Conditions | 2 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
28 | 24 | protected static function boot() |
|
29 | { |
||
30 | 24 | parent::boot(); |
|
31 | 24 | static::addGlobalScope(new InvoiceScope()); |
|
32 | 24 | static::creating(function ($model) { |
|
33 | /** |
||
34 | * @var \Illuminate\Database\Eloquent\Model $model |
||
35 | */ |
||
36 | 23 | if (!$model->getKey()) { |
|
37 | 23 | $model->{$model->getKeyName()} = Str::uuid()->toString(); |
|
38 | } |
||
39 | |||
40 | 23 | $model->total = 0; |
|
41 | 23 | $model->tax = 0; |
|
42 | 23 | $model->discount = 0; |
|
43 | 23 | $model->is_bill = false; |
|
44 | 23 | $model->currency = config('soap.invoices.default_currency', 'THB'); |
|
45 | 23 | $model->status = config('soap.invoices.default_status', 'concept'); |
|
46 | 23 | $model->reference = InvoiceReferenceGenerator::generate(); |
|
47 | 24 | }); |
|
50 |