Example #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, $eventId)
 {
     //
     $input = Input::except('token');
     $room = Room::firstOrNew(['event_id' => $eventId]);
     if ($room->id) {
         return $this->respondExistingRelationship('Event already has a Room!');
     }
     $validator = $room->getValidator($input);
     if ($validator->fails()) {
         return $this->respondInvalidData($validator->errors());
     }
     $room->fill($input);
     $room->event_id = $eventId;
     $room->save();
     return $this->respondCreateSuccess('Room created');
 }