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