Support the ongoing development of Laravel.io →
Requests Database Validation
Last updated 3 months ago.
0

    // Get user IP
    $ip = $_SERVER['REMOTE_ADDR'];

    // Search user table for user IP
    $users = Namespace\User::where('ip_address', $ip); 

    // Return number records found
    return count($users);



    // Or all in one line if you prefer that
    return count(Namespace\User::where('ip_address', $_SERVER['REMOTE_ADDR']));

Last updated 7 years ago.
0

Thanks, works great!

0

You should use eloquent count().

    return User::where('ip_address', $_SERVER['REMOTE_ADDR'])->count();
    return User::whereIpAddress($_SERVER['REMOTE_ADDR'])->count();
Last updated 6 years ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

HuntZero HuntZero huntzero Joined 24 Nov 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.