<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "tagsfilter".
 *
 * @property int $id id tag
 * @property int $sort
 */
class Tagsfilter extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'tagsfilter';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['id'], 'required'],
            [['id', 'sort'], 'integer'],
            [['id'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'id tag',
            'sort' => 'Sort',
        ];
    }
   /**
     * {@inheritdoc}
     * @return status.
     */

	public function del($id)
    {
		if( Yii::$app->user->can('admin') ){
			$this->delete();
		}
	}

	public static function find()
	{
		return parent::find()
			->orderBy(["sort"=>SORT_ASC]);
	}

}
