Laravel

Rate Limiter custom login/reg

how to add custom rate limiter using id to secure login registration in livewire here my code

<?php

namespace App\Livewire;

use Livewire\Component;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
use App\Jobs\SendOtpEmailJob;
use Illuminate\Support\Str;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class RegisterComponent extends Component
{
    public $name, $email, $password;
    public $otp, $otp_expires_at;

    protected $rules = [
        'name' => 'required|min:4',
        'email' => 'required|email|unique:users,email',
        'password' => 'required|min:6',
    ];

    public function updated($propertyName)
    {
        $this->validateOnly($propertyName);
    }

    public function register()
    {
        $this->validate();

        // Generate a 4-digit OTP and expiration
        $this->otp = rand(1000, 9999);
        $this->otp_expires_at = now()->addMinutes(5);

        // Create user with OTP details
        $user = User::create([
            'name' => $this->name,
            'email' => $this->email,
            'password' => Hash::make($this->password),
            'otp' => $this->otp,
            'otp_expires_at' => $this->otp_expires_at,
        ]);

        // Automatically log in the user
        Auth::login($user); // Log in the user

        // Dispatch email OTP job
        dispatch(new SendOtpEmailJob($user));

        // Redirect to OTP verification page
        session()->flash('otp_message', 'OTP sent successfully. Please verify your email.');
        return redirect()->route('otp.verify');
    }

    public function render()
    {
        return view('livewire.register-component');
    }
}
wees377
wees377
0
0
95