Error when interrogating specific Collection (ChildTransformer::transform())

Feature(s) impacted

Viewing a certain collection, returns “invalid data”.

Observed behavior

Returns a 500 error -

Argument 1 passed to ForestAdmin\LaravelForestAdmin\Transformers\ChildTransformer::transform() must be an instance of Illuminate\Database\Eloquent\Model, instance of Illuminate\Database\Eloquent\Collection given, called in \vendor\league\fractal\src\Scope.php on line 357.

Error originates in src/transformers/ChildTransformers.php:21 (transform method, handling smart arrays).

I assume there’s some issue with the specific Model we have and it’s relations, from what I can see it’s to do with potential morphs. I can send the forestadmin schema json and a copy of our Model php in question.

Expected behavior

Able to view collection in question without errors.

Failure Logs

I can send the trace logs privately.

Context

  • Project name: Can send privately on request
  • Team name: Can send privately on request
  • Environment name: development
  • Agent type & version: Laravel “forestadmin/laravel-forestadmin” @1.2
  • Recent changes made on your end if any: … N/A

Hi @EFGP :wave:

Could you share your Model, the .forestadmin-schema.json and the trace logs ?

Hi Nicolas - PM’d you a zip of these. Thanks again.

I have just released version 1.2.1 which fixes this issue.

FYI it comes from the eager load of “artistTags”.

On our side when we display a model, we were taking all the relations of the instance instead of take only the hasOne and belongsTo relations defined into the forest schema file.

Could you try this new version :slightly_smiling_face:.

2 Likes

Amazing - thank you Nicolas that works perfectly. Refreshing to have such quick support and updates (especially free out of the box!) - we’ll definitely be purchasing once we’ve played about and it works for us.

2 Likes