Example #1
0
 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!');
     }
 }
Example #2
0
        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;
Example #3
0
 public function show($id)
 {
     return Response::json(['msg' => 'valid', 'school' => School::with(['affiliations', 'types'])->find($id)]);
 }
Example #4
0
 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'));
 }