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')); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
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:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.