For me it looks weird.
Cannot use object of type stdClass as array
I converted my query to array.
$query = DB::table('users')->where('name','=','Alex')->get()->toArray();
Checked my variable gettype($query); and it says Array.
Also checked it with var_dump($query); and it also shows Array.
So why while looping my $query in foreach I have to use $item->name and can't access to items as array $item['name'] ?