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