Remove hard-coded manager_id in factory

This commit is contained in:
Marcus Moore 2023-03-16 12:46:47 -07:00
parent 7062b0acaa
commit 76861c0c30
No known key found for this signature in database

View file

@ -3,6 +3,7 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\Company; use App\Models\Company;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use \Auth; use \Auth;
@ -79,7 +80,9 @@ class UserFactory extends Factory
return $this->state(function () { return $this->state(function () {
return [ return [
'permissions' => '{"admin":"1"}', 'permissions' => '{"admin":"1"}',
'manager_id' => rand(1, 2), 'manager_id' => function () {
return User::where('permissions->superuser', '1')->first() ?? User::factory()->firstAdmin();
},
]; ];
}); });
} }