/**
  * Create a Vehicle for an Event.
  *
  * @param  VehicleRequest  $request
  * @param  int  $eid
  * @return Response
  */
 public function store(VehicleRequest $request, $eid)
 {
     try {
         $user = $this->isEventManager($request, $eid);
         if (!$user) {
             return response()->error(403, 'You are not a manager of this event!');
         }
         $event = Event::find($eid);
         if (!$event) {
             return response()->error(404, 'Event Not Found');
         }
         $vehicle = new EventVehicle($request->all());
         $vehicle->event()->associate($event);
         $vehicle->save();
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
Exemple #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // ---------------------------------------------------------------------
     // CONFERENCE 2
     // ---------------------------------------------------------------------
     $conference = Conference::find(2);
     $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'arrival'];
     $vehicle = new ConferenceVehicle($vehicle);
     $vehicle->conference()->associate($conference);
     $vehicle->save();
     $vehicle = ['name' => 'Airport Taxi', 'passenger_count' => 0, 'capacity' => 7, 'type' => 'departure'];
     $vehicle = new ConferenceVehicle($vehicle);
     $vehicle->conference()->associate($conference);
     $vehicle->save();
     $event = $conference->events()->first();
     $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'arrival'];
     $vehicle = new EventVehicle($vehicle);
     $vehicle->event()->associate($event);
     $vehicle->save();
     $vehicle = ['name' => 'Hotel Shuttle', 'passenger_count' => 0, 'capacity' => 50, 'type' => 'departure'];
     $vehicle = new EventVehicle($vehicle);
     $vehicle->event()->associate($event);
     $vehicle->save();
 }