-
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathReply.php
More file actions
50 lines (41 loc) · 1.12 KB
/
Reply.php
File metadata and controls
50 lines (41 loc) · 1.12 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
<?php
namespace App\Models\SupportTicket;
use App\Models\SupportTicket;
use App\Models\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Reply extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'support_ticket_id',
'message',
'attachments',
'note',
];
protected $casts = [
'attachments' => 'array',
'note' => 'boolean',
];
public function isFromAdmin(): Attribute
{
return Attribute::get(fn () => $this->user->is_admin)
->shouldCache();
}
public function isFromUser(): Attribute
{
return Attribute::get(fn () => $this->user_id === auth()->user()->id)
->shouldCache();
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function supportTicket(): BelongsTo
{
return $this->belongsTo(SupportTicket::class);
}
}