/** * Lists all Service models. * @return mixed */ public function actionIndex() { $searchModel = new ServiceSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $cat = Category::find()->orderBy('name_pt')->asArray()->all(); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cat' => $cat]); }
/** * Displays the index (home) page. * Use it in case your home page contains static content. * * @return string */ public function actionIndex() { $searchModel = new ServiceSearch(); $searchModel->promo = true; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('tempindex', ['cat' => Category::find()->orderBy('name_pt')->all(), 'serv' => Service::find()->orderBy('title_pt')->all(), 'modelImg' => Campaign::find()->one(), 'dataProvider' => $dataProvider]); }
/** * Lists all ServiceRecord models. * @return mixed */ public function actionIndex() { $searchModel = new ServiceSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Run the database seeds. * * @return void */ public function run() { $this->command->info('Start AddressSearch seeder!'); ServiceSearch::create(['name' => 'PostOficce Brazil search', 'model_reference' => 'App\\Services\\AddressSearch\\PostOfficeBrazil', 'country_code' => 'BR', 'status' => 1]); $this->command->info('AddressSearch table seeded!'); }
/** * Reverse the migrations. * * @return void */ public function down() { if (Schema::hasTable(ServiceSearch::getTableName())) { Schema::drop(ServiceSearch::getTableName()); } }
public function search(Request $request) { $postalCode = $request->input('postal_code', ''); $countryCode = $request->input('country_code', ''); $this->validCountry($countryCode); if (!strlen($postalCode)) { throw new StoreResourceFailedException("Invalid postal code '{$code}'"); } $model = ServiceSearch::where('country_code', $countryCode)->first(); if (!$model) { throw new StoreResourceFailedException("Service search not found to country '{$countryCode}'"); } $searchService = new $model->model_reference($model, $this->addressRepository); $searchService->setPostalCode($postalCode); $result = $searchService->search(); return response()->json(['data' => $result]); }