Beispiel #1
0
 public function searchVariants($throughId, $field, $param, Request $request)
 {
     $throughId = Obfuscater::decode($throughId);
     $outlet = $this->getRepository()->find($throughId);
     $com = new NoCompany($outlet->variants());
     $variantRepo = new EloquentRepository($com);
     return $this->mediator->checkPermission($this->indexAccess)->setRequest($request)->setWith()->setPerPage()->orderBy()->search($variantRepo, $field, $param, new VariantTransformer());
 }
 public function execute()
 {
     \DB::transaction(function () {
         $this->data['outlet_ids'] = Obfuscater::decode($this->data['outlet_ids']);
         $this->data['company_id'] = $this->auth->getCompanyId();
         foreach ($this->data['outlet_ids'] as $outletId) {
             //attach product to each outlets and save variants
             $this->data['outlet_id'] = $outletId;
             $product = Product::create($this->data);
             //create variant Models
             foreach ($this->data['variants'] as $variant) {
                 $product->variants()->create($variant);
             }
         }
     });
 }
Beispiel #3
0
 public function execute()
 {
     \DB::transaction(function () {
         $authorizer = new Authorizer();
         if ($this->data['title'] === 1) {
             $this->data['title'] = 'staff';
             $authorizer->managerDefault();
         }
         if ($this->data['title'] === 2) {
             $this->data['title'] = 'kasir';
             $authorizer->cashierDefault();
         }
         if ($this->data['title'] === 3) {
             $this->data['title'] = 'owner';
             $authorizer->ownerDefault();
         }
         $this->data['password'] = bcrypt($this->data['password']);
         $user = $this->factory->create($this->data);
         $authorizer->setUser($user)->giveAccess($this->data['privileges']);
         $outletIds = Obfuscater::decode($this->data['outlet_id']);
         $user->outlets()->attach($outletIds);
     });
 }
Beispiel #4
0
 public function settledThrough($throughId, $dateRange, Request $request)
 {
     $throughId = Obfuscater::decode($throughId);
     $report = new OrderReport($this->getQueryType($throughId));
     return $this->mediator->checkPermission($this->reportAccess)->setRequest($request)->setWith()->setPerPage()->orderBy()->report($dateRange, $report->isNotVoid()->haveDebtAndSettled(), $this->getReportTransformer());
 }
Beispiel #5
0
 public function myCompany(Request $request)
 {
     $companyId = Obfuscater::encode($this->auth->getCompanyId());
     return $this->mediator->checkPermission($this->indexAccess)->setRequest($request)->setWith()->show($companyId, $this->getRepository(), $this->getTransformer());
 }
 public function transform(BusinessField $businessField)
 {
     return ['id' => Obfuscater::encode($businessField->id), 'name' => $businessField->name];
 }
Beispiel #7
0
 public function searchThrough($throughId, $field, $param, Request $request)
 {
     $throughId = Obfuscater::decode($throughId);
     return $this->mediator->checkPermission($this->indexAccess)->setRequest($request)->setWith()->orderBy()->setPerPage()->search($this->getRepository($throughId), $field, $param, $this->getTransformer());
 }
Beispiel #8
0
 public function reportFor($id, $dateRange, Report $report, TransformerAbstract $transformer)
 {
     $result = $report->whenDate($dateRange)->getResultFor(Obfuscater::decode($id))->paginate($this->perPage);
     return $this->response->resource()->including($this->with)->withPaginated($result, $transformer);
 }