Beispiel #1
0
     $app->render('occupations/delete.html', $data);
 })->via('GET', 'POST')->name('occupations_delete');
 $app->map('/new', function () use($app, $data) {
     if ($app->request->isGet()) {
         $data['education_levels'] = EducationLevel::NoSchoolAdvice()->get();
         $data['talents'] = Talent::all();
     } else {
         if ($app->request->isPost()) {
             $edu_level = EducationLevel::find($app->request->post('educationlevel'));
             $talent = Talent::find($app->request->post('talent'));
             parse_str(parse_url($app->request->post('yt-video'), PHP_URL_QUERY), $urlvars);
             $job = new Occupation();
             $job->name = $app->request->post('title');
             $job->description = $app->request->post('description');
             $job->youtube = $urlvars['v'];
             $job->educationLevel()->associate($edu_level);
             $job->talent()->associate($talent);
             $job->save();
             $data['new_occupation'] = $job;
         }
     }
     $app->render('occupations/new.html', $data);
 })->via('GET', 'POST')->name('occupations_new');
 $app->map('/edit/:id', function ($id) use($app, $data) {
     $data['request_method'] = $app->request->getMethod();
     if ($app->request->isGet()) {
         $data['occupation'] = Occupation::with('talent', 'educationLevel')->find($id);
         $data['education_levels'] = EducationLevel::NoSchoolAdvice()->get();
         $data['talents'] = Talent::all();
     } else {
         if ($app->request->isPost()) {