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