Пример #1
0
 public function setKarma(Request $request, $id)
 {
     $user = User::find($id);
     $user->karma = $request->get('karma');
     $user->save();
     return redirect(route('user.index'));
 }
Пример #2
0
 public function missed(Booking $booking)
 {
     if ($booking && $booking->went != true) {
         $booking->went = false;
         $booking->save();
         $this->karmaService->miss(User::find($booking->user_id));
     }
 }
Пример #3
0
 public function checkin(Request $request)
 {
     $data = $this->validateRequest($request, ['id', 'attendances']);
     $service = new BookingService();
     foreach ($data->attendances as $attendance) {
         if ($attendance->user && $attendance->trip && $attendance->trip == $data->id) {
             $user = User::find($attendance->user);
             $trip = Trip::find($attendance->trip);
             if ($user && $trip) {
                 $service->checkin($user, $trip);
             }
         }
     }
     $service->markMissing($trip);
     return $this->encryptJson([]);
 }
Пример #4
0
 public function store(CreateTripRequest $request, FlashNotifier $flash)
 {
     if (!Shuttle::find($request->shuttle_id)) {
         $flash->error("Error creating trip. Shuttle {$request->id} does not exist.");
         return redirect()->back()->withInput();
     }
     $driver = User::find($request->driver_id);
     if ($driver == null) {
         $flash->error("Error creating trip. User {$request->driver_id} does not exist.");
         return redirect()->back()->withInput();
     }
     if (!$driver->isDriver()) {
         $flash->error("Error creating trip. User {$driver->name} is not a driver.");
         return redirect()->back()->withInput();
     }
     $leaves = new Carbon($request->leaves_at);
     $arrives = new Carbon($request->arrives_at);
     Trip::create(['shuttle_id' => $request->shuttle_id, 'driver_id' => $request->driver_id, 'origin' => $request->origin, 'destination' => $request->destination, 'leaves_at' => $leaves, 'arrives_at' => $arrives]);
     $flash->success('Trip successfully created!');
     return back();
 }