$app->render('dashboard.html', $data); })->name('dashboard'); $app->group('/users', function () use($app, $data) { $app->get('/', function () use($app, $data) { $data['users'] = User::with('talents', 'educationLevel', 'skills', 'school')->orderBy('created_at', 'DESC')->get()->toArray(); $app->render('users/overview.html', $data); })->name('users_overview'); }); $app->group('/talents', function () use($app, $data) { $app->get('/', function () use($app, $data) { $data['talents'] = Talent::all()->toArray(); $app->render('talents/overview.html', $data); })->name('talents_overview'); $app->map('/edit/:id', function ($id) use($app, $data) { $data['request_method'] = $app->request->getMethod(); $talent = Talent::with('questions')->find($id); if ($app->request->isGet()) { $data['talent'] = $talent->toArray(); } else { if ($app->request->isPost()) { foreach ($app->request->post('question') as $key => $value) { $question = $talent->questions->find((int) $key); if ($question->question != $value) { $question->question = $value; $question->save(); } } $data['new_talent'] = $talent->toArray(); } } $app->render('talents/edit.html', $data);
foreach ($user->talents as $talent) { if ($talent->pivot->picked) { array_push($resp['talents'], $talent->toArray()); } } echo json_encode($resp); }); $app->get('/talent', function () use($app) { $app->response()->header('Content-Type', 'application/json'); $talent = Talent::with('questions')->get(); echo $talent->toJson(); }); $app->get('/talent/:name', function ($name) use($app) { $app->response()->header('Content-Type', 'application/json'); try { $talent = Talent::with('questions')->where('name', '=', $name)->firstOrFail(); } catch (ModelNotFoundException $e) { $app->halt(404, 'Talent niet gevonden'); } echo $talent->toJson(); }); $app->get('/schooladvice', function () use($app) { $app->response()->header('Content-Type', 'application/json'); echo EducationLevel::SchoolAdvice()->get()->toJson(); }); $app->get('/schools', function () use($app) { $app->response()->header('Content-Type', 'application/json'); echo School::all()->toJson(); }); $app->get('/skills', function () use($app) { $app->response()->header('Content-Type', 'application/json');