Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nova Rating Field Laravel Package

eom-plus/nova-rating-field

A Laravel Nova field that adds interactive star ratings to your resources. Let users set and display rating values through a customizable star widget, with configurable max stars, read-only display, and smooth integration across Nova forms, detail, and index views.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer alongside a Laravel Nova 4 app:

composer require eom-plus/nova-rating-field

No service provider registration or publishing is required for a standard Nova 4 install. The field is used like any other Nova field inside a resource’s fields() method:

use EomPlus\NovaRatingField\Rating;

public function fields(NovaRequest $request)
{
    return [
        Rating::make('Rating')
            ->max(5)
            ->min(0)
            ->step(1),
    ];
}

Where to look first:

  1. The package’s src/ directory for the field class namespace and available fluent methods.
  2. resources/js/ for the Vue component, to confirm props such as max, min, step, and any color/icon options.
  3. The README for the exact namespace — package namespaces in small Nova fields sometimes differ from the Composer name.

First use case: add a simple 5-star rating to an existing model. You need a numeric column already in the database:

Schema::table('products', function (Blueprint $table) {
    $table->unsignedTinyInteger('rating')->default(0)->after('name');
});

Then cast it in the model ('rating' => 'integer') and add Rating::make('Rating')->max(5) to the Nova resource. This gives you an interactive star widget on the detail and update forms and a sensible display on index.

Implementation Patterns

Basic form field with validation. The field is a frontend widget; server-side validation is still yours:

Rating::make('Rating')
    ->max(5)
    ->rules('required', 'integer', 'min:0', 'max:5')
    ->sortable(),

Because Nova passes rules through to the underlying request, keep the field’s max() and your validation max: in sync — they are independent settings.

Half-star / decimal ratings. If the Vue component supports step(0.5), store the value in a decimal(3,1) column and cast it accordingly:

$table->decimal('rating', 3, 1)->default(0);

// Model
protected $casts = ['rating' => 'float'];
Rating::make('Rating')->min(0)->max(5)->step(0.5),

If step is not exposed by the package version you have, fall back to integer stars or a plain Number field.

Index and detail display. Typical Nova fields support ->onlyOnIndex(), ->hideFromIndex(), and ->readonly(). Use read-only mode for audit views where the rating is derived:

Rating::make('Average Rating', 'average_rating')
    ->readonly()
    ->onlyOnDetail(),

Sorting. If the field exposes ->sortable(), it sorts by the underlying column. Confirm the column name matches the field attribute when you use a label/attribute split (Rating::make('Score', 'rating') sorts on rating).

Grouping with other fields. A common pattern is to pair the rating with a text justification or a reviewer field, and to use ->help() for tooltips:

Rating::make('Rating')->max(5)->help('1 = poor, 5 = excellent'),
Textarea::make('Review Notes')->alwaysShow(),

Dashboards and metrics. A rating field is not a metric card; for aggregate averages use Nova metrics with a ->avg('rating') calculation rather than trying to reuse the field on a dashboard.

Gotchas and Tips

  • Nova 4 only. The package targets Nova 4 (Vue 3). Do not attempt to use it on Nova 3; the JS build and field registration differ. Last release was October 2023, so test against your current Nova 4 minor version before rolling out widely.
  • Zero dependents and one star means the ecosystem surface is tiny. Treat it as a small utility you are comfortable patching, and pin the version in composer.json. Read the Vue component source if a prop does not behave as expected.
  • No database column is created for you. Migrations, casting, and default values are your responsibility. Forgetting the cast commonly produces string values ("4") in JSON responses and inconsistent comparisons.
  • nullable ratings. A nullable rating column plus a star widget can render awkwardly when the value is null. Decide whether null means “unrated” and either set a default of 0 or handle null display in your resource.
  • Validation is not automatic. ->max(5) on the field configures the widget, not the request. Always add rules() or a FormRequest to prevent out-of-range values arriving via the API.
  • Index rendering performance. Star widgets render a small set of icons per row. On very large index tables this is negligible, but if you also compute averages per row, eager-load or select the aggregate to avoid N+1 queries.
  • Dark mode and styling. Custom Nova fields sometimes ship fixed colors. If stars look washed out in dark mode, check the component’s CSS and override via a small published asset or a Nova custom stylesheet rather than editing vendor/.
  • Extension points. For custom behavior (half-star clicks, custom colors, tooltips), the cleanest route is to subclass the field or copy the Vue component into nova-components/ and register your own field, rather than patching the vendor package.
  • Debugging. If the field does not appear, confirm the namespace is correct and run php artisan nova:publish / clear caches (php artisan optimize:clear). For JS issues, run npm run dev in the Nova directory or check the browser console for component registration errors — small Nova packages occasionally lag behind Nova’s asset pipeline changes.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager