repository = $ourteam; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\Ourteam\Repositories\Criteria\OurteamResourceCriteria::class); } /** * Display a list of ourteam. * * @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(); } $ourteams = $this->repository->paginate(); return $this->response->title(trans('ourteam::ourteam.names')) ->view('ourteam::ourteam.index', true) ->data(compact('ourteams')) ->output(); } /** * Display ourteam. * * @param Request $request * @param Model $ourteam * * @return Response */ public function show(OurteamRequest $request, Ourteam $ourteam) { if ($ourteam->exists) { $view = 'ourteam::ourteam.show'; } else { $view = 'ourteam::ourteam.new'; } return $this->response->title(trans('app.view') . ' ' . trans('ourteam::ourteam.name')) ->data(compact('ourteam')) ->view($view, true) ->output(); } /** * Show the form for creating a new ourteam. * * @param Request $request * * @return Response */ public function create(OurteamRequest $request) { $ourteam = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('ourteam::ourteam.name')) ->view('ourteam::ourteam.create', true) ->data(compact('ourteam')) ->output(); } /** * Create new ourteam. * * @param Request $request * * @return Response */ public function store(OurteamRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $ourteam = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('ourteam::ourteam.name')])) ->code(204) ->status('success') ->url(guard_url('ourteam/ourteam/' . $ourteam->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/ourteam/ourteam')) ->redirect(); } } /** * Show ourteam for editing. * * @param Request $request * @param Model $ourteam * * @return Response */ public function edit(OurteamRequest $request, Ourteam $ourteam) { return $this->response->title(trans('app.edit') . ' ' . trans('ourteam::ourteam.name')) ->view('ourteam::ourteam.edit', true) ->data(compact('ourteam')) ->output(); } /** * Update the ourteam. * * @param Request $request * @param Model $ourteam * * @return Response */ public function update(OurteamRequest $request, Ourteam $ourteam) { try { $attributes = $request->all(); $ourteam->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('ourteam::ourteam.name')])) ->code(204) ->status('success') ->url(guard_url('ourteam/ourteam/' . $ourteam->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ourteam/ourteam/' . $ourteam->getRouteKey())) ->redirect(); } } /** * Remove the ourteam. * * @param Model $ourteam * * @return Response */ public function destroy(OurteamRequest $request, Ourteam $ourteam) { try { $ourteam->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('ourteam::ourteam.name')])) ->code(202) ->status('success') ->url(guard_url('ourteam/ourteam/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ourteam/ourteam/' . $ourteam->getRouteKey())) ->redirect(); } } /** * Remove multiple ourteam. * * @param Model $ourteam * * @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('ourteam::ourteam.name')])) ->status("success") ->code(202) ->url(guard_url('ourteam/ourteam')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ourteam/ourteam')) ->redirect(); } } /** * Restore deleted ourteams. * * @param Model $ourteam * * @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('ourteam::ourteam.name')])) ->status("success") ->code(202) ->url(guard_url('/ourteam/ourteam')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ourteam/ourteam/')) ->redirect(); } } }