Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

moktar's avatar

return api() !!!!

hello folks , I had checking an open source arm built with laravel and I found this expression and I didn't understand how it works .

return api([
'saved' => true,
'id' => $result->id
]);

what return api this is the first time I see it ?

0 likes
1 reply
ohffs's avatar
ohffs
Best Answer
Level 50

I guess someone's added a helper function that is just a shorthand for return response()->json([]);. Without knowing the context it's hard to say for sure though :-)

1 like

Please or to participate in this conversation.