app/Http/Controllers/Auth/RegisteredUserController.php
/**
     * Handle an incoming registration request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse
     *
     * @throws \Illuminate\Validation\ValidationException
     */
Handle an incoming registration request.


Handle an incoming registration request .
public function store(Request $request)
    {
        $request->validate([
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'confirmed', Rules\Password::defaults()],
        ]);
        $response = Http::withHeaders([
            'Accept'=>'application/json',
        ])->post('http://api.codersfree.test/v1/user/register',$request->all());
        if ($response->status() == 422) {
            return back()->withErrors($response->json()['errors']);
        }
        $service = $response->json();
        $user = User::create([
            'name' => $request->name,
            'email' => $request->email,
        ]);
        $this->getAccessToken($user,$service);
        event(new Registered($user));
        Auth::login($user);
        return redirect(RouteServiceProvider::HOME);
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => [ 'required' , 'string' , 'max:255' ] , 'email' => [ 'required' , 'string' , 'email' , 'max:255' , 'unique:users' ] , 'password' => [ 'required' , 'confirmed' , Rules \ Password :: defaults ( ) ] , ] ) ; $ response = Http :: withHeaders ( [ 'Accept' => 'application/json' , ] ) -> post ( 'http://api.codersfree.test/v1/user/register' , $ request -> all ( ) ) ; if ( $ response -> status ( ) == 422 ) { return back ( ) -> withErrors ( $ response -> json ( ) [ 'errors' ] ) ; } $ service = $ response -> json ( ) ; $ user = User :: create ( [ 'name' => $ request -> name , 'email' => $ request -> email , ] ) ; $ this -> getAccessToken ( $ user , $ service ) ; event ( new Registered ( $ user ) ) ; Auth :: login ( $ user ) ; return redirect ( RouteServiceProvider :: HOME ) ; }
Handle an incoming registration request.
Handle an incoming registration request .
//requiriendo token a api