- How do I add time-sliced metadata to an Eloquent model in Laravel?
- Use the `HasMeta` trait on your model and assign metadata fluently, like `$post->likes = 24`, or explicitly with `$post->setMeta('likes', 24)`. The package stores metadata in a polymorphic table without requiring schema changes to your models.
- Can I schedule metadata changes for future dates in Laravel Multiplex?
- Yes. Use `setMetaAt()` to schedule changes, e.g., `$post->setMetaAt('likes', 6000, '+2 years')`. The package handles time-based updates automatically when the scheduled time arrives.
- What Laravel versions does this package support?
- Laravel Multiplex supports Laravel 9 and later. It requires MySQL 8.0+ (or equivalent) for window functions, though SQLite and SQL Server are supported with some limitations.
- How does Laravel Multiplex handle performance with large datasets?
- The package uses database window functions for efficient querying, but performance depends on your database. For large datasets, ensure proper indexing on the meta table and use eager loading helpers like `withMeta()` to avoid N+1 issues.
- Can I query metadata for a specific point in time?
- Yes. Use `getMetaAt()` or `whereMetaAt()` to retrieve metadata as of a specific timestamp. The package supports time-travel queries to fetch historical or scheduled values.
- Does Laravel Multiplex work with Laravel Scout or Nova?
- Yes. The package integrates seamlessly with Laravel Scout for metadata-based search and Laravel Nova for UI-driven metadata management, making it ideal for applications requiring dynamic, versioned data.
- What happens if I need to downgrade from MySQL 8.0+?
- Downgrading databases could break queries relying on window functions (e.g., `ROW_NUMBER()`). The package may require refactoring or alternative approaches like JSON columns if you switch to older database versions.
- How do I backfill historical metadata for existing records?
- Use `saveMetaAt()` to manually hydrate historical data, such as backdating user preferences. For large datasets, consider batch processing with queued jobs to avoid timeouts or performance issues.
- Are there alternatives to Laravel Multiplex for time-sliced data?
- If your use case is simpler, Laravel’s built-in JSON columns or attributes might suffice. For complex temporal data, consider event sourcing or a dedicated time-series database, though Multiplex offers a balanced solution for Eloquent-based applications.
- How do I handle concurrent metadata updates in production?
- The package doesn’t include built-in locking mechanisms, so concurrent updates to the same metadata key could lead to race conditions. Use database transactions or application-level locks if atomicity is critical for your workflow.