Based on Laravel example Comment has polymorph relationship with Post and Video Model.
I can retrieve Comment with Post and Video using $comment->commentable
, but it return all columns of Post or Video. Post has id, name, other columns... Video has id, title, other columns...
How to limit certain columns ? I want for Post only id and name columns and for Video only id and title columns
->with(['commentable' => function ($query) {
$query->select('id', 'name');
}])
This code will error since Video doesnt have name columns.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/x5pyUn2
via IFTTT
Aucun commentaire:
Enregistrer un commentaire