Download the PHP package modularavel/likeable without Composer
On this page you can find all versions of the php package modularavel/likeable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download modularavel/likeable
More information about modularavel/likeable
Files in modularavel/likeable
Package likeable
Short Description A Laravel Livewire package for adding like/dislike functionality to Eloquent models
License MIT
Homepage https://github.com/modularavel
Informations about the package likeable
Modularavel Likeable
A Laravel Livewire package for adding like and dislike functionality to your Eloquent models with beautiful TailwindCSS styled components.
Features
- Like and dislike any Eloquent model
- Real-time updates with Livewire
- Support for authenticated users and guest tracking via IP
- Beautiful TailwindCSS styled button component
- Dark mode support
- Configurable options
- Easy to integrate and use
Requirements
- PHP 8.0 or higher
- Laravel 9.x, 10.x, or 11.x
- Livewire 2.x or 3.x
- TailwindCSS
Installation
1. Install the package via Composer
2. Publish the migrations
3. Run migrations
4. (Optional) Publish the configuration file
5. (Optional) Publish the views for customization
Usage
1. Add the Likeable trait to your model
2. Use the Livewire component in your Blade views
Or with custom options:
You can also pass the model ID and type separately:
3. Available Methods
The Likeable trait provides these methods:
4. Using programmatically
Configuration
The configuration file allows you to customize the package behavior:
Customization
Styling
The component uses TailwindCSS classes. If you want to customize the appearance, publish the views:
Then edit the view files in resources/views/vendor/likeable/.
Dark Mode
The component includes built-in dark mode support using TailwindCSS dark mode classes.
Component Props
| Prop | Type | Default | Description |
|---|---|---|---|
model |
Model | null | The Eloquent model instance |
modelId |
int | null | The model ID (alternative to passing model) |
modelType |
string | null | The model class name (alternative to passing model) |
showCount |
bool | true | Show like/dislike counts |
showDislike |
bool | true | Show dislike button |
Events
The component emits these Livewire events:
likeToggled- Fired when like is toggleddislikeToggled- Fired when dislike is toggledrefreshLikes- Listen to this to refresh like counts
Example of listening to events:
Database Schema
The package creates a likes table with the following structure:
id- Primary keylikeable_type- Polymorphic typelikeable_id- Polymorphic IDuser_id- User ID (nullable)ip_address- IP address (nullable)type- 'like' or 'dislike'created_at- Timestampupdated_at- Timestamp
License
MIT License
Support
For issues, questions, or contributions, please visit the GitHub repository.