middleware('web'); $this->middleware('auth:web'); $this->setupTheme(config('theme.themes.user.theme'), config('theme.themes.user.layout')); $this->repository = $incidentpkg; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(IncidentpkgUserWebRequest $request) { $this->repository->pushCriteria(new \Assetdocs\Incidentpkg\Repositories\Criteria\IncidentpkgUserCriteria()); $incidentpkgs = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('incidentpkg::incidentpkg.names').' :: '); return $this->theme->of('incidentpkg::user.incidentpkg.index', compact('incidentpkgs'))->render(); } /** * Display the specified resource. * * @param Request $request * @param Incidentpkg $incidentpkg * * @return Response */ public function show(IncidentpkgUserWebRequest $request, Incidentpkg $incidentpkg) { Form::populate($incidentpkg); return $this->theme->of('incidentpkg::user.incidentpkg.show', compact('incidentpkg'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(IncidentpkgUserWebRequest $request) { $incidentpkg = $this->repository->newInstance([]); Form::populate($incidentpkg); return $this->theme->of('incidentpkg::user.incidentpkg.create', compact('incidentpkg'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(IncidentpkgUserWebRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $incidentpkg = $this->repository->create($attributes); return redirect(trans_url('/user/incidentpkg/incidentpkg')) -> with('message', trans('messages.success.created', ['Module' => trans('incidentpkg::incidentpkg.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 Incidentpkg $incidentpkg * * @return Response */ public function edit(IncidentpkgUserWebRequest $request, Incidentpkg $incidentpkg) { Form::populate($incidentpkg); return $this->theme->of('incidentpkg::user.incidentpkg.edit', compact('incidentpkg'))->render(); } /** * Update the specified resource. * * @param Request $request * @param Incidentpkg $incidentpkg * * @return Response */ public function update(IncidentpkgUserWebRequest $request, Incidentpkg $incidentpkg) { try { $this->repository->update($request->all(), $incidentpkg->getRouteKey()); return redirect(trans_url('/user/incidentpkg/incidentpkg')) ->with('message', trans('messages.success.updated', ['Module' => trans('incidentpkg::incidentpkg.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(IncidentpkgUserWebRequest $request, Incidentpkg $incidentpkg) { try { $this->repository->delete($incidentpkg->getRouteKey()); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('incidentpkg::incidentpkg.name')]), 'code' => 202, 'redirect' => trans_url('/user/incidentpkg/incidentpkg/0'), ], 202); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }