| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- class Waybill extends Model
- {
- protected $fillable=[
- 'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
- 'carrier_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
- 'car_owner_info','fee','pick_up_fee','other_fee','collect_fee','dispatch_remark','waybill_price_model_id','warehouse_weight_other','warehouse_weight_unit_id_other'
- ,'carrier_weight_other','carrier_weight_unit_id_other',
- ];
- protected $appends=[
- 'origination_city_name',
- 'carrier_name',
- 'owner_name',
- 'destination_city_name',
- 'warehouse_weight_unit_name',
- 'carrier_weight_unit_name',
- 'warehouse_weight_unit_other_name',
- 'carrier_weight_unit_other_name',
- ];
- public function owner(){
- return $this->belongsTo('App\Owner','owner_id','id');
- }
- public function carrier(){
- return $this->belongsTo('App\Carrier','carrier_id','id');
- }
- public function origination_city(){
- return $this->belongsTo('App\City','origination_city_id','id');
- }
- public function destination_city(){
- return $this->belongsTo('App\City','destination_city_id','id');
- }
- public function warehouse_weight_unit(){
- return $this->belongsTo('App\Unit','warehouse_weight_unit_id','id');
- }
- public function carrier_weight_unit(){
- return $this->belongsTo('App\Unit','carrier_weight_unit_id','id');
- }
- public function warehouse_weight_unit_other(){
- return $this->belongsTo('App\Unit','warehouse_weight_unit_id_other','id');
- }
- public function carrier_weight_unit_other(){
- return $this->belongsTo('App\Unit','carrier_weight_unit_id_other','id');
- }
- public function carType(){
- return $this->belongsTo('App\CarType','carType_id','id');
- }
- public function waybillAuditLogs(){
- return $this->hasMany('App\WaybillAuditLog','waybill_id','id');
- }
- public function getOwnerNameAttribute(){
- return $this['owner']? $this['owner']['name']:null;
- }
- public function getCarrierNameAttribute(){
- return $this['carrier']? $this['carrier']['name']:null;
- }
- public function getOriginationCityNameAttribute(){
- return $this['origination_city']? $this['origination_city']['name']:null;
- }
- public function getDestinationCityNameAttribute(){
- return $this['destination_city']? $this['destination_city']['name']:null;
- }
- public function getWarehouseWeightUnitNameAttribute(){
- return $this['warehouse_weight_unit']? $this['warehouse_weight_unit']['name']:null;
- }
- public function getCarrierWeightUnitNameAttribute(){
- return $this['carrier_weight_unit']? $this['carrier_weight_unit']['name']:null;
- }
- public function getWarehouseWeightUnitOtherNameAttribute(){
- return $this['warehouse_weight_unit_other']? $this['warehouse_weight_unit_other']['name']:null;
- }
- public function getCarrierWeightUnitOtherNameAttribute(){
- return $this['carrier_weight_unit_other']? $this['carrier_weight_unit_other']['name']:null;
- }
- }
|