I get following error:
Illuminate \ Database \ QueryException (42S02)
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'l4orm.posts' doesn't exist (SQL: insert into `posts` (`title`, `body`) values (post, body for the post))
Database l4.orm table:
model Authors
class Authors extends \Eloquent {
public function post()
{
return $this->hasMany('Post');
}
}
Routes
Route::get('/', function()
{
Authors::find(1)->post()->insert(array(
'title'=>'post',
'body' =>'body for the post'));
});
The error is pretty self explanatory. It's trying to insert into a table called "posts" that doesn't exist.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community