- How do I install zoha/laravel-meta in a Laravel app?
- Install the package with Composer, publish its migration, and run the migration to create the polymorphic meta table. Then add the HasMeta trait to each Eloquent model that should own metadata. There is no service provider ceremony or significant configuration sprawl, so a mid-level Laravel developer can be productive quickly.
- Which Laravel and PHP versions does zoha/laravel-meta support?
- The provided assessment does not include a current compatibility matrix, and the last release was March 2024, so verify the package composer.json and CI matrix before committing. Test the current release against your target Laravel and PHP versions in a staging branch. Because Laravel majors regularly break traits and query builders, do not assume support without proof.
- How do I store and retrieve meta on an Eloquent model with zoha/laravel-meta?
- Add the HasMeta trait to your model, then use model saveMeta('key', $value) to write metadata and getMeta('key') to read it back. The package stores key/value pairs in a polymorphic meta table, with a type hint available for casting. Values round-trip through the database as strings, so handle type coercion deliberately in your application code.
- Can zoha/laravel-meta handle SEO metadata such as Open Graph and Twitter tags?
- Yes, the package is designed for attaching and managing SEO metadata for Eloquent models and pages, including titles, descriptions, Open Graph, and Twitter tags. You store the values as meta keys and render them through the package Blade API. Keep your key naming and fallback logic in your app so templates remain consistent across pages.
- How do I render meta tags in Blade with zoha/laravel-meta?
- The package provides a simple, configurable Blade rendering API for outputting clean meta tags from stored metadata. Follow the README examples to render title, description, Open Graph, and Twitter tags in your layout. Always verify escaping and attribute quoting in your templates, especially when meta values can contain user-supplied content.
- Does zoha/laravel-meta support multiple models with polymorphic meta?
- Yes, it is backed by a polymorphic meta table, so different Eloquent models can own meta rows. Add the HasMeta trait to each model that needs metadata, such as CMS pages, blog posts, products, or users. The assessment notes there is no foreign key on the polymorphic relation, so clean up orphaned meta rows when models are hard-deleted.
- Can I filter, sort, or join on meta values stored by zoha/laravel-meta?
- This package is an EAV-lite key/value store and is a poor fit for attributes you intend to filter, sort, aggregate, or join at scale. If a field appears in a list view or participates in business-critical queries, put it in a real column instead. Use the package only for sparse, open-ended metadata that is read by key.
- How do I avoid N+1 queries when loading meta for many models?
- The assessment flags the EAV read path as an N+1 risk unless the trait exposes eager loading and your team uses it. Check whether the current release supports eager loading the meta relation, and batch-load meta for collections where possible. Measure query counts in list and index screens before shipping.
- Is zoha/laravel-meta actively maintained and safe for production?
- The package is MIT, self-contained, and had a last release in March 2024 with about 236 stars, so treat it as probably fine but definitely not guaranteed. It is a single-maintainer project, and a thin trait is exactly the kind of package that can silently stop receiving Laravel compatibility patches. Name an owner for a fork or vendored copy and keep a patching runbook.
- What are alternatives to zoha/laravel-meta for custom model attributes in Laravel?
- For JSON-column storage, spatie/laravel-schemaless-attributes is a stronger alternative, and a hand-rolled JSON column is often enough. If you already maintain a custom meta table, adopting this package is a lateral move unless it saves you real maintenance. Choose based on whether the attributes are ever queried, sorted, or joined.