Passed
Push — develop ( e34a97...d968c2 )
by Septianata
14:57
created

Event::bootEvent()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
cc 2
nc 1
nop 0
crap 6
1
<?php
2
3
namespace App\Models\Concerns\Customer;
4
5
use App\Models\Customer;
6
use App\Support\Model\Event as ModelEvent;
7
use Illuminate\Support\Facades\Storage;
8
9
/**
10
 * @see \App\Models\Customer
11
 */
12
trait Event
13
{
14
    use ModelEvent;
15
16
    /**
17
     * Boot the trait on the model.
18
     *
19
     * @return void
20
     */
21
    protected static function bootEvent()
22
    {
23
        static::saving(function (Customer $model) {
24
            if (is_null($model->identitycard_image)) {
0 ignored issues
show
introduced by
The condition is_null($model->identitycard_image) is always false.
Loading history...
25
                Storage::delete(Customer::IDENTITYCARD_IMAGE_PATH . '/' . $model->getRawOriginal('identitycard_image'));
26
            }
27
        });
28
    }
29
}
30