Download the PHP package modularavel/favoritable without Composer
On this page you can find all versions of the php package modularavel/favoritable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download modularavel/favoritable
More information about modularavel/favoritable
Files in modularavel/favoritable
Package favoritable
Short Description A Laravel Livewire package to add favorites functionality to your application
License MIT
Homepage https://github.com/modularavel/favoritable
Informations about the package favoritable
modularavel/favoritable
A Laravel Livewire package that adds favorites functionality to your Laravel 11+ application. Allow users to favorite any model in your application with a beautiful, customizable UI.
Features
- Add favorites to any Eloquent model
- Beautiful Livewire components with multiple variants
- Favorite button with counter
- Favorites list page
- Tailwind CSS styling included
- Full test coverage with Pest
- Easy to customize
- Real-time updates
Requirements
- PHP 8.2+
- Laravel 11.0+ or Laravel 12.0+
- Livewire 3.0+
- Tailwind CSS
Installation
Install the package via Composer:
Publish the migrations:
Run the migrations:
Optionally, publish the config file:
Optionally, publish the views for customization:
Setup
1. Add the Trait to Your Model
Add the Favoritable trait to any model you want users to be able to favorite:
2. Import CSS Styles
Add the package CSS to your main CSS file or import it in your layout:
Or include it directly in your Tailwind config:
Usage
Favorite Button Component
The simplest way to add a favorite button:
Button Variants
Choose from multiple button styles:
Button Sizes
Choose from three sizes:
Hide Counter
You can hide the favorites counter:
Favorites List Component
Display a paginated list of user's favorites:
Filter by Type
Show only favorites of a specific type:
Custom Pagination
Model Methods
The Favoritable trait adds several helpful methods to your models:
Customizing the Favorites List Display
To customize how your favorited items appear in the favorites list, implement these methods in your model:
Configuration
The package includes a configuration file with sensible defaults:
Events
The package dispatches Livewire events that you can listen to:
favoriteToggled
Dispatched when a favorite is toggled:
Testing
The package includes comprehensive Pest tests. To run tests:
Styling
The package uses Tailwind CSS for styling. All styles are scoped to avoid conflicts with your application. You can customize the appearance by:
- Publishing the views and modifying the Blade templates
- Overriding the CSS classes in your application's CSS
- Modifying the published CSS file
Advanced Usage
Custom Favorite Model
If you need to extend the Favorite model:
Middleware Protection
Protect your favorites routes with middleware:
License
MIT
Credits
- Modularavel
- All Contributors
Support
For issues, questions, or contributions, please visit the GitHub repository.
All versions of favoritable with dependencies
illuminate/support Version >=8.0
illuminate/database Version >=8.0
livewire/livewire Version ^3.0