public function getCar() { $carId = $this->carId ? $this->carId : 0; return Car::where('user_id', $this->user_id)->where('id', $carId)->first(); }
$car->save(); $uri = $app->site->uri['public'] . '/cars'; header("Location: {$uri}"); exit; } elseif (isset($post['id'], $post['delete'])) { $car = UF\Car::where('user_id', $app->user->id)->where('id', $post['id'])->first(); $car->delete(); $uri = $app->site->uri['public'] . '/cars'; header("Location: {$uri}"); exit; } }); $app->get('/cars/?', function () use($app) { $cars = UF\Car::where('user_id', $app->user->id)->orderBy('title')->get(); if ($cars->isEmpty()) { $car = new UF\Car(); $car->user_id = $app->user->id; $car->title = "Standardbil"; $car->email = ""; $car->phone = ""; $car->maxPassengerCount = 0; $car->save(); $cars = UF\Car::where('user_id', $app->user->id)->get(); } $app->render('cars.twig', ["cars" => $cars, 'csrf' => $_SESSION['csrf_token']]); }); $app->get('/booking/:booking_id/:action/:hash/?', function ($bookingId, $action, $hash) use($app) { $action = $action == 'reject' ? 'reject' : 'accept'; $booking = UF\Booking::where('id', $bookingId)->where('hash', $hash)->first(); if (!$booking) { exit("Accept/reject booking {$bookingId}: Booking not found");