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