本文整理匯總了PHP中Program::with方法的典型用法代碼示例。如果您正苦於以下問題:PHP Program::with方法的具體用法?PHP Program::with怎麽用?PHP Program::with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Program
的用法示例。
在下文中一共展示了Program::with方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: studentPerprogramFilter
public function studentPerprogramFilter($id)
{
$program_id = $id;
$program = Program::with('courses')->find($program_id);
$programs = Program::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->get();
$menu = 'report';
return View::make('reports.studentperprogram', compact('programs', 'program', 'menu'));
}
示例2: destroy
public function destroy($id)
{
$program = Program::with('courses')->find($id);
if ($program->courses->count() > 0) {
Session::flash('message', 'Tidak dapat menutup program! Program ini pernah berjalan');
} else {
Program::destroy($id);
Session::flash('message', 'Sukses menutup program!');
return Redirect::route('programs.index');
}
}
示例3: getProgramsArchiveHtml
/**
* 獲取節目單HTML字符串
*
* @param string $keyword
* @return string
*/
private function getProgramsArchiveHtml($keyword = '')
{
// query program list, and sort by date
$programs = Program::with('participants')->enabled()->orderBy('date', 'desc')->get();
// search
if ($keyword) {
$keywords = array_filter(explode(' ', $keyword));
foreach ($keywords as $keyword) {
$participantIds = Participant::searched($keyword)->lists('id');
$programIds = ProgramParticipant::whereIn('participant_id', $participantIds)->lists('program_id')->flip()->toArray();
foreach ($programs as $i => $program) {
if (false === strpos(strtolower($program->topic), $keyword) and empty($programIds[$program->id])) {
unset($programs[$i]);
}
}
}
}
// collect
$list = [];
foreach ($programs as $program) {
$list[$program->dates->year][$program->dates->month][] = $program;
}
// render page
return (string) View::make('program.index.archive')->with('list', $list);
}