You've already forked Epicnabbo-Catalogus-Updated-Daily
38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Help;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Stevebauman\Purify\Facades\Purify;
|
|
|
|
class WebsiteHelpCenterTicketReply extends Model
|
|
{
|
|
protected $guarded = ['id'];
|
|
|
|
public function ticket(): BelongsTo
|
|
{
|
|
return $this->belongsTo(WebsiteHelpCenterTicket::class, 'ticket_id');
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public function canDeleteReply(): bool
|
|
{
|
|
return $this->user_id === Auth::id() || hasPermission('delete_website_ticket_replies');
|
|
}
|
|
|
|
/**
|
|
* @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
|
|
*/
|
|
protected function content(): \Illuminate\Database\Eloquent\Casts\Attribute
|
|
{
|
|
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean(is_string($value) ? $value : ''));
|
|
}
|
|
}
|