Skip to content
Advertisement

Laravel 8 pagination Error – Column ‘is_deleted’ in where clause is ambiguous

I am new to Laravel and have stumbled upon a problem. Would you mind advising the right way of doing it if I am doing it incorrectly? For example, I have 3 tables: product, product_category, product_image, as below.

JavaScript
JavaScript
JavaScript

Question 1

I am paginating my data on the frontend, but I am getting the following error with the below code.

Column ‘is_deleted’ in where clause is ambiguous.

JavaScript

Question 2

I have a product_image table, and I want to attach the product images with each product as an array of $product->images. Currently, I am doing the below, it is working, but I am not sure it’s the right way. Can someone please advise a cleaner Laravel way of doing this?

JavaScript

Advertisement

Answer

First of all

Remake your migration and put

JavaScript

Second of all, try and rething your relationship between tables. You can accomplish the same thing with Eloquent.

JavaScript

Query example:

JavaScript

in blade do

JavaScript

to show the default pagination.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement