repository = $committee; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litepie\Committee\Repositories\Criteria\CommitteeResourceCriteria::class); } /** * Display a list of committee. * * @return Response */ public function index(CommitteeRequest $request) { return $this->repository ->setPresenter(\Litepie\Committee\Repositories\Presenter\CommitteePresenter::class) ->paginate(); } /** * Display committee. * * @param Request $request * @param Model $committee * * @return Response */ public function show(CommitteeRequest $request, Committee $committee) { return $committee->setPresenter(\Litepie\Committee\Repositories\Presenter\CommitteeListPresenter::class); ; } /** * Create new committee. * * @param Request $request * * @return Response */ public function store(CommitteeRequest $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('committee::committee.name')]); $code = 204; $status = 'success'; $url = guard_url('committee/committee/' . $committee->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('committee/committee'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the committee. * * @param Request $request * @param Model $committee * * @return Response */ public function update(CommitteeRequest $request, Committee $committee) { try { $data = $request->all(); $committee->update($data); $message = trans('messages.success.updated', ['Module' => trans('committee::committee.name')]); $code = 204; $status = 'success'; $url = guard_url('committee/committee/' . $committee->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('committee/committee/' . $committee->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the committee. * * @param Model $committee * * @return Response */ public function destroy(CommitteeRequest $request, Committee $committee) { try { $committee->delete(); $message = trans('messages.success.deleted', ['Module' => trans('committee::committee.name')]); $code = 202; $status = 'success'; $url = guard_url('committee/committee/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('committee/committee/' . $committee->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); } }