- What Laravel versions does baks-dev/products-product support?
- The package requires PHP 8.4+ and is designed for Laravel 10+ applications. While not explicitly stated, its reliance on Doctrine Migrations and Eloquent suggests compatibility with modern Laravel versions. Always verify with the latest release notes for edge cases.
- How do I install and configure the product module in Laravel?
- Run `composer require baks-dev/products-product` along with its dependencies (`products-category`, `reference-money`, etc.). After installation, execute `php bin/console baks:assets:install` to set up configuration files and assets. Doctrine migrations are handled via `doctrine:migrations:diff` and `doctrine:migrations:migrate`.
- Does this package support multi-currency pricing for products?
- Yes, the package integrates with `reference-money` and `reference-currency` modules to handle multi-currency pricing. Products can be associated with currencies, and pricing logic is likely abstracted to support dynamic currency conversions. Check the `reference-money` documentation for advanced use cases.
- Can I extend product attributes (e.g., add custom fields like 'vendor' or 'reviews')?
- The package supports extensibility via traits and Laravel’s Eloquent relationships. For custom attributes, you can add new columns to the `products` table and extend the `Product` model with accessors/mutators. Traits or mixins can also be used to dynamically add behavior like reviews or vendor associations without forking.
- Are there performance concerns with large product catalogs (e.g., N+1 queries)?
- Yes, lazy-loading relationships (e.g., categories, measurements) can cause N+1 queries in listings. Mitigate this by using Eloquent’s `with()` or query scopes to eager-load related data. Profile performance with Laravel Debugbar or Blackfire and optimize with database indexing if needed.
- How do I test the product module in my Laravel application?
- Run the package’s built-in tests with `php bin/phpunit --group=products-product`. For integration testing, create custom test cases in your Laravel project to verify workflows like product creation, pricing updates, or category assignments. Use Laravel’s testing helpers (e.g., `actingAs`, `assertDatabaseHas`) for assertions.
- Is the package suitable for microservices, or is it monolith-focused?
- The package is modular and aligns with Laravel’s architecture, making it viable for both monolithic apps and microservices. For microservices, isolate the product domain by exposing its API via Laravel API resources or GraphQL (e.g., using `spatie/laravel-graphql`). Ensure proper dependency injection and service contracts for decoupling.
- What alternatives exist for product management in Laravel?
- Alternatives include `spatie/laravel-product`, `orchid/platform` (for admin panels), or `bagisto/core` (for full e-commerce). For lightweight solutions, consider `laravel-shop` or `filament/spatie-laravel-resource`. Evaluate based on features like multi-vendor support, inventory, or B2B/B2C workflows.
- How do I handle product assets (images, files) with this package?
- The package includes a `baks:assets:install` command to set up asset storage. Assets are likely stored in a filesystem (e.g., `storage/app/public`) or cloud (S3). Customize the `config/baks/products-product.php` file to adjust paths or use Laravel’s filesystem drivers for flexibility.
- Does the package support multi-tenancy (e.g., SaaS applications)?
- The package does not explicitly support multi-tenancy, but you can implement it by adding a `tenant_id` column to product tables and using middleware like `stancl/tenancy` or `spatie/laravel-multitenancy`. Test thoroughly to ensure tenant isolation in queries and migrations.