FareedR
1 week ago
182
10
Laravel

How can I use this as a helper?

Posted 1 week ago by FareedR

I got an error "Call to undefined function App\loginIdExists()" anyone can show the right method ?

public static function generateLoginId() {
        $number = mt_rand(1000000000, 9999999999); // better than rand()
    
        // call the same function if the barcode exists already
        if (loginIdExists($number)) {
            return generateLoginId();
        }
        // otherwise, it's valid and can be used
        return $number;
    }
    
    public static function loginIdExists($number) {
        // query the database and return a boolean
        // for instance, it might look like this in Laravel
        $concated_number = 'COD'.$number;
        return User::where('login_id',$concated_number)->exists();
    }

Please sign in or create an account to participate in this conversation.