Download the PHP package wsmallnews/preference without Composer
On this page you can find all versions of the php package wsmallnews/preference. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wsmallnews/preference
More information about wsmallnews/preference
Files in wsmallnews/preference
Package preference
Short Description Wsmallnews system preference modules
License MIT
Homepage https://github.com/wsmallnews/preference
Informations about the package preference
Preference
Wsmallnews Universal Preference Record System, built on Laravel + Filament. Supports unified recording and management of preference behaviors such as likes, follows, and views. Designed with polymorphic relationships, any Eloquent model can be integrated.
Overview
- Like: Full-featured like/unlike/toggle like, with automatic counter maintenance
- Follow: Follow/unfollow/toggle follow, supports mutual follow detection, with automatic bidirectional counter maintenance
- View: View recording/counting, supports anonymous user statistics without authentication
- Polymorphic Design: Any model can be a preference subject (Preferenceable) or preference operator (Preferencer)
- Scope Isolation: Multi-scope data isolation via scope_type + scope_id
- Multi-Tenancy Support: Automatic team_id association
- Batch Status Attachment: Efficiently attach like/follow/view statuses to collections or paginated data (avoids N+1 queries)
- Counter Integration: Supports automatic increment/decrement of JSON
counterfield - Mutual Follow Support: Built-in mutual follow detection and
followed_attimestamp recording in Follow system
Installation
You can install the package via composer:
Installing this package will publish the configuration files and migration files of both the third-party dependency package and the current package:
You can publish only the config file individually:
Publish and run only the migrations individually:
Multi language support, you can publish the language files using:
Publish the views (optional):
This is the contents of the published config file config/sn-preference.php:
Usage
1. Add Preference Capabilities to Models
Include the corresponding Traits in your models:
2. Add counter field
Add a JSON counter field to your model's migration:
3. Like
The counter field is automatically maintained and updated when counts increase/decrease:
4. Follow
Counter is automatically maintained:
When following each other, the time is automatically recorded:
5. View
Counter is automatically maintained:
Use Cases
| Use Case | Traits Used | Example |
|---|---|---|
| Article Like | Likeable + Liker |
User likes an article |
| User Follow | Followable + Follower |
Users follow each other |
| Content View | Viewable + Viewer |
Record article views and user browsing history |
| Comment Like | Likeable + Liker |
User likes a comment (used in comment package) |
| Product Favorite | Custom type extension | Extend new behavior types based on Preference model |
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- smallnews
- bezhansalleh/filament-plugin-essentials
- filament/filament
- Wsmallnews/support
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of preference with dependencies
filament/filament Version ^4.0 || ^5.0
spatie/laravel-package-tools Version ^1.15.0
wsmallnews/support Version ^1.0