This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\OrganizationRole;
|
||||
use App\WorkspaceType;
|
||||
@@ -61,6 +62,20 @@ class OrganizationFactory extends Factory
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the organization the plan with the given key.
|
||||
*/
|
||||
public function withPlan(string $key): static
|
||||
{
|
||||
return $this->afterCreating(function (Organization $organization) use ($key): void {
|
||||
$planId = Plan::query()->where('key', $key)->value('id');
|
||||
|
||||
if ($planId !== null) {
|
||||
$organization->forceFill(['plan_id' => $planId])->save();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given user to the organization with the given role.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user