@ivanradojevic what happens here?
new ProductResource($this->product)
can you post what that resource looks like?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an API, that does not load at all, not error, intinity loading. I check in Postman, same situation.
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\ProductResource;
class ProductVariationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
"id" => $this->id,
"name" => $this->name,
"price" => $this->formattedPrice,
"stock_count" => $this->stock,
"in_stock" => $this->inStock(),
"product" => new ProductResource($this->product),
];
}
}
The problem arose when I entered "product" => new ProductResource($this->product), It works without it, but why don't I have error?
return [
"id" => $this->id,
"name" => $this->name,
"price" => $this->formattedPrice,
"stock_count" => $this->stock,
"in_stock" => $this->inStock(),
];
Please or to participate in this conversation.