- How do I install the permissions-for-laravel package?
- Install it with Composer using composer require roundly-consulting/permissions-for-laravel. Then complete the package setup described in its README, including any configuration publishing and migrations needed for roles and permissions tables. After that, run your application test suite to confirm the package's models and Gate integration work in your Laravel app.
- How do roles and permissions work in this package?
- Permissions are attached to roles, and roles are assigned to users. Authorization checks flow through Laravel's native Gate, so standard can checks, policies, and Blade @can directives remain consistent. This keeps role and permission logic separate from your existing application models.
- Does it work with Laravel Gate, can checks, and @can directives?
- Yes. The package is designed to integrate with Laravel's native Gate, so permission checks use familiar authorization patterns. You can rely on can checks in controllers and policies, plus @can directives in Blade templates. That means you do not need a separate authorization layer for role and permission checks.
- Can I customize the package's role and permission models and database tables?
- The package supports configurable models and tables so you can match your application's schema and naming conventions. This is useful when you need custom role or permission classes or want to align table names with existing conventions. Check the package configuration and tests after changes to ensure model resolution and relationships still work.
- How do I protect routes by role or permission?
- The package provides middleware for protecting routes by role or permission. Register or alias the middleware according to the README, then apply it to route groups or individual routes. This lets you enforce access rules before requests reach controllers while keeping checks consistent with Gate-based authorization.
- Which Laravel and PHP versions are supported?
- The provided context does not list exact Laravel and PHP version constraints. Validate compatibility against your application's Laravel and PHP versions and review the package's Composer requirements before upgrading. For production, test the package in development and staging with your actual framework versions.
- How does model swapping work with the package's factories?
- Version 1.0.2 fixes factory behavior so Laravel factories build the configured model when a host application swaps the package's default model. This supports host customization patterns such as white-labeling, multi-tenant variants, and downstream packages that replace base models. Confirm how your host declares the swapped model, whether through config, container binding, or subclassing, and test factories under both default and swapped-model scenarios.
- Is this package suitable for multi-tenant or white-label Laravel applications?
- It can fit those scenarios when you use the package's configurable models and container-friendly resolution. The 1.0.2 factory fix specifically improves support for host applications that replace the package's default models. Validate cached configuration and custom factory definitions after deployment, because stale config or hard-coded model references can break swapped-model behavior.
- How should I test roles and permissions in my Laravel application?
- Test both the default package models and any host-swapped models your application uses. Cover Gate checks, middleware-protected routes, and factory-created users, roles, and permissions. Run the suite in development and staging with representative configuration, and clear cached config when testing model swaps.
- What should I know before upgrading or choosing this package over alternatives?
- Version 1.0.2 is a patch-level factory fix with no indicated breaking changes, new APIs, or migrations, so upgrade by updating Composer, running tests, and checking default and swapped-model factories. Compared with heavier role and permission alternatives, this package is lightweight and centered on native Gate integration and configurable models. Choose it when those priorities match your app; otherwise evaluate alternatives for features like teams, admin UI, or guard-specific permissions.