repository = $notific; $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->pushCriteria(new \Asadi\Notific\Repositories\Criteria\NotificUserCriteria()); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(NotificRequest $request) { $notifics = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('notific::notific.names')); return $this->theme->of('notific::user.notific.index', compact('notifics'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Notific $notific * * @return Response */ public function show(NotificRequest $request, Notific $notific) { Form::populate($notific); return $this->theme->of('notific::user.notific.show', compact('notific'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(NotificRequest $request) { $notific = $this->repository->newInstance([]); Form::populate($notific); $this->theme->prependTitle(trans('notific::notific.names')); return $this->theme->of('notific::user.notific.create', compact('notific'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(NotificRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $notific = $this->repository->create($attributes); return redirect(trans_url('/user/notific/notific')) -> with('message', trans('messages.success.created', ['Module' => trans('notific::notific.name')])) -> with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param Notific $notific * * @return Response */ public function edit(NotificRequest $request, Notific $notific) { Form::populate($notific); $this->theme->prependTitle(trans('notific::notific.names')); return $this->theme->of('notific::user.notific.edit', compact('notific'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Notific $notific * * @return Response */ public function update(NotificRequest $request, Notific $notific) { try { $this->repository->update($request->all(), $notific->getRouteKey()); return redirect(trans_url('/user/notific/notific')) ->with('message', trans('messages.success.updated', ['Module' => trans('notific::notific.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(NotificRequest $request, Notific $notific) { try { $this->repository->delete($notific->getRouteKey()); return redirect(trans_url('/user/notific/notific')) ->with('message', trans('messages.success.deleted', ['Module' => trans('notific::notific.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }