Exemplo n.º 1
0
 public function getCar()
 {
     $carId = $this->carId ? $this->carId : 0;
     return Car::where('user_id', $this->user_id)->where('id', $carId)->first();
 }
Exemplo n.º 2
0
            }
            $booking->save();
            $ms->addMessageTranslated("success", "Bokning uppdateras", $post);
        }
    }
});
// show booking
$app->get('/bookings/:booking_id/?', function ($bookingId) use($app) {
    $booking = UF\Booking::where('user_id', $app->user->id)->where('id', $bookingId)->first();
    if (empty($booking)) {
        exit("Show booking {$bookingId}: Booking not found");
    }
    // Get the validation rules for the form on this page
    $schema = new \Fortress\RequestSchema($app->config('schema.path') . "/forms/booking-update.json");
    $app->jsValidator->setSchema($schema);
    $cars = UF\Car::where('user_id', $app->user->id)->get();
    $statuses = array('new' => 'Ohanterat', 'accepted' => 'Accepterad');
    foreach ($cars as $car) {
        $statuses['accepted-' . $car->id] = 'Accepterad (' . $car->title . ')';
    }
    $statuses['rejected'] = 'Avvisad';
    $app->render('booking.twig', ['booking' => $booking, 'validators' => $app->jsValidator->rules(), 'statuses' => $statuses]);
});
$app->get('/bookings/?', function () use($app) {
    $period = isset($_GET['period']) && in_array($_GET['period'], ['day', 'week', 'month']) ? $_GET['period'] : 'plan';
    $startUts = $endUts = 0;
    switch ($period) {
        case 'plan':
            $startUts = strtotime('today');
            $endUts = $startUts + 8640000;
            break;