Blame view

common/models/Spots.php 2.17 KB
c7f222e2   Artem   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  <?php
  
  namespace common\models;
  
  use Yii;
  use common\models;
  
  /**
   * This is the model class for table "{{%spots}}".
   *
   * @property integer $id
   * @property string $difficulty_level
   * @property string $coordinates_x
   * @property string $coordinates_y
   * @property integer $address
   * @property integer $email
   * @property string $description
   * @property string $gallery
   * @property string $how_to_get
   * @property string $name
   * @property string $schools_id
   * @property string $forecast_id
   * @property string $forecast_code
   */
4263bb14   Administrator   change view
25
  class Spots extends GalleryRecord
c7f222e2   Artem   first
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
  {
      public $file_three;
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return '{{%spots}}';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['gallery', 'how_to_get','address', 'email','description'], 'string'],
              [['name'], 'required'],
              [['file_three'], 'file'],
              [['difficulty_level', 'coordinates_x', 'coordinates_y', 'name','schools_id','forecast_id','forecast_code'], 'string', 'max' => 255]
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'id' => 'ID',
              'difficulty_level' => 'Difficulty Level',
              'coordinates_x' => 'Coordinates X',
              'coordinates_y' => 'Coordinates Y',
              'address' => 'Address',
              'email' => 'Email',
              'description' => 'Description',
              'gallery' => 'Gallery',
              'how_to_get' => 'How To Get',
              'name' => 'Name',
              'forecast_id'=> 'ID прогноза',
              'forecast_code'=> 'Код прогноза'
          ];
      }
  
  
      function isActive($array)
      {
          $array = explode(',' , $array);
          if(in_array($this->id, $array)){
              return "checked";
          } else{
              return "";
          }
      }
  
      public function behaviors()
      {
          return [
              'slug' => [
                  'class' => 'common\behaviors\Slug',
                  'in_attribute' => 'name',
                  'out_attribute' => 'translit',
                  'translit' => true
              ]
          ];
      }
  }