php - Eloquent using wrong table name -
i have model called referrermedium
along migration referrer_mediums
table.
here class:
namespace app; class referrermedium extends \eloquent { // }
here migration:
schema::create('referrer_mediums', function (blueprint $table) { $table->increments('id'); $table->string('name'); });
here code:
foreach (referrermedium::all() $referrer_medium) { $options[$referrer_medium->name] = $referrer_medium->name; }
this code causing error base table or view not found: 1146 table 'leadbind.referrer_media' doesn't exist
why attempting query referrer_media
table instead of referrer_mediums
???
because medium
's plural type media
, therefore should manually specified table name in model:
protected $table = 'referrer_mediums';
but recommend should make migration change table name.
Comments
Post a Comment