| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- use App\Traits\LogModelChanging;
- class WaybillPriceModel extends Model
- {
- use LogModelChanging;
- use ModelTimeFormat;
- protected $fillable=[
- 'logistic_id','province_id','city_id','unit_id','range_min','range_max','unit_price','base_fee','initial_weight'
- ];
- protected $appends=[
- 'carrier_name',
- 'province_name',
- 'city_name',
- 'unit_name',
- ];
- public function logistic(){
- return $this->belongsTo('App\Logistic','logistic_id','id');
- }
- public function province(){
- return $this->belongsTo('App\Province','province_id','id');
- }
- public function city(){
- return $this->belongsTo('App\City','city_id','id');
- }
- public function unit(){
- return $this->belongsTo('App\Unit','unit_id','id');
- }
- public function getCarrierNameAttribute(){
- return $this['carrier']? $this['carrier']['name']:null;
- }
- public function getProvinceNameAttribute(){
- return $this['province']? $this['province']['name']:null;
- }
- public function getCityNameAttribute(){
- return $this['city']? $this['city']['name']:null;
- }
- public function getUnitNameAttribute(){
- return $this['unit']? $this['unit']['name']:null;
- }
- }
|