Support the ongoing development of Laravel.io →
Requests Database Validation
Last updated 2 years 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 9 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 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

HuntZero huntzero Joined 24 Nov 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.