1. Go to this page and download the library: Download kosmoskosmos/rating 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/ */
kosmoskosmos / rating example snippets
public function fields(Request $request)
{
return [
// ...
// Define categories for to be rated.
Rating::make('Pizza Baking Skills', 'pizza_rating')->hideFromIndex(),
Rating::make('Sushi Rolling Skills', 'sushi_rating')->hideFromIndex(),
Rating::make('Bread Baking Skills', 'bread_rating')->hideFromIndex(),
// Show average rating from all three categories above.
Rating::make('Overall Skills', 'average_rating')->onlyOnIndex(),
// Show average rating from only one category above
Rating::make('Overall Bread Baking Skills', 'bread_average_rating')->onlyOnIndex(),
];
}
class MyModel extends Model {
// use the Rateable trait
use \KosmosKosmos\Rating\Rateable;
// use the getAttribute() function to inject the Trait's attribute-resolver
public function getAttribute($key) {
if ($result = $this->resolveRatingAttribute($key)) {
return $result;
}
return parent::getAttribute($key);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.