my table this is the result I want to display john — total paid shoes and bag dave <– total of bag,’shoes is unpaid so 1000 is not added to total’ this is my controller it gives me an error the total is same in all name Answer You could look to join sub queries, that certainly would be one
Tag: eloquent
Booking Time slot, with Equipment Stock query, in Laravel
Here’s an interesting one for you all. I’ve found myself in a implementation conundrum. I’m developing a booking app in Laravel that allows people to book rooms and equipment for spaces at specific times. The amount of equipment available is limited, so the amount of stock has to be queried in tandem with the time slots associated with the booking.
Multiple LIKE clauses in Laravel Eloquent
I currently have this code in my controller: The above code works, but what I want is to get “Accounting” and “Web Design” from an array, and just loop through that array so that the query is dynamic instead of hard coded on the controller Answer Try this :
Left Join – In Eloquent
I would like to connect user table and like table based on the user_id So I have this Model user.php like.php and my query I would like to return the ‘likes’ table inside the ‘user’ but it doesnt work. I would like to left join it. What am I doing wrong? Answer Well, you need to use one-to-many relation to
Queries in Laravel – Equivalent to left join
Currently this is my laravel query But unfortunately, I would also like to get the connected data between the company and the user table, user_id for company and id for user this is the table company table: and the user table How to I connect the user under the company array? Answer You need to make a relationship for the
Convert this SQL into eloquent ORM
I want to convert the following sql statement into eloquent: I did this as like below: The problem is that it is converting to the same sql but showing error. The error is shown below: * order_number, order_id, sum(quantity) as qty, sum(price) as pr from orders right join order_details on orders.id = order_details.order_id group by order_number) * The tables are:
Laravel 6 many to many relationship
In laravel 6, I have 2 models I have third model to join tables Now how can I get all the teachers those are not subscribed by a particular student? For example: Teacher1, Teacher2, Teacher3, Teacher4 are in the Teacher table and Student1, Student2, Student3, Student4 are in the Student table Student1 subscribed Teacher1, Teacher2 Student2 subscribed Teacher1, Teacher4 Student3
Is it possible to translate this “join” and “as” query to Laravel PDO functions?
I am struggling to make this SQL query to a Laravel PDO query. Does anyone know how I can do this? (Especially the ‘AS’ statements and the naming in the joins). Query: Answer Directly use join() and select() method like this:
Laravel Eloquent Join Using Another table
Hi how to convert this SQL query to Laravel Eloquent? I have three table: payments, devices and users. Payments table does not store user_id. but table has device_id. And device table also has user_id. I want to get user name which made payment. Answer it’s very easy Another way is: We have three models: User (has many devices) Device(belongs to
Laravel : convert grouped data to one row
Hello please i want to convert grouped data with duplicated keys and different values to one row. For example : “book1” { { “id” : “1”, “group” : “book1”, “name” : “…