26 lines
591 B
PHP
26 lines
591 B
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Category;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
class CategoryFactory extends Factory
|
|
{
|
|
protected $model = Category::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'name' => $this->faker->unique()->company(),
|
|
'slug' => $this->faker->slug(),
|
|
'description' => $this->faker->optional()->text(),
|
|
'sort_order' => function () {
|
|
$max = Category::max('sort_order') ?? 0;
|
|
|
|
return $max + 1;
|
|
},
|
|
];
|
|
}
|
|
}
|