*/ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * @return BelongsTo */ public function category(): BelongsTo { return $this->belongsTo(WebsiteHelpCenterCategory::class); } /** * @return HasMany */ public function replies(): HasMany { return $this->hasMany(WebsiteHelpCenterTicketReply::class, 'ticket_id'); } public function canDeleteTicket(): bool { return $this->user_id === Auth::id() || hasPermission('delete_website_tickets'); } public function canManageTicket(): bool { return $this->user_id === Auth::id() || hasPermission('manage_website_tickets'); } public function canCloseTicket(): bool { return $this->user_id === Auth::id() || hasPermission('manage_website_tickets'); } public function isOpen(): bool { return $this->open || hasPermission('manage_website_tickets'); } /** * @return \Illuminate\Database\Eloquent\Casts\Attribute */ protected function content(): \Illuminate\Database\Eloquent\Casts\Attribute { return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: fn ($value) => Purify::clean(is_string($value) ? $value : '')); } }