Skip to content
Advertisement

Tag: laravel

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();

Laravel using a case statement

I’m trying to retrieve all messages of a conversation and display it’s status (read or unread). With a CASE I try to read the message.read property (boolean) and process it to a string. $messages = …

Show the posts which have specific tags or categories

I want to show the posts which have specific tags or categories as I mentioned in the title; for example, one of my posts has 3 tags “php”,”laravel”,”regex” I want to get those posts that have laravel tag in their many to many relationships. Answer First, make sure you have set the right relations on your models. then use Querying

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

Advertisement