lifeonscreen/nova-belongs-to-badge
A Laravel Nova field that displays a belongsTo relationship as a compact, color-coded badge in index and detail views, so related records are easy to scan at a glance. Simple to configure with custom labels, colors, and value mappings.
^1.0).HasOne/HasMany/BelongsTo/morphTo relations.->with('packageRelation') and verify the query count drops. Eager loading is the headline v1.0.0 feature, so this is the quickest way to validate the upgrade.Parent::with('packageRelation')->get() is the default pattern for list/index endpoints. Add constraints with closures: with(['packageRelation' => fn ($q) => $q->where('active', 1)]).with('packageRelation.child') avoids N+1 at deeper levels, especially when API resources serialize nested data.$parent->load('packageRelation') after route-model binding, and loadMissing('packageRelation') when the relation may already be loaded by a parent query.whenLoaded('packageRelation') so serialization never triggers an implicit lazy load and the eager-loading contract stays explicit.$with property, use it only for relations that are needed on virtually every query. Prefer explicit with() for everything else to avoid over-fetching.withCount('packageRelation') or withSum when you only need a count/sum; loading the full relation is wasted work.chunkById(..., fn ($parents) => $parents->load('packageRelation'))) rather than loading everything at once.DB::enableQueryLog() or Laravel's query-count expectations to lock in the eager-loading behavior and catch regressions.select() can break eager loading. If you restrict columns, include the foreign keys the relation needs, or the relation silently resolves to empty collections.Model::preventLazyLoading(! app()->isProduction()) to catch places where the new eager loading support is not being used.load vs loadMissing: load re-queries and overwrites; loadMissing is a no-op if the relation is already present. Use loadMissing in shared code paths and load after explicit refreshes.refresh(), mass updates, or model events that change related records, eager-loaded relations can be out of date. Reload explicitly when correctness matters.morphTo: closures behave differently for polymorphic relations; use morphWith/morphWithCount where applicable.HasMany with thousands of rows is often worse than a targeted query. Prefer withCount, latestOfMany, or a separate paginated query.config/; publishing config is often required to change defaults.$with property are the safest customization surfaces. Avoid overriding package internals; hook through scopes and model events instead.How can I help you explore Laravel packages today?