72 lines
1.4 KiB
PHP
72 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace app\models;
|
|
|
|
use Yii;
|
|
use yii\behaviors\TimestampBehavior;
|
|
|
|
/**
|
|
* This is the model class for table "{{%package}}".
|
|
*
|
|
* @property integer $id
|
|
* @property string $name
|
|
* @property string $url
|
|
* @property integer $hits
|
|
* @property string $created_at
|
|
* @property string $updated_at
|
|
*/
|
|
class Package extends \yii\db\ActiveRecord
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return '{{%package}}';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['name', 'url'], 'required'],
|
|
[['name'], 'string', 'max' => 64],
|
|
[['url'], 'string', 'max' => 255],
|
|
[['name'], 'unique'],
|
|
[['url'], 'unique']
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'name' => 'Name',
|
|
'url' => 'URL',
|
|
'hits' => 'Hits',
|
|
'created_at' => 'Created At',
|
|
'updated_at' => 'Updated At',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::className(),
|
|
'value' => function () {
|
|
return date('Y-m-d H:i:s');
|
|
},
|
|
],
|
|
];
|
|
}
|
|
}
|