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