<?php

namespace App\DataFixtures;

use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;

class UserFixtures extends Fixture
{
    private UserPasswordHasherInterface $passwordHasher;


    public function __construct (UserPasswordHasherInterface $passwordHasher)
    {
        $this->passwordHasher = $passwordHasher;
    }


    public function load (ObjectManager $manager)
    {
        $admin = new User();
        $admin->setName('Administrador');
        $admin->setRoles(['ROLE_ADMIN']);
        $admin->setPhone('0000000');
        $admin->setIsActive(true);
        $admin->setEmail('admin@admin.com');
        $admin->setPassword($this->passwordHasher->hashPassword($admin, '1234'));

        $manager->persist($admin);
        $manager->flush();
    }
}
