Support the ongoing development of Laravel.io →
Authentication Database Validation

Hello, im trying to get an user by its name. So far i can get one like that

$users = User::where('name', '=', 'admin')->get();
foreach ($users as $user)
{
  var_dump($user->name);
}

I have array of users and would like to get users inside that array. I've tried something weird like.

$arendofwork = explode(',', $endofwork = $employes);
foreach ($arendofwork as $value) {
$users = User::where('name', '=', $value)->get();
foreach ($users as $user)
{
  var_dump($user->name);
}
}

But it outputs only first one in array

Last updated 2 years ago.
0
$users = User::whereIn('users', $employes)
    ->get();

https://laravel.com/docs/5.3/queries

0

Sign in to participate in this thread!

Eventy

Your banner here too?

thesign3r thesign3r Joined 11 Oct 2016

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.

© 2025 Laravel.io - All rights reserved.