Problem when creating object with tinker (Laravel)


I created a migration in the following way:

public function up() {
Schema::create('partesdiarios', function (Blueprint $table{

Effectively, create the daily shares table in MySQL. But when I want to create an object from tinker it returns an error:

Illuminate/Database/QueryException with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'baseprueba.parte_diarios'

That is, look for a table with a different name ( parte_diarios ). Thanks from now.

asked by josetuzin 20.12.2018 в 14:18

1 answer


Eloquent reads the following, for example your model is called:


Therefore it is assumed that the name of your table goes like this:


But if, on the contrary, your table is called


Then it is no longer the naming convention that Eloquent was waiting for; therefore you should within your model, declare a property that contains the name of the table.

Going back to the previous example, within the User model then we should have

protected $table = "my_users";

Now finally for the case of your question, within your model ParteDiario you should have:

protected $table ="partesdiarios";

Here you have the reference of the documentation go to the part that is called table names

answered by 20.12.2018 / 14:42