From 5c36e70cb11658dab054bd36a8a0b4a3178ea71f Mon Sep 17 00:00:00 2001 From: Len Woodward Date: Mon, 14 Feb 2022 00:57:16 -0800 Subject: [PATCH] add User::factory() states for AccountTypes --- database/factories/UserFactory.php | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index c43ec40..046b394 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -4,9 +4,10 @@ use App\Models\Team; use App\Models\User; -use Illuminate\Database\Eloquent\Factories\Factory; +use App\Models\AccountType; use Illuminate\Support\Str; use Laravel\Jetstream\Features; +use Illuminate\Database\Eloquent\Factories\Factory; class UserFactory extends Factory { @@ -83,4 +84,40 @@ public function withTwitter() ]; }); } + + public function withFreeAccount() + { + return $this->state(function (array $attributes) { + return [ + 'account_type' => AccountType::FREE, + ]; + }); + } + + public function withPaidAccount() + { + return $this->state(function (array $attributes) { + return [ + 'account_type' => AccountType::PAID, + ]; + }); + } + + public function withSponsorAccount() + { + return $this->state(function (array $attributes) { + return [ + 'account_type' => AccountType::SPONSOR, + ]; + }); + } + + public function withAdminAccount() + { + return $this->state(function (array $attributes) { + return [ + 'account_type' => AccountType::ADMIN, + ]; + }); + } }