提交代码
This commit is contained in:
62
app/Models/UserAddress.php
Normal file
62
app/Models/UserAddress.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use RuLong\Order\Contracts\Addressbook;
|
||||
|
||||
class UserAddress extends Model implements Addressbook
|
||||
{
|
||||
/**
|
||||
* 收件人姓名
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 收件人电话
|
||||
* @return string
|
||||
*/
|
||||
public function getMobile()
|
||||
{
|
||||
return $this->mobile;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 收件人详细地址
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
if ($this->Area && $this->Area->info) {
|
||||
return str_replace(",", "-", $this->Area->info) . '-' . $this->address;
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
/**
|
||||
* 收件人详细地址
|
||||
* @return string
|
||||
*/
|
||||
public function getAllAddressAttribute()
|
||||
{
|
||||
return str_replace(",", "-", $this->Area->info) . '-' . $this->address;
|
||||
|
||||
}
|
||||
|
||||
public function Area()
|
||||
{
|
||||
return $this->belongsTo(Area::class, 'area_sn', 'sn');
|
||||
}
|
||||
|
||||
public function Province()
|
||||
{
|
||||
return $this->belongsTo(Area::class, 'province_sn', 'sn');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user