first commit
This commit is contained in:
70
common/models/OrderProduct.php
Executable file
70
common/models/OrderProduct.php
Executable file
@ -0,0 +1,70 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user