55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Config;
|
|
|
|
class CardOrderExpress extends Model
|
|
{
|
|
protected $dates = [
|
|
'deliver_at',
|
|
'receive_at',
|
|
];
|
|
|
|
/**
|
|
* 所属订单
|
|
* @Author:<C.Jason>
|
|
* @Date:2018-10-19T13:49:06+0800
|
|
* @return Order
|
|
*/
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(CardOrder::class);
|
|
}
|
|
|
|
/**
|
|
* 设置收货地址详细内容
|
|
* @Author:<C.Jason>
|
|
* @Date:2018-10-22T10:10:02+0800
|
|
*/
|
|
public function setInstanceAttribute($address)
|
|
{
|
|
$this->attributes['name'] = $address['name'];
|
|
$this->attributes['mobile'] = $address['mobile'];
|
|
$this->attributes['address'] = $address['address'];
|
|
}
|
|
|
|
public function getCompanyTextAttribute()
|
|
{
|
|
$deliver_list = Config::get('deliver_list');
|
|
$array = preg_split('/[\r\n]+/', trim($deliver_list, "\r\n"));
|
|
|
|
if (strpos($deliver_list, ':')) {
|
|
$options = [];
|
|
foreach ($array as $val) {
|
|
[$k, $v] = explode(':', $val, 2);
|
|
$options[$k] = $v;
|
|
}
|
|
} else {
|
|
$options = $array;
|
|
}
|
|
|
|
return $options[$this->company]??'未知';
|
|
}
|
|
}
|