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