Spatie Integration
Scoutify provides first-class support for spatie/laravel-permission to define visibility rules based on roles and permissions.
Optional Dependency
Section titled “Optional Dependency”Spatie is an optional dependency. You must install it to use the role and permission rules:
composer require spatie/laravel-permissionDetection Mechanism
Section titled “Detection Mechanism”Scoutify uses method_exists to detect if your User model supports Spatie methods. It never imports Spatie classes directly, ensuring your application remains lightweight if you don’t use it.
permission() Rule
Section titled “permission() Rule”Grant visibility to users with specific permissions:
// Single permission->permission('view-articles')
// Multiple permissions (logical OR)->permission(['edit-articles', 'view-articles'])role() Rule
Section titled “role() Rule”Grant visibility to users with specific roles:
// Single role->role('admin')
// Multiple roles (logical OR)->role(['manager', 'editor'])Limitations
Section titled “Limitations”- Wildcard permissions are supported only if your Spatie configuration has them enabled.
- The rule must match the Spatie guard configured for your application.
- Scoutify fails closed (denies access) if Spatie methods are missing when these rules are evaluated.