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

Notification::getDescriptionAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace App\Modules\V1\Notifications;
2
3
use Illuminate\Database\Eloquent\Model;
4
use Illuminate\Database\Eloquent\SoftDeletes;
5
6
class Notification extends Model{
7
8
    use SoftDeletes;
9
    protected $table    = 'notifications';
10
    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
11
    protected $hidden   = ['deleted_at', 'item_type', 'data'];
12
    protected $guarded  = ['id'];
13
    protected $fillable = ['key', 'data', 'item_name', 'item_type', 'item_id', 'notified'];
14
    protected $appends  = ['description'];
15
    public $searchable  = ['key', 'item_name', 'item_type'];
16
17
    public function getCreatedAtAttribute($value)
18
    {
19
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
20
    }
21
22
    public function getUpdatedAtAttribute($value)
23
    {
24
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
25
    }
26
27
    public function getDeletedAtAttribute($value)
28
    {
29
        return \Carbon\Carbon::parse($value)->addHours(\Session::get('timeZoneDiff'))->toDateTimeString();
30
    }
31
    
32
    public function item()
33
    {
34
        return $this->morphTo();
35
    }
36
37
    public function setDataAttribute($value)
38
    {
39
        $this->attributes['data'] = serialize($value);
40
    }
41
42
    public function getDescriptionAttribute()
43
    {
44
        return trans('notifications.' . $this->attributes['key'], unserialize($this->attributes['data']));
45
    }
46
47
    public static function boot()
48
    {
49
        parent::boot();
50
        parent::observe(\App::make('App\Modules\V1\Notifications\ModelObservers\NotificationObserver'));
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...
51
    }
52
}
53