Files
Paymenter-Version-Tracks/app/Models/TicketMessageAttachment.php
Muhammad Tamir 85c03cef82 v1.3.4
2025-11-14 10:57:49 +07:00

40 lines
815 B
PHP

<?php
namespace App\Models;
use Illuminate\Support\Str;
class TicketMessageAttachment extends Model
{
protected $fillable = [
'path',
'filename',
'filesize',
'mime_type',
'ticket_message_id',
];
protected static function booted()
{
static::creating(function ($model) {
$model->uuid = (string) \Illuminate\Support\Str::uuid();
});
}
public function ticketMessage()
{
return $this->belongsTo(TicketMessage::class);
}
public function getLocalPathAttribute(): string
{
return storage_path("app/{$this->path}");
}
// Function to check if attachment can be previewed
public function canPreview(): bool
{
return Str::startsWith($this->mime_type, ['image/']);
}
}