You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Help;
|
||||
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Stevebauman\Purify\Facades\Purify;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $ticket_id
|
||||
* @property int $user_id
|
||||
* @property string $content
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property-read string $content
|
||||
* @property-read WebsiteHelpCenterTicket|null $ticket
|
||||
* @property-read User|null $user
|
||||
*/
|
||||
class WebsiteHelpCenterTicketReply extends Model
|
||||
{
|
||||
#[\Override]
|
||||
protected $guarded = ['id', 'created_at', 'updated_at', 'user_id', 'ticket_id', 'content'];
|
||||
|
||||
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()
|
||||
{
|
||||
return $this->user_id === Auth::id() || hasPermission('delete_website_ticket_replies');
|
||||
}
|
||||
|
||||
public function getContentAttribute($value)
|
||||
{
|
||||
return Purify::clean($value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user