Like Button Component using Livewire
Tech Stack: bootstrap-5, livewire
Demo
New Bootstrap 5 Livewire
Simple Livewire toggle switch
Code
Please login to View/Download the Code
Usage
@livewire('like-model',[
'model' => $post
])
Documentation
In order to use this Like button component, you need to install a laravel-love composer package in your laravel project.
Installation
composer require cybercog/laravel-love
And then run:
php artisan migrate
Adding default reactions
Run the following command, to add default reactions i.e. Like and Dislike into the database.
php artisan love:reaction-type-add --default
Setting up Reacterable (User Model)
Further, we need to modify the User model to extend an interface and add a trait to it, as shown above in the User Model Tab.
Run artisan command
php artisan love:setup-reacterable --model="App\User" --nullable
You can look more into the Official Documentation on setting up Reactable.