middleware(function ($request, $next) { $this->form = SellerForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('crm.seller.modules'), 'seller', guard_url('seller')); return $next($request); }); } /** * Display a list of seller. * * @return Response */ public function index(SellerResourceRequest $request) { $request = $request->all(); $page = SellerActions::run('paginate', $request); $data = new SellersCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('seller::seller.names')) ->view('seller::seller.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display seller. * * @param Request $request * @param Model $seller * * @return Response */ public function show(SellerResourceRequest $request, Seller $model) { $form = $this->form; $modules = $this->modules; $data = new SellerResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('seller::seller.name')) ->data(compact('data', 'form', 'modules')) ->view('seller::seller.show') ->output(); } /** * Show the form for creating a new seller. * * @param Request $request * * @return Response */ public function create(SellerResourceRequest $request, Seller $model) { $form = $this->form; $modules = $this->modules; $data = new SellerResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('seller::seller.name')) ->view('seller::seller.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new seller. * * @param Request $request * * @return Response */ public function store(SellerResourceRequest $request, Seller $model) { try { $request = $request->all(); $model = SellerAction::run('store', $model, $request); $data = new SellerResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('seller::seller.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('seller/seller/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/seller/seller')) ->redirect(); } } /** * Show seller for editing. * * @param Request $request * @param Model $seller * * @return Response */ public function edit(SellerResourceRequest $request, Seller $model) { $form = $this->form; $modules = $this->modules; $data = new SellerResource($model); // return view('seller::seller.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('seller::seller.name')) ->view('seller::seller.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the seller. * * @param Request $request * @param Model $seller * * @return Response */ public function update(SellerResourceRequest $request, Seller $model) { try { $request = $request->all(); $model = SellerAction::run('update', $model, $request); $data = new SellerResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('seller::seller.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('seller/seller/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('seller/seller/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the seller. * * @param Model $seller * * @return Response */ public function destroy(SellerResourceRequest $request, Seller $model) { try { $request = $request->all(); $model = SellerAction::run('destroy', $model, $request); $data = new SellerResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('seller::seller.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('seller/seller/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('seller/seller/' . $model->getRouteKey())) ->redirect(); } } }