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
];
}
}
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 :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community