Your IP : 216.73.216.79


Current Path : /var/www/html/dosm/backend/models/frontendheader/
Upload File :
Current File : /var/www/html/dosm/backend/models/frontendheader/FrontendHeader.php

<?php

namespace backend\models\frontendheader;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\behaviors\BlameableBehavior;
use yii\db\Expression;
use yii\db\ActiveRecord;
use asinfotrack\yii2\audittrail\behaviors\AuditTrailBehavior;

/**
 * This is the model class for table "frontend_header".
 *
 * @property integer $header_id
 * @property string $header_content
 * @property string $header_description
 */
class FrontendHeader extends \yii\db\ActiveRecord {

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return 'frontend_header';
    }

    public function behaviors() {
        return [
            'audittrail' => [
                'class' => AuditTrailBehavior::className(),
                // some of the optional configurations
                'ignoredAttributes' => ['created_at', 'updated_at'],
                'consoleUserId' => 1,
                'attributeOutput' => [
                    'desktop_id' => function ($value) {
                        $model = Desktop::findOne($value);
                        return sprintf('%s %s', $model->manufacturer, $model->device_name);
                    },
                    'last_checked' => 'datetime',
                ],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['header_content'], 'required'],
            [['header_is_php'], 'integer'],
            [['header_content', 'header_description'], 'string'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'header_id' => 'Header ID',
            'header_content' => 'Header Content',
            'header_description' => 'Header Description',
        ];
    }

    public static function dropdown() {
        static $dropdown;
        if ($dropdown == null) {
            $models = static::find()->all();
            foreach ($models as $model) {
                $dropdown[$model->header_id] = $model->header_description;
            }
        }

        return $dropdown;
    }

}