/**
  * Create a Vehicle for a Conference.
  *
  * @param  VehicleRequest  $request
  * @param  int  $cid
  * @return Response
  */
 public function store(VehicleRequest $request, $cid)
 {
     try {
         $user = $this->isConferenceManager($request, $cid);
         if (!$user) {
             return response()->error(403, 'You are not a manager of this conference!');
         }
         $conference = Conference::find($cid);
         if (!$conference) {
             return response()->error(404, 'Conference Not Found');
         }
         $vehicle = new ConferenceVehicle($request->all());
         $vehicle->conference()->associate($conference);
         $vehicle->save();
         return response()->success();
     } catch (Exception $e) {
         return response()->error();
     }
 }
Example #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();
 }