Completed
Push — master ( cd8f65...e1eb39 )
by Sherif
27:44
created

Settings::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php namespace App\Modules\V1\Core;
2
3
use Illuminate\Database\Eloquent\Model;
4
use Illuminate\Database\Eloquent\SoftDeletes;
5
6
class Settings extends Model{
7
8
    use SoftDeletes;
9
    protected $table    = 'settings';
10
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
    protected $hidden   = ['deleted_at'];
12
    protected $guarded  = ['id', 'key'];
13
    protected $fillable = ['name','value'];
14
    public $searchable  = ['name', 'value', 'key'];
15
    
16
    public function getCreatedAtAttribute($value)
17
    {
18
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
19
    }
20
21
    public function getUpdatedAtAttribute($value)
22
    {
23
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
24
    }
25
26
    public function getDeletedAtAttribute($value)
27
    {
28
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
29
    }
30
    
31
    public function newCollection(array $models = [])
32
    {
33
        return parent::newCollection($models)->keyBy('key');
34
    }
35
36
    public static function boot()
37
    {
38
        parent::boot();
39
        parent::observe(\App::make('App\Modules\V1\Core\ModelObservers\SettingsObserver'));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (observe() instead of boot()). Are you sure this is correct? If so, you might want to change this to $this->observe().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
    }
41
}
42