la_back/common/models/OrderProduct.php
2023-11-21 19:51:44 +03:00

71 lines
1.5 KiB
PHP
Executable File

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "order_product".
*
* @property int $id
* @property int|null $order_id
* @property int|null $product_id
*
* @property Order $order
* @property Product $product
*/
class OrderProduct extends \yii\db\ActiveRecord
{
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'order_product';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['order_id', 'product_id'], 'integer'],
[['order_id'], 'exist', 'skipOnError' => true, 'targetClass' => Order::class, 'targetAttribute' => ['order_id' => 'id']],
[['product_id'], 'exist', 'skipOnError' => true, 'targetClass' => Product::class, 'targetAttribute' => ['product_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'order_id' => 'Order ID',
'product_id' => 'Product ID',
];
}
/**
* Gets query for [[Order]].
*
* @return \yii\db\ActiveQuery
*/
public function getOrder()
{
return $this->hasOne(Order::class, ['id' => 'order_id']);
}
/**
* Gets query for [[Product]].
*
* @return \yii\db\ActiveQuery
*/
public function getProduct()
{
return $this->hasOne(Product::class, ['id' => 'product_id']);
}
}