Download the PHP package boss/laravel-district-access without Composer
On this page you can find all versions of the php package boss/laravel-district-access. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download boss/laravel-district-access
More information about boss/laravel-district-access
Files in boss/laravel-district-access
Package laravel-district-access
Short Description Configurable district-based query scoping and access control for Laravel applications.
License MIT
Informations about the package laravel-district-access
Laravel District Access
Configurable district-based query scoping and access control for Laravel applications.
Requirements
- PHP 8.1+
- Laravel 10, 11, 12, or 13
illuminate/contracts,illuminate/database, andilluminate/support
Installation
Laravel package discovery registers the service provider automatically.
Publish configuration:
Basic usage
The service returns the query unchanged for a configured super admin. For normal users it adds a whereIn for their allowed districts. By default, a normal user with no districts receives a query that can return no rows (1 = 0).
Configuration
The default configuration assumes a user property named district_role containing either a comma-separated string or an array. This is only a default: applications can replace the resolver callbacks.
For applications using a custom session-based user lookup, configure user_resolver in the application's published config instead of changing the package.
Dependency injection
Middleware
The package registers this middleware alias:
Use it on routes when the endpoint requires a resolved authenticated district-access user:
This middleware does not perform query filtering itself. It only ensures that the package can resolve an authenticated user. Query scoping should be explicitly applied to every relevant query.
Security model
This package follows deny-by-default behavior for normal users with no assigned districts. Super-admin behavior is delegated to the configurable resolver. Never rely on a controller-only filter if sensitive records can be accessed through another endpoint; apply the scope at every data access boundary or introduce your own repository/query abstraction.
Testing
Versioning
Use semantic version tags:
Do not add a version field to composer.json; Packagist detects package versions from VCS tags.
Publishing to Packagist
- Push this repository to a public GitHub repository.
- Run
composer validate --strict. - Create a release tag such as
v1.0.0. - Submit the public repository URL on Packagist.
- Packagist will crawl the repository and detect future VCS tags.
License
MIT.
All versions of laravel-district-access with dependencies
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0