<?php

namespace Database\Factories;

use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;

class CategoryFactory extends Factory
{
    public function definition(): array
    {
        return [
            'name' => $this->faker->unique()->name(),
            'slug' => $this->faker->slug(),
            'description' => $this->faker->optional()->text(),
            'sort_order' => function () {
                $max = Category::max('sort_order') ?? 0;

                return $max + 1;
            },
        ];
    }
}
