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