Passed
Pull Request — master (#648)
by John
06:12
created

Carousel::boot()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace App\Models\Eloquent;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Carousel extends Model
8
{
9
    protected $table='carousel';
10
    protected $primaryKey='caid';
11
12
    protected $fillable=[
13
        'image', 'url', 'title', 'available'
14
    ];
15
16
    public static function boot()
17
    {
18
        parent::boot();
19
        static::saving(function($model) {
20
            if ($model->image!="" && $model->image!=null && $model->image[0]!="/") {
21
                $model->image="/$model->image";
22
            }
23
        });
24
    }
25
}
26