Renamed jetstream team to organization

This commit is contained in:
Constantin Graf
2024-01-21 19:52:19 +01:00
parent 6377df1f44
commit 0a8d958ccc
63 changed files with 461 additions and 329 deletions

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Client;
use App\Models\Team;
use App\Models\Organization;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -22,11 +22,11 @@ class ClientFactory extends Factory
{
return [
'name' => $this->faker->company(),
'organization_id' => Team::factory(),
'organization_id' => Organization::factory(),
];
}
public function forOrganization(Team $organization): self
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {
return [

View File

@@ -4,13 +4,14 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Team>
* @extends Factory<Organization>
*/
class TeamFactory extends Factory
class OrganizationFactory extends Factory
{
/**
* Define the model's default state.

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Client;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Team;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -24,12 +24,12 @@ class ProjectFactory extends Factory
return [
'name' => $this->faker->company(),
'color' => $this->faker->hexColor(),
'organization_id' => Team::factory(),
'organization_id' => Organization::factory(),
'client_id' => null,
];
}
public function forOrganization(Team $organization): self
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {
return [

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Organization;
use App\Models\Tag;
use App\Models\Team;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -22,11 +22,11 @@ class TagFactory extends Factory
{
return [
'name' => $this->faker->name,
'organization_id' => Team::factory(),
'organization_id' => Organization::factory(),
];
}
public function forOrganization(Team $organization): self
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {
return [

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Task;
use App\Models\Team;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
@@ -24,7 +24,7 @@ class TaskFactory extends Factory
return [
'name' => $this->faker->word(),
'project_id' => Project::factory(),
'organization_id' => Team::factory(),
'organization_id' => Organization::factory(),
];
}
@@ -37,7 +37,7 @@ class TaskFactory extends Factory
});
}
public function forOrganization(Team $organization): self
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {
return [

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Task;
use App\Models\Team;
use App\Models\TimeEntry;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
@@ -32,7 +32,7 @@ class TimeEntryFactory extends Factory
'billable' => $this->faker->boolean(),
'tags' => [],
'user_id' => User::factory(),
'organization_id' => Team::factory(),
'organization_id' => Organization::factory(),
];
}
@@ -45,7 +45,7 @@ class TimeEntryFactory extends Factory
});
}
public function forOrganization(Team $organization): self
public function forOrganization(Organization $organization): self
{
return $this->state(function (array $attributes) use ($organization) {
return [

View File

@@ -4,14 +4,13 @@ declare(strict_types=1);
namespace Database\Factories;
use App\Models\Team;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Laravel\Jetstream\Features;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
* @extends Factory<User>
*/
class UserFactory extends Factory
{
@@ -50,16 +49,12 @@ class UserFactory extends Factory
/**
* Indicate that the user should have a personal team.
*/
public function withPersonalTeam(?callable $callback = null): static
public function withPersonalOrganization(?callable $callback = null): static
{
if (! Features::hasTeamFeatures()) {
return $this->state([]);
}
return $this->has(
Team::factory()
Organization::factory()
->state(fn (array $attributes, User $user) => [
'name' => $user->name.'\'s Team',
'name' => $user->name.'\'s Organization',
'user_id' => $user->id,
'personal_team' => true,
])

View File

@@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('teams', function (Blueprint $table) {
Schema::create('organizations', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('user_id')->index();
$table->string('name');

View File

@@ -13,14 +13,14 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('team_user', function (Blueprint $table) {
Schema::create('organization_user', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('team_id');
$table->foreignUuid('organization_id');
$table->foreignUuid('user_id');
$table->string('role')->nullable();
$table->timestamps();
$table->unique(['team_id', 'user_id']);
$table->unique(['organization_id', 'user_id']);
});
}

View File

@@ -13,16 +13,16 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('team_invitations', function (Blueprint $table) {
Schema::create('organization_invitations', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignUuid('team_id')
$table->foreignUuid('organization_id')
->constrained()
->cascadeOnDelete();
$table->string('email');
$table->string('role')->nullable();
$table->timestamps();
$table->unique(['team_id', 'email']);
$table->unique(['organization_id', 'email']);
});
}

View File

@@ -19,7 +19,7 @@ return new class extends Migration
$table->uuid('organization_id');
$table->foreign('organization_id')
->references('id')
->on('teams')
->on('organizations')
->cascadeOnUpdate()
->restrictOnDelete();
$table->timestamps();

View File

@@ -26,7 +26,7 @@ return new class extends Migration
$table->uuid('organization_id');
$table->foreign('organization_id')
->references('id')
->on('teams')
->on('organizations')
->cascadeOnUpdate()
->restrictOnDelete();
$table->timestamps();

View File

@@ -25,7 +25,7 @@ return new class extends Migration
$table->uuid('organization_id');
$table->foreign('organization_id')
->references('id')
->on('teams')
->on('organizations')
->cascadeOnUpdate()
->restrictOnDelete();
$table->timestamps();

View File

@@ -19,7 +19,7 @@ return new class extends Migration
$table->uuid('organization_id');
$table->foreign('organization_id')
->references('id')
->on('teams')
->on('organizations')
->cascadeOnUpdate()
->restrictOnDelete();
$table->timestamps();

View File

@@ -28,7 +28,7 @@ return new class extends Migration
$table->uuid('organization_id');
$table->foreign('organization_id')
->references('id')
->on('teams')
->on('organizations')
->cascadeOnUpdate()
->restrictOnDelete();
$table->uuid('project_id')->nullable();

View File

@@ -6,9 +6,9 @@ namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\Client;
use App\Models\Organization;
use App\Models\Project;
use App\Models\Task;
use App\Models\Team;
use App\Models\TimeEntry;
use App\Models\User;
use Illuminate\Database\Seeder;
@@ -22,14 +22,23 @@ class DatabaseSeeder extends Seeder
public function run(): void
{
$this->deleteAll();
$organization = Team::factory()->create([
$organization = Organization::factory()->create([
'name' => 'ACME Corp',
]);
$user1 = User::factory()->withPersonalTeam()->create([
$user1 = User::factory()->withPersonalOrganization()->create([
'name' => 'Test User',
'email' => 'test@example.com',
]);
$user1->teams()->attach($organization);
$userAcmeAdmin = User::factory()->create([
'name' => 'ACME Admin',
'email' => 'admin@acme.test',
]);
$user1->organizations()->attach($organization, [
'role' => 'editor',
]);
$userAcmeAdmin->organizations()->attach($organization, [
'role' => 'admin',
]);
$client = Client::factory()->create([
'name' => 'Big Company',
]);
@@ -50,6 +59,6 @@ class DatabaseSeeder extends Seeder
DB::table((new Project())->getTable())->delete();
DB::table((new Client())->getTable())->delete();
DB::table((new User())->getTable())->delete();
DB::table((new Team())->getTable())->delete();
DB::table((new Organization())->getTable())->delete();
}
}