Skip to content

Commit

Permalink
Add factories and seeders
Browse files Browse the repository at this point in the history
  • Loading branch information
lancepioch committed Jul 20, 2023
1 parent e3fc0f9 commit dbe05dc
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 6 deletions.
29 changes: 29 additions & 0 deletions database/factories/BoardFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Factories;

use App\Models\Board;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;

class BoardFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Board::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'project_id' => \App\Models\Project::factory(),
];
}
}
29 changes: 29 additions & 0 deletions database/factories/CommentFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Factories;

use App\Models\Comment;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;

class CommentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Comment::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'task_id' => \App\Models\Task::factory(),
];
}
}
29 changes: 29 additions & 0 deletions database/factories/ProjectFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Factories;

use App\Models\Project;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;

class ProjectFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Project::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'team_id' => \App\Models\Team::factory(),
];
}
}
29 changes: 29 additions & 0 deletions database/factories/SprintFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Factories;

use App\Models\Sprint;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;

class SprintFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Sprint::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'project_id' => \App\Models\Project::factory(),
];
}
}
29 changes: 29 additions & 0 deletions database/factories/TaskFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Factories;

use App\Models\Task;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Factories\Factory;

class TaskFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Task::class;

/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'project_id' => \App\Models\Project::factory(),
];
}
}
19 changes: 19 additions & 0 deletions database/seeders/BoardSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Board;
use Illuminate\Database\Seeder;

class BoardSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Board::factory()
->count(5)
->create();
}
}
19 changes: 19 additions & 0 deletions database/seeders/CommentSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Comment;
use Illuminate\Database\Seeder;

class CommentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Comment::factory()
->count(5)
->create();
}
}
20 changes: 14 additions & 6 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Database\Seeders;

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

class DatabaseSeeder extends Seeder
Expand All @@ -12,11 +11,20 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// \App\Models\User::factory(10)->create();
// Adding an admin user
$user = \App\Models\User::factory()
->count(1)
->create([
'email' => '[email protected]',
'password' => \Hash::make('admin'),
]);

// \App\Models\User::factory()->create([
// 'name' => 'Test User',
// 'email' => '[email protected]',
// ]);
$this->call(BoardSeeder::class);
$this->call(CommentSeeder::class);
$this->call(ProjectSeeder::class);
$this->call(SprintSeeder::class);
$this->call(TaskSeeder::class);
$this->call(TeamSeeder::class);
$this->call(UserSeeder::class);
}
}
19 changes: 19 additions & 0 deletions database/seeders/ProjectSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Project;
use Illuminate\Database\Seeder;

class ProjectSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Project::factory()
->count(5)
->create();
}
}
19 changes: 19 additions & 0 deletions database/seeders/SprintSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Sprint;
use Illuminate\Database\Seeder;

class SprintSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Sprint::factory()
->count(5)
->create();
}
}
19 changes: 19 additions & 0 deletions database/seeders/TaskSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Task;
use Illuminate\Database\Seeder;

class TaskSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Task::factory()
->count(5)
->create();
}
}
19 changes: 19 additions & 0 deletions database/seeders/TeamSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\Team;
use Illuminate\Database\Seeder;

class TeamSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Team::factory()
->count(5)
->create();
}
}
19 changes: 19 additions & 0 deletions database/seeders/UserSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Database\Seeders;

use App\Models\User;
use Illuminate\Database\Seeder;

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

0 comments on commit dbe05dc

Please sign in to comment.