<?php

namespace Database\Factories;

use App\Models\Foto;
use App\Models\Servicio;
use App\Models\Profesion;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\DB;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Servicio>
 */
class ServicioFactory extends Factory
{
    /**
     * The name of the factory's corresponding model.
     *
     * @var string
     */
    protected $model = Servicio::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $fotoDefault = Foto::firstOrCreate(
            ['ruta' => 'images/Servicio.jpg'],
            [
                'extension'     => 'jpg',
                'tamanio_bytes' => 0,
                'nombre'        => 'Servicio',
                'mime_type'     => 'image/jpeg',
            ]
        );

        return [
            'titulo'          => $this->faker->unique()->bs(),
            'estado'          => 'activo',
            'descripcion'     => $this->faker->sentence(12),
            'visibleenweb'    => 'si',
            'contenidoweb_id' => DB::table('contenidoswebs')->value('id'),
            'profesion_id'    => Profesion::factory(),
            'foto_id'         => $fotoDefault->id,
        ];
    }
}
