提交代码
This commit is contained in:
54
app/Models/CardOrderExpress.php
Normal file
54
app/Models/CardOrderExpress.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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]??'未知';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user