<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Storage;

class ClubMessageAttachment extends Model
{
    protected $fillable = [
        'club_message_id',
        'file_path',
        'file_name',
        'mime_type',
        'file_size',
        'attachment_type',
    ];

    public function message(): BelongsTo
    {
        return $this->belongsTo(ClubMessage::class, 'club_message_id');
    }

    public function url(): string
    {
        return Storage::disk('public')->url($this->file_path);
    }

    public function isImage(): bool
    {
        return $this->attachment_type === 'image';
    }
}
