| 1 | <?php |
||
| 16 | class PostAbridge extends \yii\db\ActiveRecord |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @inheritdoc |
||
| 20 | */ |
||
| 21 | public static function tableName() |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @inheritdoc |
||
| 28 | */ |
||
| 29 | public function behaviors() |
||
| 30 | { |
||
| 31 | return [ |
||
| 32 | 'ml' => [ |
||
| 33 | 'class' => MultilingualBehavior::className(), |
||
| 34 | 'languages' => [ |
||
| 35 | 'ru' => 'Russian', |
||
| 36 | 'en-US' => 'English', |
||
| 37 | ], |
||
| 38 | 'defaultLanguage' => 'ru', |
||
| 39 | 'langForeignKey' => 'post_id', |
||
| 40 | 'tableName' => "{{%postLang}}", |
||
| 41 | 'attributes' => [ |
||
| 42 | 'title', 'body', |
||
| 43 | ] |
||
| 44 | ], |
||
| 45 | ]; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @inheritdoc |
||
| 50 | */ |
||
| 51 | public function rules() |
||
| 52 | { |
||
| 53 | return [ |
||
| 54 | [['title', 'body'], 'required'], |
||
| 55 | ['title', 'string'], |
||
| 56 | ]; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @inheritdoc |
||
| 61 | */ |
||
| 62 | public function transactions() |
||
| 63 | { |
||
| 64 | return [ |
||
| 65 | self::SCENARIO_DEFAULT => self::OP_ALL, |
||
| 66 | ]; |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @inheritdoc |
||
| 71 | */ |
||
| 72 | public static function find() |
||
| 76 | } |