mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 07:17:34 +08:00
Properly include to-many relations
This commit is contained in:
parent
c5420ef7df
commit
9e81e9f955
|
@ -54,7 +54,7 @@ abstract class BaseSerializer extends SerializerAbstract
|
|||
$data = $relation($model, $include);
|
||||
} else {
|
||||
if ($include) {
|
||||
$data = !is_null($model->$relation) ? $model->$relation : $model->$relation()->first();
|
||||
$data = !is_null($model->$relation) ? $model->$relation : ($many ? $model->$relation()->get() : $model->$relation()->first());
|
||||
} elseif ($many) {
|
||||
$relationIds = $relation.'_ids';
|
||||
$data = $model->$relationIds ?: $model->$relation()->get(['id'])->fetch('id')->all();
|
||||
|
|
Loading…
Reference in New Issue
Block a user