repository = $meeting; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Activity\Repositories\Criteria\MeetingResourceCriteria::class); } /** * Display a list of meeting. * * @return Response */ public function index(MeetingRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Bixo\Activity\Repositories\Presenter\MeetingPresenter::class) ->$function(); } $meetings = $this->repository->paginate(); return $this->response->setMetaTitle(trans('activity::meeting.names')) ->view('activity::meeting.index', true) ->data(compact('meetings', 'view')) ->output(); } /** * Display meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function show(MeetingRequest $request, Meeting $meeting) { if ($meeting->exists) { $view = 'activity::meeting.show'; } else { $view = 'activity::meeting.new'; } return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('activity::meeting.name')) ->data(compact('meeting')) ->view($view, true) ->output(); } /** * Show the form for creating a new meeting. * * @param Request $request * * @return Response */ public function create(MeetingRequest $request) { $meeting = $this->repository->newInstance([]); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('activity::meeting.name')) ->view('activity::meeting.create', true) ->data(compact('meeting')) ->output(); } /** * Create new meeting. * * @param Request $request * * @return Response */ public function store(MeetingRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $meeting = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('activity::meeting.name')])) ->code(204) ->status('success') ->url(guard_url('activity/meeting/' . $meeting->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/activity/meeting')) ->redirect(); } } /** * Show meeting for editing. * * @param Request $request * @param Model $meeting * * @return Response */ public function edit(MeetingRequest $request, Meeting $meeting) { return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('activity::meeting.name')) ->view('activity::meeting.edit', true) ->data(compact('meeting')) ->output(); } /** * Update the meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function update(MeetingRequest $request, Meeting $meeting) { try { $attributes = $request->all(); $meeting->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('activity::meeting.name')])) ->code(204) ->status('success') ->url(guard_url('activity/meeting/' . $meeting->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('activity/meeting/' . $meeting->getRouteKey())) ->redirect(); } } /** * Remove the meeting. * * @param Model $meeting * * @return Response */ public function destroy(MeetingRequest $request, Meeting $meeting) { try { $meeting->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('activity::meeting.name')])) ->code(202) ->status('success') ->url(guard_url('activity/meeting/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('activity/meeting/' . $meeting->getRouteKey())) ->redirect(); } } /** * Remove multiple meeting. * * @param Model $meeting * * @return Response */ public function delete(MeetingRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('activity::meeting.name')])) ->status("success") ->code(202) ->url(guard_url('activity/meeting')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/activity/meeting')) ->redirect(); } } /** * Restore deleted meetings. * * @param Model $meeting * * @return Response */ public function restore(MeetingRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('activity::meeting.name')])) ->status("success") ->code(202) ->url(guard_url('/activity/meeting')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/activity/meeting/')) ->redirect(); } } }