Skip to content
Advertisement

Tag: eloquent

Laravel Eloquent: select records where one field equals another

I apologize if this is duplicated. Is it possible in Eloquent ORM to select records where one field equals another? In MySQL this means: Is it possible to do so in Eloquent or I’m bound to using raw queries? Answer On field equalling another in the query builder (and eloquent) is whereColumn(‘Url’, ‘LIKE’, ‘ModelId’) but since you have additional things

Convert Query to Eloquent

How to make that query with eloquent My relationships I fetching the name with a given ID, but how can I find it for all. Or maybe I am thinking wrong Answer I assumed your employees Model name as Employee and companies Model name as Company If you want to search per id then you may do as below.

changing sql statement to eloquent query

So I have an SQL statement as such; How do I change this to an eloquent query? Or is it better to just use a db:raw query? All inputs are very much appreciated. Cheers! Answer You can try this : Read more at whereBetween section in here

Advertisement