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