mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 21:14:03 +00:00
Merge branch 'master' into poly-sync
This commit is contained in:
commit
dc69a112eb
34 changed files with 231 additions and 125 deletions
|
|
@ -6,10 +6,29 @@ use Stancl\Tenancy\Middleware;
|
|||
use Stancl\Tenancy\Resolvers;
|
||||
|
||||
return [
|
||||
'tenant_model' => Stancl\Tenancy\Database\Models\Tenant::class,
|
||||
'domain_model' => Stancl\Tenancy\Database\Models\Domain::class,
|
||||
/**
|
||||
* Configuration for the models used by Tenancy.
|
||||
*/
|
||||
'models' => [
|
||||
'tenant' => Stancl\Tenancy\Database\Models\Tenant::class,
|
||||
'domain' => Stancl\Tenancy\Database\Models\Domain::class,
|
||||
|
||||
'id_generator' => Stancl\Tenancy\UUIDGenerator::class,
|
||||
/**
|
||||
* Name of the column used to relate models to tenants.
|
||||
*
|
||||
* This is used by the HasDomains trait, and models that use the BelongsToTenant trait (used in single-database tenancy).
|
||||
*/
|
||||
'tenant_key_column' => 'tenant_id',
|
||||
|
||||
/**
|
||||
* Used for generating tenant IDs.
|
||||
*
|
||||
* - Feel free to override this with a custom class that implements the UniqueIdentifierGenerator interface.
|
||||
* - To use autoincrement IDs, set this to null and update the `tenants` table migration to use an autoincrement column.
|
||||
* SECURITY NOTE: Keep in mind that autoincrement IDs come with *potential* enumeration issues (such as tenant storage URLs).
|
||||
*/
|
||||
'id_generator' => Stancl\Tenancy\UUIDGenerator::class,
|
||||
],
|
||||
|
||||
/**
|
||||
* The list of domains hosting your central app.
|
||||
|
|
@ -293,12 +312,4 @@ return [
|
|||
'--class' => 'Database\Seeders\DatabaseSeeder', // root seeder class
|
||||
// '--force' => true,
|
||||
],
|
||||
|
||||
/**
|
||||
* Single-database tenancy config.
|
||||
*/
|
||||
'single_db' => [
|
||||
/** The name of the column used by models with the BelongsToTenant trait. */
|
||||
'tenant_id_column' => 'tenant_id',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ declare(strict_types=1);
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
class CreateTenantUserImpersonationTokensTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -17,13 +18,13 @@ class CreateTenantUserImpersonationTokensTable extends Migration
|
|||
{
|
||||
Schema::create('tenant_user_impersonation_tokens', function (Blueprint $table) {
|
||||
$table->string('token', 128)->primary();
|
||||
$table->string('tenant_id');
|
||||
$table->string(Tenancy::tenantKeyColumn());
|
||||
$table->string('user_id');
|
||||
$table->string('auth_guard');
|
||||
$table->string('redirect_url');
|
||||
$table->timestamp('created_at');
|
||||
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->onUpdate('cascade')->onDelete('cascade');
|
||||
$table->foreign(Tenancy::tenantKeyColumn())->references('id')->on('tenants')->onUpdate('cascade')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -36,4 +37,4 @@ class CreateTenantUserImpersonationTokensTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('tenant_user_impersonation_tokens');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTenantsTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -34,4 +34,4 @@ class CreateTenantsTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ declare(strict_types=1);
|
|||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
|
||||
class CreateDomainsTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -18,10 +19,10 @@ class CreateDomainsTable extends Migration
|
|||
Schema::create('domains', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('domain', 255)->unique();
|
||||
$table->string('tenant_id');
|
||||
$table->string(Tenancy::tenantKeyColumn());
|
||||
|
||||
$table->timestamps();
|
||||
$table->foreign('tenant_id')->references('id')->on('tenants')->onUpdate('cascade');
|
||||
$table->foreign(Tenancy::tenantKeyColumn())->references('id')->on('tenants')->onUpdate('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -34,4 +35,4 @@ class CreateDomainsTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('domains');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Controllers\TenantAssetController;
|
||||
|
||||
// todo make this work with path identification
|
||||
Route::get('/tenancy/assets/{path?}', [TenantAssetController::class, 'asset'])
|
||||
->where('path', '(.*)')
|
||||
->name('stancl.tenancy.asset');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue