personal_area_php/common/models/Addresses.php
2024-04-24 18:02:58 +03:00

74 lines
1.5 KiB
PHP

<?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']);
}
}