repository = $seller; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Shopping\Seller\Repositories\Criteria\SellerResourceCriteria::class); } /** * Display a list of seller. * * @return Response */ public function index(SellerRequest $request) { return $this->repository ->setPresenter(\Shopping\Seller\Repositories\Presenter\SellerPresenter::class) ->paginate(); } /** * Display seller. * * @param Request $request * @param Model $seller * * @return Response */ public function show(SellerRequest $request, Seller $seller) { return $seller->setPresenter(\Shopping\Seller\Repositories\Presenter\SellerListPresenter::class); ; } /** * Create new seller. * * @param Request $request * * @return Response */ public function store(SellerRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('seller::seller.name')]); $code = 204; $status = 'success'; $url = guard_url('seller/seller/' . $seller->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('seller/seller'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the seller. * * @param Request $request * @param Model $seller * * @return Response */ public function update(SellerRequest $request, Seller $seller) { try { $data = $request->all(); $seller->update($data); $message = trans('messages.success.updated', ['Module' => trans('seller::seller.name')]); $code = 204; $status = 'success'; $url = guard_url('seller/seller/' . $seller->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('seller/seller/' . $seller->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the seller. * * @param Model $seller * * @return Response */ public function destroy(SellerRequest $request, Seller $seller) { try { $seller->delete(); $message = trans('messages.success.deleted', ['Module' => trans('seller::seller.name')]); $code = 202; $status = 'success'; $url = guard_url('seller/seller/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('seller/seller/' . $seller->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }