Home > database >  Lumen changes table name in query
Lumen changes table name in query

Time:04-02

I'm new to Lumen (ver. 8.3.4) and I got a strange issue during my tests.

In my DB I have the table "Pippo"; to query it I created the model App\Models\Pippo and the controller App\Http\Controllers\PippoController.php, that includes the aforementioned model. To route the requests, in web.php I added the line:

$router->post('getdomain', 'PippoController@getdomain');

Now, in 'getdomain' function I've a simple

$var = Pippo::all();

but when I try to call it, I get the following error:

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

I searched and researched multiple times in the code, but I don't understand why Lumen adds the 's' character to the table name.

Any suggestion?

Thanks in advance, Gianluca

CodePudding user response:

you can put in modal protected $table = 'pippo'; To avoid this error

  • Related