mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 03:59:39 +08:00
Make sure serializers work with relations implemented with magic (via __call)
This commit is contained in:
parent
db31d9f772
commit
22ff8a203d
@ -47,7 +47,7 @@ abstract class BaseSerializer extends SerializerAbstract
|
||||
$data = $relation($model, $include);
|
||||
} else {
|
||||
if ($include) {
|
||||
$data = $model->$relation;
|
||||
$data = !is_null($model->$relation) ? $model->$relation : $model->$relation()->first();
|
||||
} elseif ($many) {
|
||||
$relationIds = $relation.'_ids';
|
||||
$data = $model->$relationIds ?: $model->relation()->get(['id'])->fetch('id')->all();
|
||||
|
Loading…
x
Reference in New Issue
Block a user