Open admiralmedia opened 4 months ago
Change the database table to "tests". You want to make your table names plural in most cases.
Change the database table to "tests". You want to make your table names plural in most cases.
I've created(also renamed) several times the table with name Tests(plural form) but all I got was the same error when browsing Bread:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Tests.* from
testsorder by
created_atdesc) {"userId":1,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Tests.* from
testsorder by
created_atdesc) at /home/project/public_html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)
I've figured out what the issue was as follows:
Hello,
Tables needs names in all small letters and plural.
Not Test, not Tests, not test But should be tests
Kind regards John
manually create model for Test (model name) better to reallocate model directly inside app folder App
i.e: Modal Name = 'App\Models\Test**'
php artisan make:model Test
add below codes on Test Model
` class Test extends Model { protected $primaryKey='id';
use HasFactory;
public $table= 'Test';
public $timestamps=false;
`
Laravel version
9.52.16
PHP version
8.3.3-1+0~20240216.17+debian10~1.gbp87e37b
Voyager version
1.7
Database
MariaDB version 10.3.39
Description
I'm trying to create a simple project but got stuck on the first step as follows.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Test.* from
testsorder by
created_atdesc) {"userId":1,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Test.* from
testsorder by
created_atdesc) at /home/project/public_html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)
As I undestand the table name is created as singular but the browse BREAD is looking for the plural name of the table!
Steps to reproduce
I'm trying to create a simple project but got stuck on the first step as follows.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Test.* from
testsorder by
created_atdesc) {"userId":1,"exception":"[object] (Illuminate\\Database\\QueryException(code: 42S02): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'project.tests' doesn't exist (SQL: select
Test.* from
testsorder by
created_atdesc) at /home/project/public_html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:760)
Expected behavior
Browse the BREAD
Screenshots
Additional context
No response