本文整理汇总了PHP中School::with方法的典型用法代码示例。如果您正苦于以下问题:PHP School::with方法的具体用法?PHP School::with怎么用?PHP School::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类School
的用法示例。
在下文中一共展示了School::with方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
public function destroy($id)
{
$school = School::with('educations')->find($id);
if ($school->educations->count() > 0) {
Session::flash('message', 'Tidak dapat menghapus sekolah! Sekolah ini merupakan sekolah asal salah satu siswa');
} else {
School::destroy($id);
Session::flash('message', 'Sukses menghapus data sekolah!');
}
}
示例2: function
if ($app->request->isGet()) {
$data['skill'] = $skill->toArray();
} else {
if ($app->request->isPost()) {
$skill->name = $app->request->post('title');
$skill->save();
$data['new_skill'] = $skill->toArray();
}
}
$app->render('skills/edit.html', $data);
})->via('GET', 'POST')->name('skills_edit');
});
$app->group('/schools', function () use($app, $data) {
$data['request_method'] = $app->request->getMethod();
$app->get('/', function () use($app, $data) {
$data['schools'] = School::with('User')->orderBy('name', 'ASC')->get()->toArray();
$app->render('schools/overview.html', $data);
})->name('schools_overview');
$app->map('/delete/:id', function ($id) use($app, $data) {
$data['school'] = School::find($id);
if ($app->request->isPost()) {
$data['school']->delete();
}
$app->render('schools/delete.html', $data);
})->via('GET', 'POST')->name('schools_delete');
$app->map('/new', function () use($app, $data) {
if ($app->request->isPost()) {
$school = new School();
$school->name = $app->request->post('name');
$school->save();
$data['new_school'] = $school;
示例3: show
public function show($id)
{
return Response::json(['msg' => 'valid', 'school' => School::with(['affiliations', 'types'])->find($id)]);
}
示例4: recapSchoolGeneration
public function recapSchoolGeneration()
{
$educations = Education::with('school')->where('project_id', '=', Auth::user()->curr_project_id)->groupBy('school_id')->get();
$generations = Generation::all();
$menu = 'report';
$schools = array();
foreach ($educations as $education) {
$statistics = array();
foreach ($generations as $generation) {
$count = School::with(array('educations', 'educations.issues'))->join('educations', 'educations.school_id', '=', 'schools.id')->join('issues', 'issues.id', '=', 'educations.issue_id')->where('issues.generation_id', '=', $generation->id)->where('schools.id', '=', $education->school_id)->count();
$statistics[] = array('count' => $count);
}
$schools[] = array('id' => $education->school_id, 'name' => $education->school->name, 'statistics' => $statistics);
}
return View::make('reports.recapschoolgeneration', compact('schools', 'generations', 'menu'));
}