Exemplo n.º 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());
 }
Exemplo n.º 2
0
 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);
             }
         }
     });
 }
Exemplo n.º 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);
     });
 }
Exemplo n.º 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());
 }
Exemplo n.º 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());
 }
Exemplo n.º 6
0
 public function transform(BusinessField $businessField)
 {
     return ['id' => Obfuscater::encode($businessField->id), 'name' => $businessField->name];
 }
Exemplo n.º 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());
 }
Exemplo n.º 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);
 }