Reputation: 3833
I have the table users
in laravel.
A user has, among other things, an id
and an owner_id
.
I want to perform a query to get all the owners. That means, where the id
is equal to owner_id
.
Users::where('id','owner_id')->get();
Something like this. This didn't work obviously.
Any suggestions?
Upvotes: 0
Views: 912
Reputation: 41810
Use whereColumn
instead.
Users::whereColumn('id','owner_id')->get();
With where
, obviously you're just looking for a literal string 'owner_id'.
Upvotes: 2