/** * Handle fetch branch list. * * @return Response */ public function allBranch() { $user = $this->getUser(); if (!is_object($user)) { return $this->getApiServer()->resourceJson(array('message' => $this->getLocale()->t('Permission denied.'), 'description' => $this->getLocale()->t('Unable to identify current logged in user.')), 403); } $branchList = Branch::all(); $branches = array(); if (!$branchList->isEmpty()) { foreach ($branchList as $branch) { $branches[] = new BranchTemplate($branch); } } unset($branchList); return $this->getApiServer()->collectionJson($branches); }
/** * Register Template Reports eBri * * @return void */ public function registerTemplate() { $this->app['ebri.template'] = $this->app->share(function ($app) { $branches = Branch::all(); if ($branches->isEmpty()) { $branches = array(); } else { $branches = $branches; } $branchOffice = BranchOffice::all(); if ($branchOffice->isEmpty()) { $branchOffice = array(); } else { $branchOffice = $branchOffice; } $products = Products::all(); if ($products->isEmpty()) { $products = array(); } else { $products = $products; } return new TemplateSupport($branches, $branchOffice, $products); }); }