Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
8 / 8
CRAP
100.00% covered (success)
100.00%
8 / 8
WaybillPriceModel
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
8 / 8
12
100.00% covered (success)
100.00%
8 / 8
 carrier
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 province
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 city
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 unit
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getCarrierNameAttribute
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getProvinceNameAttribute
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getCityNameAttribute
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 getUnitNameAttribute
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class WaybillPriceModel extends Model
{
    protected $fillable=[
        'carrier_id','province_id','city_id','unit_id','range_min','range_max','unit_price','initial_weight'
    ];
    protected $appends=[
        'carrier_name',
        'province_name',
        'city_name',
        'unit_name',
    ];
    public function carrier(){
        return $this->belongsTo('App\Carrier','carrier_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;
    }
}