app/Http/Controllers/User/UserController.php
// registra o crea un usuario y crea el token (store)
registra o crea un usuario y crea el token (store)
registra o crea un usuario y crea el token ( store )
public function store(Request $request)
    {
        $validated =  $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|string|email|max:255|unique:users',
            'password' => 'required|string|min:6|confirmed',
        ]);
        $user = User::create([
            'name' => $request->get('name'),
            'email' => $request->get('email'),
            'password' => Hash::make($request->get('password')),
            'verified' => User::USUARIO_NO_VERIFICADO,
            'verification_token' => User::generarVerificationToken()
        ]);
        $userR = new UserResource($user);
        return $this->showOne($userR,201);
    }
public function store ( Request $ request ) { $ validated = $ request -> validate ( [ 'name' => 'required|string|max:255' , 'email' => 'required|string|email|max:255|unique:users' , 'password' => 'required|string|min:6|confirmed' , ] ) ; $ user = User :: create ( [ 'name' => $ request -> get ( 'name' ) , 'email' => $ request -> get ( 'email' ) , 'password' => Hash :: make ( $ request -> get ( 'password' ) ) , 'verified' => User :: USUARIO_NO_VERIFICADO , 'verification_token' => User :: generarVerificationToken ( ) ] ) ; $ userR = new UserResource ( $ user ) ; return $ this -> showOne ( $ userR , 201 ) ; }
registra o crea un usuario y crea el token (store)
registra o crea un usuario y crea el token ( store )
// si hay un error laravel envia automarticamente // $token = JWTAuth::fromUser($user);