Level 51
Change it to
$medical_institute->load([
'doctors:id,name,name_kana,your_relationship_column',
]);
return response()->json([
'data' => $medical_institute
]);
When using this feature, you should always include the
idcolumn and any relevant foreign key columns in the list of columns you wish to retrieve.
https://laravel.com/docs/10.x/eloquent-relationships#eager-loading-specific-columns
1 like