Service.php 3.03 KB
<?php
    
    namespace common\models;
    
    use common\behaviors\SaveImgBehavior;
    use common\modules\language\behaviors\LanguageBehavior;
    use Yii;
    use yii\behaviors\TimestampBehavior;
    use yii\db\ActiveQuery;
    use yii\db\ActiveRecord;
    use yii\web\Request;
    
    /**
     * This is the model class for table "service".
     * @property integer       $service_id
     * @property string        $image
     * @property integer       $created_at
     * @property integer       $updated_at
     * * From language behavior *
     * @property ServiceLang   $lang
     * @property ServiceLang[] $langs
     * @property ServiceLang   $object_lang
     * @property string        $ownerKey
     * @property string        $langKey
     * @property ServiceLang[] $model_langs
     * @property bool          $transactionStatus
     * @method string           getOwnerKey()
     * @method void             setOwnerKey( string $value )
     * @method string           getLangKey()
     * @method void             setLangKey( string $value )
     * @method ActiveQuery      getLangs()
     * @method ActiveQuery      getLang( integer $language_id )
     * @method ServiceLang[]    generateLangs()
     * @method void             loadLangs( Request $request )
     * @method bool             linkLangs()
     * @method bool             saveLangs()
     * @method bool             getTransactionStatus()
     * * End language behavior *
     */
    class Service extends ActiveRecord
    {
        
        /**
         * @inheritdoc
         */
        public static function tableName()
        {
            return 'service';
        }
        
        /**
         * @inheritdoc
         */
        public function rules()
        {
            return [
                [
                    [
                        'created_at',
                        'updated_at',
                    ],
                    'integer',
                ],
            ];
        }
        
        /**
         * @inheritdoc
         */
        public function behaviors()
        {
            return [
                [
                    'class'  => SaveImgBehavior::className(),
                    'fields' => [
                        [
                            'name'      => 'image',
                            'directory' => 'service',
                        ],
                    ],
                ],
                TimestampBehavior::className(),
                [
                    'class' => 'common\behaviors\ShowImage',
                ],
                'language' => [
                    'class' => LanguageBehavior::className(),
                ],
            ];
        }
        
        /**
         * @inheritdoc
         */
        public function attributeLabels()
        {
            return [
                'service_id' => Yii::t('app', 'service_id'),
                'image'      => Yii::t('app', 'image'),
                'created_at' => Yii::t('app', 'created_at'),
                'updated_at' => Yii::t('app', 'updated_at'),
            ];
        }
    }