repository = $our_team; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\OurTeam\Repositories\Criteria\OurTeamResourceCriteria::class); } /** * Display a list of our_team. * * @return Response */ public function index(OurTeamRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\OurTeam\Repositories\Presenter\OurTeamPresenter::class) ->$function(); } $our_teams = $this->repository->paginate(); return $this->response->title(trans('our_team::our_team.names')) ->view('our_team::our_team.index', true) ->data(compact('our_teams')) ->output(); } /** * Display our_team. * * @param Request $request * @param Model $our_team * * @return Response */ public function show(OurTeamRequest $request, OurTeam $our_team) { if ($our_team->exists) { $view = 'our_team::our_team.show'; } else { $view = 'our_team::our_team.new'; } return $this->response->title(trans('app.view') . ' ' . trans('our_team::our_team.name')) ->data(compact('our_team')) ->view($view, true) ->output(); } /** * Show the form for creating a new our_team. * * @param Request $request * * @return Response */ public function create(OurTeamRequest $request) { $our_team = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('our_team::our_team.name')) ->view('our_team::our_team.create', true) ->data(compact('our_team')) ->output(); } /** * Create new our_team. * * @param Request $request * * @return Response */ public function store(OurTeamRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $our_team = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('our_team::our_team.name')])) ->code(204) ->status('success') ->url(guard_url('our_team/our_team/' . $our_team->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/our_team/our_team')) ->redirect(); } } /** * Show our_team for editing. * * @param Request $request * @param Model $our_team * * @return Response */ public function edit(OurTeamRequest $request, OurTeam $our_team) { return $this->response->title(trans('app.edit') . ' ' . trans('our_team::our_team.name')) ->view('our_team::our_team.edit', true) ->data(compact('our_team')) ->output(); } /** * Update the our_team. * * @param Request $request * @param Model $our_team * * @return Response */ public function update(OurTeamRequest $request, OurTeam $our_team) { try { $attributes = $request->all(); $our_team->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('our_team::our_team.name')])) ->code(204) ->status('success') ->url(guard_url('our_team/our_team/' . $our_team->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('our_team/our_team/' . $our_team->getRouteKey())) ->redirect(); } } /** * Remove the our_team. * * @param Model $our_team * * @return Response */ public function destroy(OurTeamRequest $request, OurTeam $our_team) { try { $our_team->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('our_team::our_team.name')])) ->code(202) ->status('success') ->url(guard_url('our_team/our_team/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('our_team/our_team/' . $our_team->getRouteKey())) ->redirect(); } } /** * Remove multiple our_team. * * @param Model $our_team * * @return Response */ public function delete(OurTeamRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('our_team::our_team.name')])) ->status("success") ->code(202) ->url(guard_url('our_team/our_team')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/our_team/our_team')) ->redirect(); } } /** * Restore deleted our_teams. * * @param Model $our_team * * @return Response */ public function restore(OurTeamRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('our_team::our_team.name')])) ->status("success") ->code(202) ->url(guard_url('/our_team/our_team')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/our_team/our_team/')) ->redirect(); } } }