repository = $v_l_a_n_s; parent::__construct(); } /** * Display a list of v_l_a_n_s. * * @return Response */ public function index(VLANSRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('v_l_a_n::v_l_a_n_s.names').' :: '); return $this->theme->of('v_l_a_n::admin.v_l_a_n_s.index')->render(); } /** * Display a list of v_l_a_n_s. * * @return Response */ public function getJson(VLANSRequest $request) { $pageLimit = $request->input('pageLimit'); $v_l_a_n_s_s = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Codi22\\VLAN\\Repositories\\Presenter\\VLANSListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $v_l_a_n_s_s['recordsTotal'] = $v_l_a_n_s_s['meta']['pagination']['total']; $v_l_a_n_s_s['recordsFiltered'] = $v_l_a_n_s_s['meta']['pagination']['total']; $v_l_a_n_s_s['request'] = $request->all(); return response()->json($v_l_a_n_s_s, 200); } /** * Display v_l_a_n_s. * * @param Request $request * @param Model $v_l_a_n_s * * @return Response */ public function show(VLANSRequest $request, VLANS $v_l_a_n_s) { if (!$v_l_a_n_s->exists) { return response()->view('v_l_a_n::admin.v_l_a_n_s.new', compact('v_l_a_n_s')); } Form::populate($v_l_a_n_s); return response()->view('v_l_a_n::admin.v_l_a_n_s.show', compact('v_l_a_n_s')); } /** * Show the form for creating a new v_l_a_n_s. * * @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); return response()->view('v_l_a_n::admin.v_l_a_n_s.create', compact('v_l_a_n_s')); } /** * Create new v_l_a_n_s. * * @param Request $request * * @return Response */ public function store(VLANSRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $v_l_a_n_s = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('v_l_a_n::v_l_a_n_s.name')]), 'code' => 204, 'redirect' => trans_url('/admin/v_l_a_n/v_l_a_n_s/'.$v_l_a_n_s->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show v_l_a_n_s for editing. * * @param Request $request * @param Model $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); return response()->view('v_l_a_n::admin.v_l_a_n_s.edit', compact('v_l_a_n_s')); } /** * Update the v_l_a_n_s. * * @param Request $request * @param Model $v_l_a_n_s * * @return Response */ public function update(VLANSRequest $request, VLANS $v_l_a_n_s) { try { $attributes = $request->all(); $v_l_a_n_s->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('v_l_a_n::v_l_a_n_s.name')]), 'code' => 204, 'redirect' => trans_url('/admin/v_l_a_n/v_l_a_n_s/'.$v_l_a_n_s->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/v_l_a_n/v_l_a_n_s/'.$v_l_a_n_s->getRouteKey()), ], 400); } } /** * Remove the v_l_a_n_s. * * @param Model $v_l_a_n_s * * @return Response */ public function destroy(VLANSRequest $request, VLANS $v_l_a_n_s) { try { $t = $v_l_a_n_s->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('v_l_a_n::v_l_a_n_s.name')]), 'code' => 202, 'redirect' => trans_url('/admin/v_l_a_n/v_l_a_n_s/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/v_l_a_n/v_l_a_n_s/'.$v_l_a_n_s->getRouteKey()), ], 400); } } }