PHP code example of leek / filament-subtenant-scope
1. Go to this page and download the library: Download leek/filament-subtenant-scope library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
leek / filament-subtenant-scope example snippets
use Filament\Panel;
use Leek\FilamentSubtenantScope\SubtenantScope;
use Leek\FilamentSubtenantScope\SubtenantScopingPlugin;
use App\Models\ServiceArea;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(
SubtenantScopingPlugin::make()
->scopes([
SubtenantScope::make('service_area', 'Service Area', ServiceArea::class, 'service_area_id')
->icon('heroicon-o-map-pin')
->labelAttribute('name')
->optionsQuery(fn ($user) => ServiceArea::query()
->where('company_id', $user->company_id)
->where('is_active', true)
->orderBy('name')),
]),
);
}