repository = $meeting; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litepie\Meeting\Repositories\Criteria\MeetingResourceCriteria::class); } /** * Display a list of meeting. * * @return Response */ public function index(MeetingRequest $request) { return $this->repository ->setPresenter(\Litepie\Meeting\Repositories\Presenter\MeetingPresenter::class) ->paginate(); } /** * Display meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function show(MeetingRequest $request, Meeting $meeting) { return $meeting->setPresenter(\Litepie\Meeting\Repositories\Presenter\MeetingListPresenter::class); ; } /** * Create new meeting. * * @param Request $request * * @return Response */ public function store(MeetingRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('meeting::meeting.name')]); $code = 204; $status = 'success'; $url = guard_url('meeting/meeting/' . $meeting->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('meeting/meeting'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the meeting. * * @param Request $request * @param Model $meeting * * @return Response */ public function update(MeetingRequest $request, Meeting $meeting) { try { $data = $request->all(); $meeting->update($data); $message = trans('messages.success.updated', ['Module' => trans('meeting::meeting.name')]); $code = 204; $status = 'success'; $url = guard_url('meeting/meeting/' . $meeting->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('meeting/meeting/' . $meeting->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the meeting. * * @param Model $meeting * * @return Response */ public function destroy(MeetingRequest $request, Meeting $meeting) { try { $meeting->delete(); $message = trans('messages.success.deleted', ['Module' => trans('meeting::meeting.name')]); $code = 202; $status = 'success'; $url = guard_url('meeting/meeting/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('meeting/meeting/' . $meeting->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }