Assign the existing site to one landlord so stommer.info can run tenancy.
Seebad 0.3 stays in this release. With a single landlord every host still reaches the default website. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d9e52c4789
commit
8ebc1a3878
93 files changed
+2506
-112
No files matched your search
@@ -36,6 +36,16 @@ public function definition(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (Booking $booking): void {
|
||||
Guest::withoutGlobalScope('tenant')
|
||||
->whereKey($booking->guest_id)
|
||||
->where('tenant_id', '!=', $booking->tenant_id)
|
||||
->update(['tenant_id' => $booking->tenant_id]);
|
||||
});
|
||||
}
|
||||
|
||||
public function reserved(?\DateTimeInterface $holdExpiresAt = null): static
|
||||
{
|
||||
return $this->state(fn (): array => [
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Tenant>
|
||||
*/
|
||||
class TenantFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->company();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)),
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -18,6 +20,22 @@ class UserFactory extends Factory
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (User $user): void {
|
||||
if ($user->role === null || app(TenantContext::class)->id() !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tenant = Tenant::query()->count() === 1
|
||||
? Tenant::query()->firstOrFail()
|
||||
: Tenant::factory()->create();
|
||||
|
||||
app(TenantContext::class)->set($tenant);
|
||||
$user->attachCurrentRole($tenant);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user