Пример #1
0
 public function all($params)
 {
     $params['order'] = isset($params['order']) ? $params['order'] : ['hotels.rating|ASC'];
     $users = Hotel::select("hotels.*");
     $users->leftJoin('companies', 'companies.id', '=', 'hotels.company_id');
     $users = parent::execute($users, $params);
     return $users;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Hotel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('location');
     $query->andFilterWhere(['id' => $this->id, 'star' => $this->star, 'regdate' => $this->regdate, 'editdate' => $this->editdate, 'status' => $this->status, 'hot' => $this->hot]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'briefinfo', $this->briefinfo])->andFilterWhere(['like', 'detailinfo', $this->detailinfo])->andFilterWhere(['like', 'smallimg', $this->smallimg])->andFilterWhere(['like', 'largeimg', $this->largeimg])->andFilterWhere(['like', 'location.name', $this->id_location]);
     return $dataProvider;
 }
 public function create($id, $tech_number = 1)
 {
     if (Auth::user()->can('create-service')) {
         $data['title'] = $tech_number == 1 ? "Create Service ~ " . $tech_number . " technician" : "Create Service ~ " . $tech_number . " technicians";
         $data['companies'] = Company::all();
         $data['company_id'] = $id;
         $data['contacts'] = CompanyPersonController::API()->all(["where" => ["company_person.company_id|=|" . $id], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]);
         $data['technicians'] = CompanyPersonController::API()->all(["where" => ["company_person.company_id|=|" . ELETTRIC80_COMPANY_ID], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]);
         $data['divisions'] = Division::orderBy("name")->get();
         $data['hotels'] = Hotel::where('company_id', $id)->orderBy("name")->get();
         $tech_number = $tech_number < 1 ? 1 : $tech_number;
         $tech_number = $tech_number > 5 ? 5 : $tech_number;
         $data['technician_number'] = $tech_number;
         foreach ($data['hotels'] as &$hotel) {
             $hotel['name_address'] = $hotel['name'] . " @ " . $hotel['address'];
         }
         return view('services/create', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to service create page']);
     }
 }
Пример #4
0
 public function getHotels()
 {
     return $this->hasMany(Hotel::className(), ['id_location' => 'id']);
 }