You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.7 KiB
80 lines
1.7 KiB
5 years ago
|
<?php
|
||
|
|
||
|
namespace common\models;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "order_address".
|
||
|
*
|
||
|
* @property integer $id
|
||
|
* @property integer $order_id
|
||
|
* @property integer $province
|
||
|
* @property integer $city
|
||
|
* @property integer $district
|
||
|
* @property integer $town
|
||
|
* @property string $address
|
||
|
* @property string $created_at
|
||
|
* @property string $updated_at
|
||
|
*/
|
||
|
class OrderAddress extends \yii\db\ActiveRecord
|
||
|
{
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return 'order_address';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['order_id', 'province', 'city', 'district', 'town'], 'integer'],
|
||
|
[['address'], 'string', 'max' => 120],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'order_id' => 'Order ID',
|
||
|
'province' => 'Province',
|
||
|
'city' => 'City',
|
||
|
'district' => 'District',
|
||
|
'town' => 'Town',
|
||
|
'address' => 'Address',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function getRegionP()
|
||
|
{
|
||
|
return $this->hasOne(Region::className(), ['id' => 'province']);
|
||
|
}
|
||
|
public function getRegionC()
|
||
|
{
|
||
|
return $this->hasOne(Region::className(), ['id' => 'city']);
|
||
|
}
|
||
|
public function getRegionD()
|
||
|
{
|
||
|
return $this->hasOne(Region::className(), ['id' => 'district']);
|
||
|
}
|
||
|
public function getRegionT()
|
||
|
{
|
||
|
// dd($this->town);
|
||
|
if($this->town){
|
||
|
return $this->hasOne(Region::className(), ['id' => 'town']);
|
||
|
}else{
|
||
|
$string='';
|
||
|
return $string;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|