Rating
>= v1.25Rating component.
Rating, Personalization Blocks
This content is part of TallStackUI personalization.
Example:
TallStackUi::personalize() ->rating() ->block('block', 'classes');
The soft personalization should be done in boot
method of service providers.
Version 1.25.0 of TallStackUI introduces a new component: Rating. In the modern world, many applications need to collect their user's level of satisfaction related to specific parts of a process, such as the purchase process, which may require the evaluation of service and even satisfaction with the delivery of the object. The rating component was created thinking precisely about serving this purpose, displaying stars to be clicked to evaluate something.
The logic for persisting the rating in a database, such as SQL, SQLite or Redis (cache)
is up to its own algorithm. When a star is pressed, the evaluate
method is triggered, receiving the quantity of rating as a parameter. Let's take a look at an example:
The Livewire component:
use Livewire\Component;use Illuminate\Contracts\View\View; class Profile extends Component{ public $rate = 2; public function render(): View { return view('livewire.profile'); } public function evaluate(int $quantity): void { // }}
The associated Blade file:
<x-rating wire:model="rate" />
With this example, when clicking on a star in the component, the evaluate
method will be triggered, receiving in the $quantity
parameter the value
related to the number of rating selected. You can change the method used to receive the rating
event by using evaluate-method
:
<x-rating wire:model="rate" evaluate-method="evaluating" />
As the rate
parameter is only used to define the current
number of selected rating, you are not required to use wire:model
.
Using this approach with static
parameter you will be able to use this
component out of Livewire components:
<x-rating :$rate /> <!-- The "static" parameter disablethe click effect on the starts --><x-rating :$rate static />
TALL
LIVT