mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 22:50:44 +00:00
40 lines
811 B
PHP
40 lines
811 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ShopShip extends Model
|
|
{
|
|
protected $guarded = [];
|
|
|
|
protected function shop()
|
|
{
|
|
return $this->belongsTo(Shop::class, 'shop_id', 'id');
|
|
}
|
|
|
|
public function getStatusAttribute($value)
|
|
{
|
|
$map = [
|
|
0 => '未授权',
|
|
1 => '已授权',
|
|
3 => '停用',
|
|
];
|
|
if (1 === (int)$value && ($this->attributes['expires_at'] - time()) / 3600 <= 72) {
|
|
return '重新授权';
|
|
}
|
|
|
|
return $map[$value];
|
|
}
|
|
|
|
public function getExpiresAtAttribute($value)
|
|
{
|
|
return $value ? date('Y-m-d H:i:s', $value) : '';
|
|
}
|
|
|
|
public function senders()
|
|
{
|
|
return $this->hasMany(ShopSender::class, 'shop_ship_id');
|
|
}
|
|
}
|