mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:04:03 +00:00
Fix PHPStan errors
This commit is contained in:
parent
4f9147bf81
commit
3449f19748
2 changed files with 13 additions and 5 deletions
|
|
@ -4,10 +4,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Stancl\Tenancy\Bootstrappers\Integrations;
|
namespace Stancl\Tenancy\Bootstrappers\Integrations;
|
||||||
|
|
||||||
use Illuminate\Contracts\Config\Repository;
|
|
||||||
use Illuminate\Database\DatabaseManager;
|
|
||||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
|
||||||
use Stancl\Tenancy\Contracts\Tenant;
|
use Stancl\Tenancy\Contracts\Tenant;
|
||||||
|
use Illuminate\Database\DatabaseManager;
|
||||||
|
use Illuminate\Contracts\Config\Repository;
|
||||||
|
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||||
|
use Stancl\Tenancy\Database\Contracts\TenantWithDatabase;
|
||||||
|
|
||||||
class PostgresTenancyBootstrapper implements TenancyBootstrapper
|
class PostgresTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +25,7 @@ class PostgresTenancyBootstrapper implements TenancyBootstrapper
|
||||||
|
|
||||||
public function bootstrap(Tenant $tenant): void
|
public function bootstrap(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
|
/** @var TenantWithDatabase $tenant */
|
||||||
$this->database->purge('central');
|
$this->database->purge('central');
|
||||||
|
|
||||||
$this->config->set('database.connections.pgsql.username', $tenant->getTenantKey());
|
$this->config->set('database.connections.pgsql.username', $tenant->getTenantKey());
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class CreatePostgresUserForTenant implements ShouldQueue
|
||||||
DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';");
|
DB::statement("CREATE USER \"$name\" LOGIN PASSWORD '$password';");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->grantPermissions($name);
|
$this->grantPermissions((string) $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function grantPermissions(string $userName): void
|
protected function grantPermissions(string $userName): void
|
||||||
|
|
@ -53,7 +53,13 @@ class CreatePostgresUserForTenant implements ShouldQueue
|
||||||
* @var \Stancl\Tenancy\Database\Contracts\StatefulTenantDatabaseManager $databaseManager
|
* @var \Stancl\Tenancy\Database\Contracts\StatefulTenantDatabaseManager $databaseManager
|
||||||
*/
|
*/
|
||||||
$databaseManager = $this->tenant->database()->manager();
|
$databaseManager = $this->tenant->database()->manager();
|
||||||
foreach (array_map(fn (string $modelName) => (new $modelName), config('tenancy.models.rls')) as $model) {
|
|
||||||
|
/**
|
||||||
|
* @var Model[] $rlsModels
|
||||||
|
*/
|
||||||
|
$rlsModels = array_map(fn (string $modelName) => (new $modelName), config('tenancy.models.rls'));
|
||||||
|
|
||||||
|
foreach ($rlsModels as $model) {
|
||||||
$table = $model->getTable();
|
$table = $model->getTable();
|
||||||
|
|
||||||
$databaseManager->database()->statement("GRANT ALL ON {$table} TO \"{$userName}\"");
|
$databaseManager->database()->statement("GRANT ALL ON {$table} TO \"{$userName}\"");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue