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