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