I am trying to retrieve a polymorphic model that has null on its polymorphic columns. Based on the example below, how to retrieve comments that do not belong to any post or video
Example:
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
Relationships:
class Comment extends Model
{
public function commentable()
{
return $this->morphTo();
}
}
class Post extends Model
{
public function comments()
{
return $this->morphOne('App\Comment', 'commentable');
}
}
class Video extends Model
{
public function comments()
{
return $this->morphOne('App\Comment', 'commentable');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire