From 76861c0c30a154a01db06c188d82f12daeed3030 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 16 Mar 2023 12:46:47 -0700 Subject: [PATCH] Remove hard-coded manager_id in factory --- database/factories/UserFactory.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 91881d2b2d..c99354648c 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -3,6 +3,7 @@ namespace Database\Factories; use App\Models\Company; +use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use \Auth; @@ -79,7 +80,9 @@ class UserFactory extends Factory return $this->state(function () { return [ 'permissions' => '{"admin":"1"}', - 'manager_id' => rand(1, 2), + 'manager_id' => function () { + return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin(); + }, ]; }); }