share-lt/app/Models/Entry.php
Jon Brookes 56607285bd feat: integrate Spatie Media Library (#4)
- Added Spatie Media Library
- Added media library configuration file
- Updated Entry model to support media handling
- Added featured image upload with gallery selection and preview
- Added login tests with Dusk for user authentication
- Added Dusk test for featured image selection

Co-authored-by: jon brookes <marshyon@gmail.com>
Reviewed-on: https://codeberg.org/headshed/share-lt/pulls/4
2026-01-06 13:26:55 +01:00

46 lines
1.2 KiB
PHP

<?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;
/*
Entry model with rich content and media library integration
This is the main article / blog rich content model
*/
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()
);
}
}