Download the PHP package leek/filament-subtenant-scope without Composer

On this page you can find all versions of the php package leek/filament-subtenant-scope. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-subtenant-scope

Filament Subtenant Scope

Second-level tenancy for Filament panels. Adds a topnav dropdown that scopes every Eloquent query in the panel to a sub-tenant — service area, region, location, branch, department — without touching individual resources.

Filament's built-in tenancy gives you one tenant. This plugin adds another level on top: pick a sub-scope, and resources, widgets, navigation badges, and global search all auto-filter.

screenshot

Why

You already have multi-tenancy (e.g. Company). Inside each company you also need a soft filter — "show me only the North service area" — that:

This plugin does that with one trait + one ->scopes([...]) array.

Requirements

Installation

Styles

Tell your panel theme to compile the plugin's blade utility classes by adding a @source directive to the panel theme configured with ->viteTheme(...):

Then rebuild your app assets:

Without this, responsive utilities like hidden sm:inline used inside the dropdown won't be compiled into your panel CSS and the dropdown label may collapse on wide screens.

Register the plugin

Register the plugin on your panel and define one or more scopes:

That's the whole topnav setup. The dropdown renders next to the global search.

Opt resources into the scope

Add the HasSubtenantScopes trait and map each scope key to the FK column on the resource's model:

The plugin walks every resource in the panel during boot() and registers an Eloquent global scope on the model. Once any resource opts in, all queries on that model auto-filter — list pages, relation managers, navigation badges, widgets, global search.

Custom join logic

If the FK isn't on the model directly, pass null and define a static method named scopeSubTenant{Key}:

Behavior

Persistence

By default, selections persist for the session. To make them sticky across sessions/devices, register get/set callbacks. The classic pattern is a JSON column on users:

Resolution order: URL param → session → user storage. First non-null wins.

Customizing the dropdown

Render hook

Override where the dropdown renders:

Render the selector yourself

Disable the built-in render hook and embed the Livewire component anywhere:

Override the view

Publish and edit the dropdown blade:

Multiple scopes

Stack as many as you need. Each gets its own dropdown and storage key:

Resources can opt into one or both:

Listening for changes

The Livewire component dispatches sub-scope-changed after every selection (it also triggers a full page reload to refresh server-rendered scoped data):

Testing

How it works

  1. Plugin registers a render hook that pulls the dropdown into the topbar, scopes the manager request-singleton, and walks panel resources during boot() to attach Eloquent global scopes.
  2. Manager resolves the active selection per scope (URL → session → user storage), caches per request.
  3. Trait (HasSubtenantScopes) adds a panel-aware Eloquent global scope to the model. The scope is no-op outside the panel the plugin is registered on.
  4. Livewire selector renders one dropdown per registered scope, writes the selection through the manager, and reloads the page so server-rendered data picks up the new filter.

License

MIT. See LICENSE.md.


All versions of filament-subtenant-scope with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^4.0 || ^5.0
livewire/livewire Version ^3.0 || ^4.0
spatie/laravel-package-tools Version ^1.15
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package leek/filament-subtenant-scope contains the following files

Loading the files please wait ...