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