<?php

namespace common\models;

use Yii;
use yii\behaviors\SluggableBehavior;
/**
 * This is the model class for table "pb_artikel".
 *
 * @property int $iArtikelid
 * @property string $vJudul
 * @property string $eKategori
 * @property string $vPendahulu
 * @property string $vLengkap
 * @property string $vPengarang
 * @property string $vKeterangan
 * @property string $vKeyword
 * @property string $eLetakimg
 * @property string $vImages
 * @property string $vEditor
 * @property string $vMetatitle
 * @property string $vMetakeyword
 * @property string $vMetadesc
 * @property string $ePublish
 * @property string $eDeleted
 * @property int $iCreated
 * @property string $tCreated
 * @property string $eStatus
 */
class Artikel extends \yii\db\ActiveRecord
{
	const PERMISSIONS_PRIVATE = 10;
      const PERMISSIONS_PUBLIC = 20;  
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pb_artikel';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['eKategori', 'vPendahulu', 'vLengkap', 'vKeterangan', 'vKeyword', 'eLetakimg', 'vMetakeyword', 'vMetadesc', 'ePublish', 'eDeleted', 'eStatus'], 'string'],
            [['vJudul','eBrand','ePublish'], 'required'],
            [['iCreated'], 'integer'],
            [['tCreated'], 'safe'],
            [['vJudul', 'vPengarang'], 'string', 'max' => 200],
            [['vImages', 'vEditor', 'vMetatitle'], 'string', 'max' => 255],
            [['vJudul'], 'unique', 'message' => 'Judul sudah ada, tidak boleh sama !'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'iArtikelid' => 'ID',
            'vJudul' => ' Judul',
            'eKategori' => 'Kategori',
            'vPendahulu' => 'Pendahulu',
            'vLengkap' => 'Artikel Lengkap',
            'vPengarang' => 'Pengarang',
            'vKeterangan' => 'Keterangan',
            'vKeyword' => 'Keyword',
            'eLetakimg' => 'Letakimg',
            'vImages' => 'Images',
            'vEditor' => 'Editor',
            'vMetatitle' => 'Metatitle',
            'vMetakeyword' => 'Metakeyword',
            'vMetadesc' => 'Metadesc',
            'ePublish' => 'Publish',
            'eDeleted' => 'Deleted',
            'iCreated' => 'Created',
            'tCreated' => 'Created',
            'eStatus' => 'E Status',
            'eBrand' => 'Brand',
        ];
    }
	
	public function behaviors()
    {
        return [
            [
                'class' => SluggableBehavior::className(),
                'attribute' => 'vJudul',
                // 'slugAttribute' => 'slug',
                'immutable' => true,
        		'ensureUnique'=>true,
            ],
        ];
    }
}
