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