初始化项目
This commit is contained in:
85
app/Models/ExpressNo.php
Normal file
85
app/Models/ExpressNo.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* App\Models\ExpressNo
|
||||
*
|
||||
* @property int $id
|
||||
* @property string|null $express_company_name 公司名称
|
||||
* @property string $express_company_code 公司编码
|
||||
* @property string $express_no 快递单号
|
||||
* @property string|null $mobile 手机号码
|
||||
* @property int|null $state 物流状态
|
||||
* @property string|null $sync_at 同步时间
|
||||
* @property \Illuminate\Support\Carbon|null $created_at
|
||||
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||
* @property-read \App\Models\ExpressCompany|null $company 快递公司
|
||||
* @property-read \App\Models\ExpressDetail|null $detail 物流详情[单]
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ExpressDetail[] $details 物流详情[多]
|
||||
* @property-read int|null $details_count
|
||||
* @property-read string $created_at_format 创建时间的格式化
|
||||
* @property-read string $state_string 物流状态
|
||||
* @property-read string $status_string 状态名称
|
||||
* @property-read string $updated_at_format 更新时间的格式化
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ExpressNo newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ExpressNo newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ExpressNo query()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ExpressNo extends BaseModel
|
||||
{
|
||||
const STATE_SIGN = 3;
|
||||
const STATE = [
|
||||
1 => '揽收',
|
||||
0 => '在途',
|
||||
5 => '派件',
|
||||
self::STATE_SIGN => '签收',
|
||||
6 => '退回',
|
||||
4 => '退签',
|
||||
7 => '转投',
|
||||
2 => '疑难',
|
||||
8 => '清关',
|
||||
14 => '拒签',
|
||||
];
|
||||
|
||||
/**
|
||||
* @comment 物流详情[单]
|
||||
* @return HasOne
|
||||
*/
|
||||
public function detail(): HasOne
|
||||
{
|
||||
return $this->hasOne(ExpressDetail::class, 'express_no_id')->orderByDesc('detail_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 物流详情[多]
|
||||
* @return HasMany
|
||||
*/
|
||||
public function details(): HasMany
|
||||
{
|
||||
return $this->hasMany(ExpressDetail::class, 'express_no_id')->orderByDesc('detail_at');
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 快递公司
|
||||
* @return BelongsTo
|
||||
*/
|
||||
public function company(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ExpressCompany::class, 'express_company_code', 'code');
|
||||
}
|
||||
|
||||
/**
|
||||
* @comment 物流状态
|
||||
* @return string
|
||||
*/
|
||||
public function getStateStringAttribute(): string
|
||||
{
|
||||
return self::STATE[$this->state] ?? '';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user