PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.3.2
Fluent Support – Helpdesk & Customer Support Ticket System v2.3.2
2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 All 67 releases
fluent-support / app / Models / NotificationUser.php

NotificationUser.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.3.2, at app/Models/NotificationUser.php

56 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Models;
4
5 class NotificationUser extends Model
6 {
7 protected $table = 'fs_notification_users';
8
9 protected $fillable = [
10 'notification_id',
11 'user_id',
12 'channel',
13 'is_read',
14 'read_at'
15 ];
16
17 public static function boot()
18 {
19 parent::boot();
20
21 static::creating(function ($model) {
22 if (!$model->channel) {
23 $model->channel = 'web';
24 }
25
26 if ($model->is_read === null) {
27 $model->is_read = 0;
28 }
29
30 $model->created_at = current_time('mysql');
31 $model->updated_at = current_time('mysql');
32 });
33
34 static::updating(function ($model) {
35 $model->updated_at = current_time('mysql');
36 });
37 }
38
39 public function notification()
40 {
41 $class = __NAMESPACE__ . '\Notification';
42
43 return $this->belongsTo($class, 'notification_id', 'id');
44 }
45
46 public function scopeUnread($query)
47 {
48 return $query->where('is_read', 0);
49 }
50
51 public function scopeRead($query)
52 {
53 return $query->where('is_read', 1);
54 }
55 }
56