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