Installation:
composer require awcodes/matinee
Ensure you have a custom Filament theme configured.
Add CSS:
In your theme’s CSS file (e.g., resources/css/filament/app.css):
@source '../../../../vendor/awcodes/matinee/resources/**/*.blade.php';
First Use Case: Add the field to a Filament resource or form:
use Awcodes\Matinée\Fields\OEmbedField;
OEmbedField::make('video')
->label('Embed Video')
->required(),
config/matinee.php (if generated; check for default settings).Basic Embed Field:
OEmbedField::make('youtube_url')
->label('YouTube Video')
->columnSpanFull(),
Customizing Providers:
OEmbedField::make('custom_embed')
->providers([
'soundcloud' => 'https://soundcloud.com/oembed',
]),
Integration with Resources:
// In a Filament Resource
public static function form(Form $form): Form
{
return $form
->schema([
OEmbedField::make('hero_video')
->required()
->maxLength(255),
]);
}
Validation & Sanitization:
OEmbedField::make('trailer')
->rules(['url' => 'active_url|max:255'])
->sanitizeUrl(),
Displaying Embeds in Views:
@if($record->video_url)
<div class="matinee-embed">
{!! $record->video_url->embed !!}
</div>
@endif
->dynamicProviders() to fetch providers from an API or config..matinee-embed iframe {
max-width: 100%;
aspect-ratio: 16/9;
}
Theme Dependency:
@source CSS directive.Provider Limitations:
->fallbackUrl() to provide a default embed or handle errors in ->mutate().JSON Storage:
{"url":"https://youtube.com/..."}).$record->video_url->url to access the raw URL; avoid direct JSON parsing.CORS Restrictions:
OEmbedField::make('debug_embed')
->logResponses(), // Logs provider API calls to Laravel logs
https://www.youtube.com/watch?v=dQw4w9WgXcQ) to isolate issues.https://www.youtube.com/oembed?url=...) return valid JSON.Custom Providers:
Extend the OEmbedProvider class to support niche platforms:
class CustomProvider extends OEmbedProvider {
public function getEndpoint(): string {
return 'https://custom-site.com/oembed';
}
}
Register via:
OEmbedField::make('custom')
->providers(['custom' => CustomProvider::class]),
Post-Processing: Modify embed HTML after fetching:
OEmbedField::make('poster')
->mutate(function ($state) {
$state['embed'] = str_replace('width="560"', 'width="100%"', $state['embed']);
return $state;
}),
Livewire Integration:
Use ->livewire() to update embeds dynamically without full page reloads:
OEmbedField::make('live_embed')
->livewire(),
config(['matinee.providers' => []]);
OEmbedField::make('cached_embed')
->cacheProviderResponses(minutes: 60),
How can I help you explore Laravel packages today?