first commit
This commit is contained in:
49
database/factories/TeamFactory.php
Normal file
49
database/factories/TeamFactory.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Team;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Team>
|
||||
*/
|
||||
class TeamFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->company();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name),
|
||||
'is_personal' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the team is a personal team.
|
||||
*/
|
||||
public function personal(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'is_personal' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the team has been deleted.
|
||||
*/
|
||||
public function trashed(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'deleted_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user