repository = $brand; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Shopping\Brand\Repositories\Criteria\BrandResourceCriteria::class); } /** * Display a list of brand. * * @return Response */ public function index(BrandRequest $request) { return $this->repository ->setPresenter(\Shopping\Brand\Repositories\Presenter\BrandPresenter::class) ->paginate(); } /** * Display brand. * * @param Request $request * @param Model $brand * * @return Response */ public function show(BrandRequest $request, Brand $brand) { return $brand->setPresenter(\Shopping\Brand\Repositories\Presenter\BrandListPresenter::class); ; } /** * Create new brand. * * @param Request $request * * @return Response */ public function store(BrandRequest $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('brand::brand.name')]); $code = 204; $status = 'success'; $url = guard_url('brand/brand/' . $brand->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('brand/brand'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the brand. * * @param Request $request * @param Model $brand * * @return Response */ public function update(BrandRequest $request, Brand $brand) { try { $data = $request->all(); $brand->update($data); $message = trans('messages.success.updated', ['Module' => trans('brand::brand.name')]); $code = 204; $status = 'success'; $url = guard_url('brand/brand/' . $brand->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('brand/brand/' . $brand->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the brand. * * @param Model $brand * * @return Response */ public function destroy(BrandRequest $request, Brand $brand) { try { $brand->delete(); $message = trans('messages.success.deleted', ['Module' => trans('brand::brand.name')]); $code = 202; $status = 'success'; $url = guard_url('brand/brand/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('brand/brand/' . $brand->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); } }