<?php

namespace App\Models;

use Database\Factories\SystemMessageFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class SystemMessage extends Model
{
    /** @use HasFactory<SystemMessageFactory> */
    use HasFactory;

    protected $guarded = [];

    protected function voice(): Attribute
    {
        return Attribute::make(
            get: fn($value) => $value == null ? null : Storage::disk('public')->url($value)
        );
    }
}
