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