public function doCreate(CreatePlanRequest $request) { $plan = new AMPlan(); $plan->am_id = \Auth::user()->id; $plan->month = $request->month . '-' . $request->year; $plan->date = $request->date; $plan->doctors = json_encode($request->doctors); try { $plan->save(); return redirect()->back()->with('message', 'Visit Plan has been sent to your managers successfully! . Wait for approval'); } catch (ParseException $ex) { echo 'Failed to create new plan , with error message: ' . $ex->getMessage(); } }