- How do I install baks-dev/products-favorite in a Laravel 10+ project?
- Run `composer require baks-dev/products-favorite` to install. The package requires PHP 8.4+ and Laravel 10+, so ensure your environment meets these requirements. No additional steps are needed unless you customize views or migrations, which can be published via `php artisan vendor:publish --tag=products-favorite-views`.
- Does this package support polymorphic favorites (e.g., for products, articles, or other models)?
- The package does not explicitly document polymorphic support in v7.4.8. It’s designed for product favorites by default, but you can extend it by modifying the underlying Eloquent model relationships. Check the changelog for updates or review the source code for customization hooks.
- Can I use this with Livewire or Inertia.js for dynamic frontend interactions?
- Yes, the package is frontend-agnostic and works with Livewire or Inertia.js. It provides Blade templates (e.g., `@include('products-favorite::partials.favorite-button')`) that you can integrate into your frontend components. No JavaScript dependencies are included, so it’s lightweight for SPAs or server-side rendering.
- What Laravel versions are officially supported by v7.4.8?
- This version is explicitly built for Laravel 10+ and requires PHP 8.4+. While it may work with older Laravel versions, no backward compatibility guarantees are provided. Always test thoroughly if using Laravel 9.x or below, as deprecated methods could cause issues.
- How do I add rate-limiting or queue jobs for favorite actions (e.g., FavoriteAdded events)?
- The package doesn’t include built-in rate-limiting or queueable jobs, but you can extend it. Listen to events like `FavoriteAdded` in your `EventServiceProvider` and dispatch them to queues. For rate-limiting, use Laravel’s `throttle` middleware or packages like `spatie/rate-limiter`.
- Are there any database optimizations in v7.4.8, like indexes or query improvements?
- The release notes for v7.4.8 don’t mention schema or query optimizations, so assume no changes to indexes or performance-critical paths. If you’re concerned about N+1 queries, manually eager-load relationships (e.g., `with('user')`) in your queries or use Laravel’s `with()` method on the Favorite model.
- How do I customize the views or publish assets from this package?
- Run `php artisan vendor:publish --tag=products-favorite-views` to publish Blade templates and config files to `resources/views/vendor/products-favorite` and `config/products-favorite.php`. Override the published files to tailor the UI or behavior to your needs.
- Is there a way to test if the package works with Sanctum or Passport for API-based favorites?
- Yes, the package integrates with Laravel’s authentication system, so it works seamlessly with Sanctum or Passport. Test API endpoints like `POST /favorites` or `GET /user/favorites` using tools like Postman or Laravel’s HTTP tests. Ensure your auth middleware is properly configured.
- What alternatives exist for Laravel wishlist functionality, and how does this compare?
- Alternatives include Spatie’s `wishlist` package (v3.x), which offers bulk actions and API endpoints out of the box. Compare features like polymorphic support, event-driven architecture, and frontend templates. This package is lighter but may require more customization for advanced use cases.
- How can I verify if the package is compatible with my existing database migrations?
- Run `php artisan migrate --pretend` to check for conflicts. Since v7.4.8 doesn’t introduce schema changes, your existing migrations should remain unaffected. If you’ve customized the `favorites` table, ensure your changes align with the package’s default structure to avoid issues.