Completed
Push — master ( bfbb50...8023d3 )
by Sherif
09:55
created

Setting   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newCollection() 0 4 1
A boot() 0 5 1
1
<?php
2
3
namespace App\Modules\Core;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use App\Modules\Core\ModelObservers\SettingsObserver;
8
9
class Setting extends Model
10
{
11
12
    use SoftDeletes;
13
    protected $table    = 'settings';
14
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
15
    protected $hidden   = ['deleted_at'];
16
    protected $guarded  = ['id', 'key'];
17
    protected $fillable = ['name', 'value'];
18
    
19
    public function newCollection(array $models = [])
20
    {
21
        return parent::newCollection($models)->keyBy('key');
22
    }
23
24
    public static function boot()
25
    {
26
        parent::boot();
27
        Setting::observe(SettingsObserver::class);
28
    }
29
}
30