Skip to content

Commit

Permalink
factory changes
Browse files Browse the repository at this point in the history
  • Loading branch information
romo4ko committed Oct 27, 2024
1 parent 3364719 commit d2d1f18
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ TELEGRAM_BOT_TOKEN=
TELEGRAM_SECRET_KEY=

FRONTEND_URL=https://localhost:3000

ADMIN_LOGIN=
ADMIN_PASSWORD=
4 changes: 2 additions & 2 deletions database/factories/ChallengeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function definition(): array
$now = Carbon::now();

return [
'name' => fake()->text(20),
'description' => fake()->text(),
'name' => $this->faker->realText(20),
'description' => $this->faker->realText(),
'start_date' => $now,
'end_date' => $now->addDays(rand(1, 30)),
'achievement_id' => Achievement::query()->inRandomOrder()->first(),
Expand Down
10 changes: 1 addition & 9 deletions database/factories/TeamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Team>
*/
class TeamFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
protected $model = Team::class;

public function definition(): array
{
return [
'name' => $this->faker->company,
'description' => $this->faker->sentence,
'captain_id' => User::query()->first()->id,
'captain_id' => User::query()->inRandomOrder()->first()->id,
];
}
}
21 changes: 6 additions & 15 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,24 @@
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$gender = $this->faker->randomElement(['male', 'female']);

return [
'name' => fake()->name(),
'surname' => fake()->lastName(),
'about' => fake()->text(),
'name' => $this->faker->firstName($gender),
'surname' => $this->faker->lastName($gender),
'about' => $this->faker->realText(),
'is_confirmed' => true,
'email' => fake()->unique()->safeEmail(),
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => Hash::make('password'),
'remember_token' => Str::random(10),
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
Expand Down
4 changes: 3 additions & 1 deletion database/seeders/UsersSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class UsersSeeder extends Seeder
{
Expand All @@ -15,7 +16,8 @@ public function run(): void

User::factory()->create([
'name' => 'Admin',
'email' => '[email protected]',
'email' => env('ADMIN_LOGIN'),
'password' => Hash::make(env('ADMIN_PASSWORD')),
'is_admin' => true,
]);
}
Expand Down

0 comments on commit d2d1f18

Please sign in to comment.