Bennd

models/City.php

Dec 10th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <?php
  2.  
  3. namespace app\models;
  4.  
  5. use Yii;
  6.  
  7. /**
  8.  * This is the model class for table "city".
  9.  *
  10.  * @property integer $id
  11.  * @property string $locality
  12.  * @property string $administrative_area_level_1
  13.  * @property string $administrative_area_level_2
  14.  * @property string $country
  15.  * @property string $postal_code
  16.  * @property string $latitude
  17.  * @property string $longitude
  18.  * @property string $place_id
  19.  *
  20.  * @property Profile[] $profiles
  21.  */
  22. class City extends \yii\db\ActiveRecord
  23. {
  24.     /**
  25.      * @inheritdoc
  26.      */
  27.     public static function tableName()
  28.     {
  29.         return 'city';
  30.     }
  31.  
  32.     /**
  33.      * @inheritdoc
  34.      */
  35.     public function rules()
  36.     {
  37.         return [
  38.             [['country', 'locality'], 'required'],
  39.             [['locality', 'administrative_area_level_1', 'administrative_area_level_2', 'country', 'postal_code', 'latitude', 'longitude', 'place_id'], 'string', 'max' => 45],
  40.         ];
  41.     }
  42.  
  43.     /**
  44.      * @inheritdoc
  45.      */
  46.     public function attributeLabels()
  47.     {
  48.         return [
  49.             'id' => Yii::t('app', 'ID'),
  50.             'locality' => Yii::t('app', 'Locality'),
  51.             'administrative_area_level_1' => Yii::t('app', 'Admin Area Level 1'),
  52.             'administrative_area_level_2' => Yii::t('app', 'Admin Area Level 2'),
  53.             'country' => Yii::t('app', 'Country'),
  54.             'postal_code' => Yii::t('app', 'Postal Code'),
  55.             'latitude' => Yii::t('app', 'Latitude'),
  56.             'longitude' => Yii::t('app', 'Longitude'),
  57.             'place_id' => Yii::t('app', 'Google Place ID'),
  58.         ];
  59.     }
  60.  
  61.     /**
  62.      * @return \yii\db\ActiveQuery
  63.      */
  64.     public function getProfiles()
  65.     {
  66.         return $this->hasMany(Profile::className(), ['location' => 'id']);
  67.     }
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment