thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Base table or view not found error occurred when using tables without an "s" in the name #5077

Closed maurin88 closed 4 years ago

maurin88 commented 4 years ago

Version information

Description

Tablenames without a "s" at the end will not work with voyager. They alway produce the error:

Illuminate\Database\QueryException SQLSTATE[42S02]: Base table or view not found: 1146 Table 'demo.demotables' doesn't exist (SQL: select * from demotable**s** order by id asc)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a table without an "s" at the end of the tablename. For example: demotable. In other languages then english, names in plural often do not have an "s" at the end.
  2. Create a bread
  3. Try to browse the table.
  4. Because the table has no "s" at the end of the name, an table not found error will occur.

Expected behavior

Browse the table like other tables with an S at the end. I had no problems using voyager with a table name like "clients" for example. but the german word "mitarbeiter" fails. I know, that voyager has a multilanguage feature, but this is only a workaround to this bug.

Additional context

Also i have encountered a problem with CamelCase notation. DemoTables will create a demo_tables which is not recognized in the BREAD. Maybe this error is related to the first problem.

fletch3555 commented 4 years ago

Laravel naming conventions expect tables to be plural (generally, ending with an 's'). Since Voyager is built on top of Laravel, we make the same assumptions. To fix this, you have to tell laravel what the table name should be, by adding the $table property to your model class.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.