New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

experteam/api-laravel-base

Library to help with Laravel api Authentication
12,974
Install
composer require experteam/api-laravel-base
Latest Version:3.0.0
PHP:^8.3 || ^8.4
Laravel:10 – 13
Older releases:5 – 9
License:MIT
Last Updated:Oct 29, 2026
Links: GitHub  ·  Packagist
Maintainer: experteam-mx

API Laravel BASE

Base service providers to manage crud services
It includes:

  • Model paginate: Trait to manage pagination, it can manage limit, offset and order by.

Install

Run the following commands to install:

composer require experteam/api-laravel-base

Change the

Update

Run the composer command to update the package:

composer update experteam/api-laravel-base

Role scope

RoleScope restricts queries to the data the active role may see. The scope comes from the token role and its validated session, never from request parameters. The hierarchy is read from the companies.companyCountry, companies.location and companies.installation Redis hashes.

Each model declares its organizational columns, as a list or as a map from field to column:

public array $roleScope = ['country_id', 'company_country_id', 'location_id', 'installation_id'];
public array $roleScope = ['location_id' => 'check_in_operation_location_id'];
public array $roleScope = [];

An empty array marks data without organizational owner. A model without the property, with an unknown field, or without any column the level can use, fails with AuthorizationException. Installation filters by the session location when the model does not declare installation_id. The levels above resolve through the Redis hierarchy when the model lacks their own column.

RoleScope::current()->apply(Shipment::query());
RoleScope::current()->constrain($match, Payment::class);
RoleScope::current()->authorize($request->only(['country_id', 'location_id', 'installation_id']));

apply() wraps the previous filters in a group and adds the conditions after them. Apply it last. Global roles and AppKey calls without a role are not restricted.

allows() and authorize() check filters: an id passes when its subtree intersects the scope, and a company_id is rejected. In writes, take ownership from the session.

Every queued job starts without a scope. A job sets its own and restores the previous one:

$previous = RoleScope::swap(RoleScope::fromSnapshot($role, $session));

try {
    $this->export();
} finally {
    RoleScope::swap($previous);
}

License

MIT license.

Related Packages

experteam/api-laravel-crud

Library to help with Laravel api CRUDs definition

12,964 0
kilroyweb/cruddy

Laravel CRUD Helper

23 1
orchid/crud

Build CRUD apps in fewer lines of code for Laravel Orchid.

1,561,174 149
mwi/laravel-crud

MWI Crud setup for Laravel Projects

8,540 1
technote/laravel-crud-helper

CRUD helper for laravel

2,429 1

Version History

Version Released PHP Laravel License
3.0.0 ^8.3 || ^8.4 ^10.0 || ^11.0 || ^12.0 || ^13.0 MIT
2.4.0 ^8.1 || ^8.2 || ^8.3 ^9.0 || ^10.0 || ^11.0 || ^12.0 MIT
2.3.1 ^8.1 || ^8.2 || ^8.3 ^9.0 || ^10.0 || ^11.0 || ^12.0 MIT
2.3.0 ^8.1 || ^8.2 || ^8.3 ^9.0 || ^10.0 || ^11.0 || ^12.0 MIT
2.2.1 ^8.1 || ^8.2 ^9.0 || ^10.0 || ^11.0 MIT