PHP code example of allcaretravel / nova-rating-field
1. Go to this page and download the library: Download allcaretravel/nova-rating-field library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
allcaretravel / nova-rating-field example snippets
public function fields(Request $request)
{
return [
// ...
Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideFromIndex(),
// Defining a custom style for the index page.
Rating::make('Rating')->min(0)->max(5)->increment(0.5)->hideRating()
->withStyles([
'star-size' => 15,
'rounded-corners' => true,
])->onlyOnIndex()->sortable(),
// ...
];
}
public function fields(Request $request)
{
Rating::make('Rating')
// Miniumum rating (default: 0)
->min(0)
// Maximum rating (default: 5)
// This is how the component knows how many stars it should display.
->max(5)
// Incremet (default: 1)
// Can be float. The underlying eloquent colum must be defined as float in that case.
// ie. 0.5 for half stars or 0.01 for fluid stars.
->increment(0.5)
// Show rating value next to the stars
->hideRating()
}