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