Skip to content

Instantly share code, notes, and snippets.

@chasecmiller
Created August 28, 2023 16:54
Show Gist options
  • Save chasecmiller/2b0a1dbfb9d92ad4cc66b1364db86726 to your computer and use it in GitHub Desktop.
Save chasecmiller/2b0a1dbfb9d92ad4cc66b1364db86726 to your computer and use it in GitHub Desktop.
Sharing resources between tenants in Filanent.
/**
* On your resource, you need to override the getEloquentQuery method. Here is the original:
**/
public static function getEloquentQuery(): Builder {
$query = static::getModel()::query();
if ($tenant = Filament::getTenant()) {
static::scopeEloquentQueryToTenant($query, $tenant);
}
return $query;
}
/**
* Strip out the $tenant scope and it will allow the resource to be listed between all tenants.
**/
public static function getEloquentQuery(): Builder {
$query = static::getModel()::query();
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment