Browse Source

Add missing ProjectNoTransactions model test class

tags/1.1.0
Alban Jubert 9 years ago
parent
commit
797849e6a3
  1. 2
      README.md
  2. 81
      tests/models/ProjectNoTransactions.php

2
README.md

@ -40,6 +40,8 @@ use lhs\Yii2SaveRelationsBehavior\SaveRelationsBehavior;
class Project extends \yii\db\ActiveRecord class Project extends \yii\db\ActiveRecord
{ {
use SaveRelationsTrait; // Optionnal
public function behaviors() public function behaviors()
{ {
return [ return [

81
tests/models/ProjectNoTransactions.php

@ -0,0 +1,81 @@
<?php
namespace tests\models;
use lhs\Yii2SaveRelationsBehavior\SaveRelationsBehavior;
class ProjectNoTransactions extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'project';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'saveRelations' => [
'class' => SaveRelationsBehavior::className(),
'relations' => ['company', 'users', 'links']
],
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'company_id'], 'required'],
[['name'], 'unique', 'targetAttribute' => ['company_id', 'name']],
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getCompany()
{
return $this->hasOne(Company::className(), ['id' => 'company_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProjectUsers()
{
return $this->hasMany(ProjectUser::className(), ['project_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUsers()
{
return $this->hasMany(User::className(), ['id' => 'user_id'])->via('projectUsers');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getProjectLinks()
{
return $this->hasMany(ProjectLink::className(), ['project_id' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getLinks()
{
return $this->hasMany(Link::className(), ['language' => 'language', 'name' => 'name'])->via('projectLinks');
}
}
Loading…
Cancel
Save