Files

64 lines
1.4 KiB
PHP
Raw Permalink Normal View History

<?php
namespace Database\Factories;
use App\Models\Project;
use Illuminate\Database\Eloquent\Factories\Factory;
class ProjectFactory extends Factory
{
protected $model = Project::class;
public function definition(): array
{
return [
'name' => fake()->words(2, true),
'description' => fake()->optional()->paragraph(),
'status' => fake()->randomElement(Project::STATUSES),
'due_at' => fake()->optional()->dateTimeBetween('now', '+1 year'),
];
}
public function active(): static
{
return $this->state(fn () => [
'status' => 'active',
]);
}
public function completed(): static
{
return $this->state(fn () => [
'status' => 'completed',
]);
}
public function archived(): static
{
return $this->state(fn () => [
'status' => 'archived',
]);
}
public function onHold(): static
{
return $this->state(fn () => [
'status' => 'on_hold',
]);
}
public function planned(): static
{
return $this->state(fn () => [
'status' => 'planned',
]);
}
public function withDueDate(): static
{
return $this->state(fn () => [
'due_at' => fake()->dateTimeBetween('now', '+1 year'),
]);
}
}