You've already forked Atomcms-edit
574b5d6e17
feat: add 24 model factories for Help, Shop, Community, Game, User domains - Translate mixed Dutch/English strings in README.md and AlertSettings.php - Add HasFactory trait to 23 models - Create factories for Help (6), Shop (4), Community (5), Game (2), User (7)
50 lines
1.3 KiB
PHP
Executable File
50 lines
1.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models\Help;
|
|
|
|
use App\Models\User;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
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
|
|
{
|
|
use HasFactory;
|
|
#[\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);
|
|
}
|
|
}
|