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