lundi 29 août 2016

Laravel5: Why my model "Media" require table named "media" instead of "medias"?

From the doc of laravel, it claims:

Now, let's look at an example Flight model, which we will use to retrieve and store information from our flights database table

So I wrote:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Media extends Model
{
    //
}

But when I run my application, it gives that error:

QueryException in Connection.php line 729:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myapp.media' doesn't exist (SQL: select * from `media`)

It requires a table named media instead of medias as document said. So why that errors happened? Do I accidentally open option flag which changed the default name mapping from model to table or something similar?

Any suggestion will be appreciated.


Environment:

  • Laravel Framework version 5.2.43
  • PHP 7.0.8-2+deb.sury.org~xenial+1


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire