kosmoskosmos / rating

Allows multiple models to be rated with a five-star like system on Laravel Nova

Stars
0

Laravel Nova Rateable Field Extension

About

This package introduces a Rateable Trait to your application's models on Laravel Nova.

This package introduces a Rateable Trait to your application's models.

Also, it introduces an interactive Field to your Nova backend that makes it possible to instantly rate any property you wish.

With this package it is possible to perform multiple category rating.

For example, you might want to rate the

  • Performance
  • Price
  • Quality

of a product.

However, you can also generate a field that returns the average rating over all three categories combined with the virtual attribute averageRating

Credits

Thank you for doing the base work:

https://github.com/willvincent/laravel-rateable
https://github.com/craigh411/vue-star-rating

Special credits

Thank you for inspiring us:

https://novapackages.com/packages/nikaia/nova-rating-field

If you need some more documentation about possible options, this might be a good documentation resource.

Installation

  1. composer require kosmoskosmos/nova-rateable-field
  2. php artisan vendor:publish
  3. php artisan migrate

Usage

public function fields(Request $request)
{
    return [
        // ...
        // Define categories for to be rated.
        Rating::make('Pizza Baking Skills', 'pizza')->hideFromIndex(),
        Rating::make('Sushi Rolling Skills',  'sushi')->hideFromIndex(),
        Rating::make('Bread Baking Skills', 'bread')->hideFromIndex(),
        // Show average rating from all three categories above.  
        Rating::make('Overall Skills', 'average_rating')->onlyOnIndex(), 
        // ...    
    ];
}