Skip to content

Commit

Permalink
add User::factory() states for AccountTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
ProjektGopher committed Feb 14, 2022
1 parent 56ea978 commit 5c36e70
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
];
});
}
}

0 comments on commit 5c36e70

Please sign in to comment.