You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.0 KiB

9 years ago
<?php
namespace tests\models;
use lhs\Yii2SaveRelationsBehavior\SaveRelationsBehavior;
9 years ago
class Link extends \yii\db\ActiveRecord
{
const SCENARIO_FIRST = 'first';
const SCENARIO_SECOND = 'second';
9 years ago
/**
* @inheritdoc
*/
public static function tableName()
{
return 'link';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'saveRelations' => [
'class' => SaveRelationsBehavior::className(),
'relations' => ['linkType']
],
];
}
/**
* @inheritdoc
*/
9 years ago
public function rules()
{
return [
[['language', 'name', 'link'], 'required'],
[['name'], 'unique', 'targetAttribute' => ['language', 'name']],
[['link_type_id'], 'safe']
9 years ago
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLinkType()
{
return $this->hasOne(LinkType::className(), ['id' => 'link_type_id']);
}
9 years ago
}