- How do I add metadata support to an existing Eloquent model without downtime?
- Use the `addMeta()` macro in your migration to add a JSON column or a dedicated table. Apply the `HasMeta` trait to your model and configure defaults via `getMetaConfig()`. Existing queries remain unchanged unless explicitly using metadata features.
- Does this package support filtering models by metadata values (e.g., `where('meta.key', 'value')`)?
- Yes, but performance varies. For simple queries, use `whereHas('meta', fn($q) => $q->where('key', 'value'))`. For production, a dedicated `_meta` table with indexes is recommended over JSON columns for complex filtering.
- Can I use this for Open Graph tags and SEO without a frontend framework like Livewire?
- Absolutely. The package includes a `CurrentModel` facade and Blade directives (`@include('laravel-meta::meta')`) to render OG/SEO tags directly in views. Works with any Laravel frontend, including static HTML or API-driven clients.
- What’s the difference between storing metadata in a JSON column vs. a separate table?
- JSON columns are simpler for small, infrequently queried metadata but lack indexing and bloat row size. A dedicated table (e.g., `posts_meta`) offers better performance for filtering/sorting but adds join overhead. Use the table for production-scale apps.
- How do I validate metadata values before saving?
- The package doesn’t enforce validation by default. Implement it via model observers, form requests, or override the `savingMeta()` method in the `HasMeta` trait. For example, validate `og_image` URLs before saving.
- Is there built-in support for Laravel Nova or Filament admin panels?
- Yes. The package provides `NovaResourceHasMeta` and `FilamentResourceHasMeta` traits to auto-generate metadata fields in Nova/Filament panels. Publish the views with `php artisan vendor:publish --tag=views` to access these traits.
- Will this work with Laravel 9 or PHP 8.1?
- No. The package requires **Laravel 10+** and **PHP 8.2+**. Check the [README](https://github.com/novius/laravel-meta) for version compatibility or consider alternatives like `spatie/laravel-activitylog` for older setups.
- How do I handle concurrent metadata updates (e.g., two users editing at once)?
- The package doesn’t include built-in concurrency controls. Use Laravel’s `lockForUpdate()` or database transactions in your update logic to prevent race conditions. For critical apps, consider optimistic locking on the parent model.
- Can I use this for non-SEO metadata, like A/B test variants or user preferences?
- Yes. The package is schema-less and works for any dynamic key-value pairs. For example, store `ab_test_variant: 'blue-button'` or `user_preference: 'dark-mode'`. Just configure fallbacks and validation as needed.
- What are the alternatives to `novius/laravel-meta` with a more permissive license?
- For MIT-licensed alternatives, consider `spatie/laravel-activitylog` (for structured logs) or `spatie/laravel-medialibrary` (for media metadata). For pure key-value storage, `spatie/laravel-simple-attributes` is another option, though it lacks SEO-specific features.