Skip to content
Advertisement

Tag: eloquent

Laravel Eloquent version of “NOT IN” SQL

Just need the Eloquent ORM format of this query.. giving a headache for a while. Answer You Can Try this. First you Can Select all Player IDs. $player_ids = TeamRequest::select(‘player_id’)->get(); Then you can find Players Player::whereNotIn(‘user_id’, $player_ids)->get();

How to prioritize result in laravel eloquent

I have a table with 4 columns. I want to display the row based on input and it should be able to display with priority according to the priority fields. example: My table looks like this: I have my test cases below how it should work: Now, I want to prioritize the result from title down to tags based in

Laravel using where clause on a withCount method

I am trying to do a where clause on withCount method of laravel’s eloquent query builder using this piece of code. and this code is giving me this error. SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘upvotes_count’ in ‘where clause’ (SQL: select , (select count() from upvotes where upvotes.upvoteable_id = posts.id and upvotes.upvoteable_type = AppPost) as upvotes_count from posts where

MySQL order by field in Eloquent

When I want to define a custom sort order in a MySQL query I can do something like this: ORDER BY FIELD(language,’USD’,’EUR’,’JPN’) What would be the Eloquent ORM version of that? UPDATE: This is …

Advertisement