Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nagamma's avatar

Base table or view not found: Exception

Hi everyone,

In my application , I have created a model with name 'Invoice' and table with name 'invoice'. I am trying to get all records from invoice table.. my query is

$invoice=Invoice::all();

But , I am getting exception as follows

"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'lara_relationships.invoices' doesn't exist (SQL: select * from invoices)"

Why it is throwing error with table name invoices ?

where as my table name is only invoice and trying to fetch values using Invoice Model .

Please help me .. Thank you inadvance

0 likes
3 replies
Goldoni's avatar
Goldoni
Best Answer
Level 3

you have to create a table with the name invoices or specify the table with the protected $table = 'invoice'; in your model invoice

1 like

Please or to participate in this conversation.