Adding a Star Rating system to your application – Step 5 – Changing the View to use the CSS Star Rating component

The next step is straight forward. We need to modify the ratecourt view to replace the simple number based rating with our new bootstrap-star-rating component. To do this, open the file resources/views/courtratings/ratecourt_fields.blade.php and replace the blade helper which creates the rating field

with the following line

{!! Form::number('rating', null, ['class' => 'rating', 'data-min' => 0, 'data-max' => 5, 'data-step' => 1, 'data-size' => 'sm']) !!}

This approach uses a blade helper to create the field but it should be noted that you can also use straightforward html to create this input component and achieve the same effect. This would look as follows

 <input id="fieldRating" name="rating" type="text" class="rating" data-min=0 data-max=5 data-step=1 data-size="sm"> 

Select a court to rate from the http://localhost:8000/courts page by clicking on the tick beside the court the form should now look as follows

Leave a Reply