Suppose I have a Salary model contains column of month and year I want to fetch data like Salary::where((year==date(‘Y’) && month<date('m')) || yearget() How can I …
Tag: laravel
Use a boolean function to determine the results in Laravel query builder
I have shops that open at a specific time and close at a specific time and I want to filter these stores according to a time period specified by the user so that all the returned shops will be available (opened) at any moment within filtering interval The shop opens at 10 pm and closes at 2 pm, I mean
Laravel sort conversations by last message
I have a Conversation model that has many ConversationMessage models. Now I want to sort the conversations based on the last message of the conversation. Basically like WhatsApp. How do I build the …
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 = …
“Action AppHttpControllersCommentRepliesController@createReply not defined” error on Laravel
I am trying to add an option to reply to comments on a post, but I keep getting that: CommentRepliesController@createReply is not defined. Adding a reply to a post through PostCommentsController@…
SQLSTATE[01000]: Warning: 1265 Data truncated for column
SQLSTATE[01000]: Warning: 1265 Data truncated for column ‘pay_totals’ at row 1 public function order(Request $req){ $order = new Order; $order->pay_number = $req->…
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
Get most recent row with group by and Laravel
Even though there are multiple questions like this I can’t get my query to return the row with the most recent date with a group by. I have the following table.. | message_id | from | to | …