Created
August 28, 2023 16:54
-
-
Save chasecmiller/2b0a1dbfb9d92ad4cc66b1364db86726 to your computer and use it in GitHub Desktop.
Sharing resources between tenants in Filanent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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