middleware(function ($request, $next) { $this->form = CalendarForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('bixo.schedule.modules'), 'schedule', guard_url('schedule')); return $next($request); }); } /** * Display a list of calendar. * * @return Response */ public function index(CalendarResourceRequest $request) { $request = $request->all(); $page = CalendarActions::run('paginate', $request); $data = new CalendarsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('schedule::calendar.names')) ->view('schedule::calendar.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display calendar. * * @param Request $request * @param Model $calendar * * @return Response */ public function show(CalendarResourceRequest $request, Calendar $model) { $form = $this->form; $modules = $this->modules; $data = new CalendarResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('schedule::calendar.name')) ->data(compact('data', 'form', 'modules')) ->view('schedule::calendar.show') ->output(); } /** * Show the form for creating a new calendar. * * @param Request $request * * @return Response */ public function create(CalendarResourceRequest $request, Calendar $model) { $form = $this->form; $modules = $this->modules; $data = new CalendarResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('schedule::calendar.name')) ->view('schedule::calendar.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new calendar. * * @param Request $request * * @return Response */ public function store(CalendarResourceRequest $request, Calendar $model) { try { $request = $request->all(); $model = CalendarAction::run('store', $model, $request); $data = new CalendarResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('schedule::calendar.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('schedule/calendar/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/schedule/calendar')) ->redirect(); } } /** * Show calendar for editing. * * @param Request $request * @param Model $calendar * * @return Response */ public function edit(CalendarResourceRequest $request, Calendar $model) { $form = $this->form; $modules = $this->modules; $data = new CalendarResource($model); // return view('schedule::calendar.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('schedule::calendar.name')) ->view('schedule::calendar.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the calendar. * * @param Request $request * @param Model $calendar * * @return Response */ public function update(CalendarResourceRequest $request, Calendar $model) { try { $request = $request->all(); $model = CalendarAction::run('update', $model, $request); $data = new CalendarResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('schedule::calendar.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('schedule/calendar/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('schedule/calendar/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the calendar. * * @param Model $calendar * * @return Response */ public function destroy(CalendarResourceRequest $request, Calendar $model) { try { $request = $request->all(); $model = CalendarAction::run('destroy', $model, $request); $data = new CalendarResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('schedule::calendar.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('schedule/calendar/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('schedule/calendar/' . $model->getRouteKey())) ->redirect(); } } }