Skip to content

Commit

Permalink
Добавлен TeamSeeder
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrignatushin committed Oct 26, 2024
1 parent f8554be commit dd54b23
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
28 changes: 28 additions & 0 deletions database/factories/TeamFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Database\Factories;

use App\Models\Team;
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,
'code' => strtoupper($this->faker->unique()->lexify('??###')),
];
}
}
12 changes: 6 additions & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Database\Seeders;

use App\Models\User;

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

Expand All @@ -15,11 +16,10 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();

User::factory()->create([
'name' => 'Test User',
'email' => '[email protected]',
]);
$this->call(
[
TeamsSeeder::class
]
);
}
}
18 changes: 18 additions & 0 deletions database/seeders/TeamsSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Database\Seeders;

use App\Models\Team;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class TeamsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Team::factory()->count(5)->create();
}
}

0 comments on commit dd54b23

Please sign in to comment.