// 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']));
You should use eloquent count().
return User::where('ip_address', $_SERVER['REMOTE_ADDR'])->count();
return User::whereIpAddress($_SERVER['REMOTE_ADDR'])->count();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community