Exemplo n.º 1
0
        $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");
    }
    switch ($action) {
        case 'accept':
            $booking->status = 'accepted';
            break;
        case 'reject':