create project
This commit is contained in:
73
common/models/Addresses.php
Normal file
73
common/models/Addresses.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "addresses".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $address
|
||||
* @property int $company_id
|
||||
* @property string|null $name
|
||||
*
|
||||
* @property Check[] $checks
|
||||
* @property Company $company
|
||||
*/
|
||||
class Addresses extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'addresses';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['address', 'company_id'], 'required'],
|
||||
[['company_id'], 'integer'],
|
||||
[['address', 'name'], 'string', 'max' => 255],
|
||||
[['company_id'], 'exist', 'skipOnError' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'address' => 'Адрес',
|
||||
'company_id' => 'Компания',
|
||||
'name' => 'Название',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets query for [[Checks]].
|
||||
*
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChecks()
|
||||
{
|
||||
return $this->hasMany(Check::class, ['addresses_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets query for [[Company]].
|
||||
*
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
return $this->hasOne(Company::class, ['id' => 'company_id']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user