wowowowowo
This commit is contained in:
32
database/factories/OrganisationInvitationFactory.php
Normal file
32
database/factories/OrganisationInvitationFactory.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\OrganisationRole;
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OrganisationInvitation>
|
||||
*/
|
||||
class OrganisationInvitationFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'organisation_id' => Organisation::factory(),
|
||||
'invited_by_user_id' => User::factory(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'role' => OrganisationRole::MEMBER,
|
||||
'token' => Str::random(40),
|
||||
'expires_at' => now()->addDays(14),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->foreignId('source_provider_id')
|
||||
->nullable()
|
||||
->after('organisation_id')
|
||||
->constrained('source_providers')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('applications', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('source_provider_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Organisation;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('organisation_invitations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignIdFor(Organisation::class)->constrained()->cascadeOnDelete();
|
||||
$table->foreignIdFor(User::class, 'invited_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->string('email');
|
||||
$table->string('role');
|
||||
$table->string('token')->unique();
|
||||
$table->timestamp('accepted_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['organisation_id', 'email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('organisation_invitations');
|
||||
}
|
||||
};
|
||||
@@ -65,7 +65,6 @@ class DatabaseSeeder extends Seeder
|
||||
$application->environments()->create([
|
||||
'name' => 'Dev',
|
||||
'branch' => 'main',
|
||||
'url' => 'https://dev.clipbin.hjb.dev',
|
||||
'status' => 'active',
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user