Support the ongoing development of Laravel.io →
Requests

I try to understand api, oauth2, ... Now i have a problem with transformers in dingo/api. I'm sure this should work, but it doesnt:

In my Api:

$oAll = Comment::get();
return $this->response->collection($oAll, new CommentTransformer);

And in my Transformer

use League\Fractal\TransformerAbstract;
use App\Models\Comment;

class CommentTransformer extends TransformerAbstract {

    public static function transform(Comment $comment)
    {
        return [
            'text' => (string) $comment->comment_text
        ];
    }

}
Last updated 3 years ago.
0

Ok. I solved it. When i call the api direct with ajax it works. But when i do an internal request, like in the documentation of dingo it is not working. Maybe someone will help this info in the future :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.