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

bacordioroger's avatar

API Resource Non-Related Model

Hi, I know how to make Laravel API resource if relationship is involved. But how about if they are not related?

        $inventories = Inventory::all();
        $categories = Category::all();

I want to merge them with keys but not using the put method of collection as it returns array. I want object.

0 likes
0 replies

Please or to participate in this conversation.