Notification.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace App\Models;
use App\Support\Model;
use Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo;
use Awobaz\Compoships\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
class Notification extends Model
{
use SoftDeletes;
protected $table = 'notifications';
protected $guarded = [];
protected $hidden = ['deleted_at'];
protected $casts = [
'publish_to' => 'array',
'publish_type' => 'int'
];
public array $columnMap = [
'title' => '通知标题',
'content' => '通知整文',
'type' => '类型',
'cover' => '图片',
'link_type' => "交互类型",
'link_id' => "交互对象",
'publish_to' => '发布对象',
'publish_type' => "发布方式",
'publish_at' => '发布时间',
'rich_content' => '富文本内容'
];
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class)->withTrashed();
}
/**
* @return \Awobaz\Compoships\Database\Eloquent\Relations\HasMany
*/
public function items(): HasMany
{
return $this->hasMany(NotificationUser::class);
}
}