I am having problems setting up my table in an eloquent model. I have done this many times, but for some reason this does not seem to work. Am I missing something here?
Model:
class F5Host extends Eloquent {
protected $guarded = array();
protected $table = 'f5hosts';
public function Environments() {
return $this->belongsTo('Environment');
}
}
Using:
$host = new F5Host;
return $host->all();
Error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myapp.f5_hosts' doesn't exist (SQL: select * from `f5_hosts`)
Update: I know that Laravel has a function that translates CamelCase to snake_case when using models to determine the database table name. however, the $ table variable should override this. I noticed that when changing the class name to "F5host", an override suddenly starts working.
source
share