form = MeetingForm::setAttributes()->toArray(); $this->modules = $this->modules(config('litecms.meeting.modules'), 'meeting', guard_url('meeting')); $this->repository = $meeting; } /** * Display a list of meeting. * * @return Response */ public function index(MeetingRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(MeetingResourceFilter::class) ->setPresenter(MeetingListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('meeting::meeting.names')) ->view('meeting::meeting.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function show(MeetingRequest $request, MeetingRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('meeting::meeting.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('meeting::meeting.show') ->output(); } /** * Show the form for creating a new meeting. * * @param Request $request *x * @return Response */ public function create(MeetingRequest $request, MeetingRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('meeting::meeting.name')) ->view('meeting::meeting.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new meeting. * * @param Request $request * * @return Response */ public function store(MeetingRequest $request, MeetingRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.created', ['Module' => trans('meeting::meeting.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('meeting/meeting/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/meeting/meeting')) ->redirect(); } } /** * Show meeting for editing. * * @param Request $request * @param Model $meeting * * @return Response */ public function edit(MeetingRequest $request, MeetingRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('meeting::meeting.name')) ->view('meeting::meeting.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function update(MeetingRequest $request, MeetingRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('meeting::meeting.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('meeting/meeting/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('meeting/meeting/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the meeting. * * @param Model $meeting * * @return Response */ public function destroy(MeetingRequest $request, MeetingRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('meeting::meeting.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('meeting/meeting/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('meeting/meeting/' . $repository->getRouteKey())) ->redirect(); } } }