model = $publicity; $this->model->setUserFilter(); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(PublicityUserRequest $request) { $publicities = $this->model->all(); $this->theme->prependTitle(trans('publicity::publicity.names').' :: '); return $this->theme->of('publicity::user.publicity.index', compact('publicities'))->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(PublicityUserRequest $request, $role, $id) { $publicity = $this->model->find($id); return $this->theme->of('publicity::user.publicity.show', compact('publicity'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(PublicityUserRequest $request) { $publicity = $this->model->findOrNew(0); Former::populate($publicity); return $this->theme->of('publicity::user.publicity.create', compact('publicity'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(PublicityUserRequest $request) { try { $attributes = $request->all(); $publicity = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('publicity::publicity.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(PublicityUserRequest $request, $role, $id) { $publicity = $this->model->find($id); Former::populate($publicity); return $this->theme->of('publicity::user.publicity.edit', compact('publicity'))->render(); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(PublicityUserRequest $request, $role, $id) { try { $attributes = $request->all(); $publicity = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('publicity::publicity.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(PublicityUserRequest $request, $role, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('publicity::publicity.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }