<?php

namespace Database\Factories;

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

/** @extends Factory<Operator> */
class OperatorFactory extends Factory
{
    protected $model = Operator::class;

    public function definition(): array
    {
        return [
            'name' => $this->faker->name(),
            'email' => $this->faker->unique()->safeEmail(),
            'password' => 'passwort-fuer-tests',
        ];
    }

    /** Give the operator a console role. Roles are seeded by migration. */
    public function role(string $role = 'Owner'): static
    {
        return $this->afterCreating(fn (Operator $operator) => $operator->syncRoles([$role]));
    }
}
