michaelnguyen547
9 months ago

polymorphic relation

Posted 9 months ago by michaelnguyen547

https://laravel.com/docs/5.7/eloquent-relationships#polymorphic-relationships


$comment = App\Comment::find(1);

$commentable = $comment->commentable;

commentable can be App\Video or App\Post. Is it possible to get exact type such as $comment->video or $comment->post

Please sign in or create an account to participate in this conversation.