|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
|
6
|
|
|
use Illuminate\Database\Eloquent\Builder; |
|
7
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
|
8
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
|
9
|
|
|
use Illuminate\Database\Query\Builder as QueryBuilder; |
|
10
|
|
|
use IonGhitun\MysqlEncryption\Models\BaseModel; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class UserNotification |
|
14
|
|
|
* |
|
15
|
|
|
* @property int $id |
|
16
|
|
|
* @property int $user_id |
|
17
|
|
|
* @property string $message |
|
18
|
|
|
* @property string|null $ref_name |
|
19
|
|
|
* @property int|null $ref_id |
|
20
|
|
|
* @property int $status |
|
21
|
|
|
* @property Carbon|null $created_at |
|
22
|
|
|
* @property Carbon|null $updated_at |
|
23
|
|
|
* @property Carbon|null $deleted_at |
|
24
|
|
|
* |
|
25
|
|
|
* @property User $user |
|
26
|
|
|
* |
|
27
|
|
|
* @method static Builder|UserNotification newModelQuery() |
|
28
|
|
|
* @method static Builder|UserNotification newQuery() |
|
29
|
|
|
* @method static Builder|UserNotification query() |
|
30
|
|
|
* @method static Builder|UserNotification whereCreatedAt($value) |
|
31
|
|
|
* @method static Builder|UserNotification whereDeletedAt($value) |
|
32
|
|
|
* @method static Builder|UserNotification whereId($value) |
|
33
|
|
|
* @method static Builder|UserNotification whereMessage($value) |
|
34
|
|
|
* @method static Builder|UserNotification whereRefId($value) |
|
35
|
|
|
* @method static Builder|UserNotification whereRefName($value) |
|
36
|
|
|
* @method static Builder|UserNotification whereStatus($value) |
|
37
|
|
|
* @method static Builder|UserNotification whereUpdatedAt($value) |
|
38
|
|
|
* @method static Builder|UserNotification whereUserId($value) |
|
39
|
|
|
* @method static QueryBuilder|UserNotification onlyTrashed() |
|
40
|
|
|
* @method static QueryBuilder|UserNotification withTrashed() |
|
41
|
|
|
* @method static QueryBuilder|UserNotification withoutTrashed() |
|
42
|
|
|
* @method static Builder|BaseModel orWhereEncrypted($column, $value) |
|
43
|
|
|
* @method static Builder|BaseModel orWhereNotEncrypted($column, $value) |
|
44
|
|
|
* @method static Builder|BaseModel orderByEncrypted($column, $direction) |
|
45
|
|
|
* @method static Builder|BaseModel whereEncrypted($column, $value) |
|
46
|
|
|
* @method static Builder|BaseModel whereNotEncrypted($column, $value) |
|
47
|
|
|
* |
|
48
|
|
|
* @package App\Models |
|
49
|
|
|
*/ |
|
50
|
|
|
class UserNotification extends Model |
|
51
|
|
|
{ |
|
52
|
|
|
use SoftDeletes; |
|
53
|
|
|
|
|
54
|
|
|
/** @var int */ |
|
55
|
|
|
const STATUS_UNREAD = 0; |
|
56
|
|
|
|
|
57
|
|
|
/** @var int */ |
|
58
|
|
|
const STATUS_READ = 1; |
|
59
|
|
|
|
|
60
|
|
|
/** @var bool */ |
|
61
|
|
|
public $timestamps = true; |
|
62
|
|
|
|
|
63
|
|
|
/** @var string */ |
|
64
|
|
|
protected $table = 'user_notifications'; |
|
65
|
|
|
|
|
66
|
|
|
/** @var array */ |
|
67
|
|
|
protected $fillable = [ |
|
68
|
|
|
'user_id', |
|
69
|
|
|
'message', |
|
70
|
|
|
'ref_name', |
|
71
|
|
|
'ref_id', |
|
72
|
|
|
'status' |
|
73
|
|
|
]; |
|
74
|
|
|
|
|
75
|
|
|
/** @var array */ |
|
76
|
|
|
protected $visible = [ |
|
77
|
|
|
'id', |
|
78
|
|
|
'user_id', |
|
79
|
|
|
'message', |
|
80
|
|
|
'ref_name', |
|
81
|
|
|
'ref_id', |
|
82
|
|
|
'status', |
|
83
|
|
|
'created_at', |
|
84
|
|
|
'updated_at', |
|
85
|
|
|
'user' |
|
86
|
|
|
]; |
|
87
|
|
|
|
|
88
|
|
|
/** @var array */ |
|
89
|
|
|
protected $casts = [ |
|
90
|
|
|
'status' => 'int' |
|
91
|
|
|
]; |
|
92
|
|
|
|
|
93
|
|
|
/** @var array */ |
|
94
|
|
|
protected $sortable = [ |
|
95
|
|
|
'id', |
|
96
|
|
|
'message', |
|
97
|
|
|
'status', |
|
98
|
|
|
'created_at', |
|
99
|
|
|
'updated_at', |
|
100
|
|
|
]; |
|
101
|
|
|
|
|
102
|
|
|
/** @var array */ |
|
103
|
|
|
protected $searchable = [ |
|
104
|
|
|
'message' |
|
105
|
|
|
]; |
|
106
|
|
|
|
|
107
|
|
|
/** @var array */ |
|
108
|
|
|
protected $filterable = [ |
|
109
|
|
|
'user_id', |
|
110
|
|
|
'ref_id', |
|
111
|
|
|
'status' |
|
112
|
|
|
]; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* User. |
|
116
|
|
|
* |
|
117
|
|
|
* @return BelongsTo |
|
118
|
|
|
*/ |
|
119
|
|
|
public function user() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->belongsTo(User::class, 'user_id', 'id'); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|