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