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