| Total Complexity | 6 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 62.5% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class InvoiceLine extends Model |
||
| 9 | { |
||
| 10 | protected $guarded = []; |
||
| 11 | |||
| 12 | public $incrementing = false; |
||
| 13 | |||
| 14 | protected $fillable = [ |
||
| 15 | 'amount', 'tax', 'tax_details', 'invoice_id', 'description', 'invoiceable_id', |
||
| 16 | 'invoiceable_type', 'name', 'discount', 'quantity', 'is_free', 'is_complimentary' |
||
| 17 | ]; |
||
| 18 | |||
| 19 | protected $casts = [ |
||
| 20 | 'tax_details' => 'array' |
||
| 21 | ]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * InvoiceLine constructor. |
||
| 25 | * @param array $attributes |
||
| 26 | */ |
||
| 27 | 36 | public function __construct(array $attributes = []) |
|
| 32 | 36 | } |
|
| 33 | |||
| 34 | 36 | protected static function boot() |
|
| 35 | { |
||
| 36 | 36 | parent::boot(); |
|
| 37 | static::creating(function ($model) { |
||
| 38 | /** |
||
| 39 | * @var \Illuminate\Database\Eloquent\Model $model |
||
| 40 | */ |
||
| 41 | 36 | if (!$model->getKey()) { |
|
| 42 | 36 | $model->{$model->getKeyName()} = Str::uuid()->toString(); |
|
| 43 | } |
||
| 44 | 36 | }); |
|
| 45 | 36 | } |
|
| 46 | |||
| 47 | public function invoice() |
||
| 48 | { |
||
| 49 | return $this->belongsTo(Invoice::class); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function bill() |
||
| 53 | { |
||
| 54 | return $this->belongsTo(Bill::class, 'invoice_id'); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Get the owning invoiceable model. |
||
| 59 | */ |
||
| 60 | public function invoiceable() |
||
| 63 | } |
||
| 64 | } |
||
| 65 |