Skip to content
Advertisement

Tag: laravel

Error 1140 using the query builder of Laravel and count aggregate

I want to do the following SQL query using the Laravel query builder: I tried with the following code but it doesn’t work correctly: I reiceived the following error: Can help? Answer Aggregate functions like sum,count,min,max,avg when selected with other columns it must have a groupBy clause for one of these column. your query have two columns ‘source’ & ‘customer_id’

how to successfully add a foreign key constraint to your Database table in laravel using eloquent?

I have a database containing two Tables(students, payments) with id as primary key and another column studentID within the students Table. Am making studentID a foreign key in payments Table. I am getting this error message: SQLSTATE[42000]: Syntax error or access violation: 1072 Key column ‘studentID’ doesn’t exist in table (SQL: alter table payments add constraint payments_studentid_foreign foreign key (studentID)

Multiple form submit in Laravel

Good day everyone, I have a form with multiple inputs in it and I want to pass it onto the database on submit. Here’s what my blade.php looks like: on code: Here’s my attempt to find a solution: on my controller: I’m having the following errors: ErrorException Array to string conversion and when adding an image call to a member

Laravel Dynamic DB Relation

I didn’t find any solution so i am asking it here.. The id of Team is related with teams in Match ,for this the solution is easy.. but The Problem is that one Match can have 3/4+ no of teams So i have to make it dynamic … Answer As Per @maki10 The working Solution Is

Laravel sql table error when i try to upload

This is the error i get SQLSTATE[HY000]: General error: 1 table posts has no column named caption (SQL: insert into “posts” (“caption”, “image”, “user_id”, “updated_at”, “created_at”) values (Caption, Why is that post table code blade.php code and i have my PostsController.php as Why is the error coming up? Answer As you are trying to store data into the post table

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

Advertisement