1 | <?php |
||
26 | class RomRelease extends \yii\db\ActiveRecord |
||
27 | { |
||
28 | public $file; |
||
29 | const STATUS_PUBLISHED = 1; |
||
30 | const STATUS_UNPUBLISHED = 0; |
||
31 | |||
32 | /** |
||
33 | * @inheritdoc |
||
34 | */ |
||
35 | 9 | public static function tableName() |
|
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | 5 | public function rules() |
|
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | */ |
||
66 | 2 | public function attributeLabels() |
|
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | 11 | public function behaviors() |
|
101 | |||
102 | 1 | public function fields() |
|
103 | { |
||
104 | 1 | $fields = parent::fields(); |
|
105 | 1 | $fields['url'] = function () { |
|
106 | 1 | $path = str_replace('api/uploads/', '', $this->getUploadUrl('url')); |
|
|
|||
107 | 1 | if (isset($_ENV['API_HOST'])) { |
|
108 | $url = $_ENV['API_HOST'] . 'files/' . $path; |
||
109 | } else { |
||
110 | 1 | $url = Url::to(['file/view', 'path' => $path], true); |
|
111 | } |
||
112 | 1 | return $url; |
|
113 | }; |
||
114 | 1 | unset($fields['id'], $fields['created_at'], $fields['status'], $fields['updated_at']); |
|
115 | 1 | return $fields; |
|
116 | } |
||
117 | |||
118 | 1 | public static function getStatusList() |
|
125 | } |
||
126 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: