Создал БД
posts
id - integer title - string body - text
videos
id - integer title - string url - string
comments
id - integer body - text commentable_id - integer commentable_type - string
Для каждой Модели определил отношения
class Comment extends Model
{
/**
* Get all of the owning commentable models.
*/
public function commentable()
{
return $this->morphTo();
}
}
class Post extends Model
{
/**
* Get all of the post's comments.
*/
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
}
class Video extends Model
{
/**
* Get all of the video's comments.
*/
public function comments()
{
return $this->morphMany('App\Comment', 'commentable');
}
}
В контроллере написано
public function index()
{
$comment = App\Comment::find(1);
$commentable = $comment->commentable;
dd( $commentable);
}
Но мне выдает ошибку
FatalErrorException in Model.php line 827: Class 'post' not found
В базе пробовал менять название commentable_type на Post все равно ошибка.
Что мне сделать чтобы отношения работали?