- How do I install and set up the BaksDev Product Category package in Laravel?
- Run `composer require baks-dev/products-category`, then execute `php bin/console baks:assets:install` to set up assets. Create the upload directory with `mkdir -p public/upload/product_category_cover` and set permissions to `773`. Finally, run Doctrine migrations with `php bin/console doctrine:migrations:migrate`.
- Does this package support Laravel 10 or 11? What’s the latest compatible version?
- The package is officially tested for Laravel 7.4.7 but may work with LTS versions like 8.x/9.x. Check for PHP 8.4+ compatibility and test migrations in a staging environment. For Laravel 10/11, verify Doctrine DBAL and Symfony Console dependencies align with your stack.
- Can I customize category access control (e.g., admin-only CRUD) with this package?
- The package doesn’t include built-in RBAC, but you can integrate Laravel’s built-in authorization (e.g., Gates/Policies) or use packages like Spatie’s Laravel-Permission. Bind custom logic via service container or extend the `Category` model with middleware or traits.
- How are category cover uploads handled? Can I use S3 or other storage drivers?
- Covers are stored locally by default in `public/upload/product_category_cover`. To switch to S3, override the `Storage` facade binding in your service provider or configure Laravel’s filesystem disk settings. Validate uploads (size, MIME types) via Laravel’s `File` validation rules or custom logic in the `CoverUploaded` event.
- Are there performance risks with large category hierarchies (e.g., N+1 queries)?
- The package uses Doctrine ORM, which may generate N+1 queries for nested categories. Mitigate this by eager-loading relationships (e.g., `with('children')`) in your queries or implementing lazy-loading with custom repository methods. Test with your expected hierarchy depth.
- Does the package support multilingual category names or translations?
- The package doesn’t include built-in localization, but you can extend it using Laravel’s localization features (e.g., `trans()` helpers) or packages like Laravel Localization. Store translations in a `localizations` table or use JSON fields for category metadata.
- How do I test the package’s functionality in my Laravel app?
- Run `php bin/phpunit --group=products-category` to execute the package’s built-in tests. For integration testing, mock the `Category` model and cover uploads in your test suite. Use Laravel’s HTTP tests to verify API endpoints or Blade views if applicable.
- What if my project already has a `Category` model or migrations? Will this cause conflicts?
- Yes, naming conflicts (e.g., `Category` model or `product_category_cover` table) may occur. Review the package’s migrations with `php bin/console doctrine:migrations:diff` and merge manually. Use `composer why-not` to check dependency conflicts and rename existing models/tables as needed.
- Can I extend the package to add API endpoints or search functionality?
- Absolutely. The package is modular and can be extended via Laravel’s service container. Add API routes in `routes/api.php`, create custom controllers, or use Laravel Scout for search. Override views or publish assets with `php artisan vendor:publish --tag=products-category-views`.
- Is there English documentation, or is the README only in Russian?
- The primary documentation is in Russian, but the package follows Laravel conventions, so you can infer usage from the codebase (e.g., migrations, console commands). For critical setup steps, translate key commands (e.g., `baks:assets:install`) or check the source code for undocumented assumptions. Consider contributing translations to the GitHub repo.