52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Beike\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Logistics extends Base{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'warehouse_name',
|
|
'country_id',
|
|
'country_ids',
|
|
'type',
|
|
'first_weight',
|
|
'first_weight_fee',
|
|
'continuation_weight_max',
|
|
'add_weight',
|
|
'continuation_weight_fee',
|
|
'throwing_ratio',
|
|
'num_fee',
|
|
'day_min',
|
|
'day_max',
|
|
'position'
|
|
];
|
|
/**
|
|
* Common: 根据国家ID 获取所有关联的物流列表
|
|
* Author: wu-hui
|
|
* Time: 2023/08/22 10:31
|
|
* @param int $countryId
|
|
* @param string[] $field
|
|
* @return array
|
|
*/
|
|
public static function getAll(int $countryId,$field = ['id','name','warehouse_name','type','day_min','day_max']){
|
|
$list = self::select($field)
|
|
->whereRaw(\DB::raw('FIND_IN_SET('.$countryId.',country_ids)'))
|
|
->orderBy('position','ASC')
|
|
->orderBy('id','ASC')
|
|
->get();
|
|
|
|
|
|
return $list ? $list->toArray() : [];
|
|
}
|
|
|
|
public function country(){
|
|
return $this->belongsTo(Country::class,'country_id','id');
|
|
}
|
|
}
|