public function store($roomId) { $request = json_decode(request()->getContent()); $schedule = new Schedule(); $schedule->date = $request->date; $schedule->start = $request->start; $schedule->course_id = $request->course_id; $schedule->duration = $request->duration; $schedule->room_id = $roomId; $saved = $schedule->save(); return response()->json(array('error' => !$saved, 'schedule' => $schedule->toArray()), $saved ? 200 : 500); }