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

Carousel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 9
c 2
b 0
f 1
dl 0
loc 15
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 4
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