| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\DB;
- use App\Traits\ModelLogChanging;
- class OwnerPriceDirectLogistic extends Model
- {
- use ModelLogChanging;
- protected $fillable = [
- "name", //名称
- "base_km" //起步公里数
- ];
- public function details()
- { //直发车计费对应车型费
- return $this->hasMany(OwnerPriceDirectLogisticCar::class,"owner_price_direct_logistic_id","id");
- }
- public function owners()
- { //货主中间表
- return $this->belongsToMany(Owner::class,"owner_price_direct_logistic_owner","owner_price_direct_logistic_id","owner_id");
- }
- public function getOwnerIdAttribute()
- { //获取货主ID数组
- return array_column(DB::select(DB::raw("SELECT * FROM owner_price_direct_logistic_owner WHERE owner_price_direct_logistic_id = ?"),[$this->id]),"owner_id");
- }
- }
|