<?php

namespace App\Models;

use Filament\Forms\Components\RichEditor\FileAttachmentProviders\SpatieMediaLibraryFileAttachmentProvider;
use Filament\Forms\Components\RichEditor\Models\Concerns\InteractsWithRichContent;
use Filament\Forms\Components\RichEditor\Models\Contracts\HasRichContent;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Entry extends Model implements HasRichContent, HasMedia

{

    use InteractsWithMedia, InteractsWithRichContent;

    protected $fillable = [
        'title',
        'slug',
        'description',
        'is_published',
        'is_featured',
        'published_at',
        'content',
    ];


    /**
     * Set up rich content configuration for media library integration
     */
    public function setUpRichContent(): void
    {
        $this->registerRichContent('content')
            ->fileAttachmentProvider(
                SpatieMediaLibraryFileAttachmentProvider::make()
                    ->collection('content-attachments')
                    ->preserveFilenames()
            );
    }

}
