Great question! The reason your price and expenses accessors aren't being applied is likely because you're accessing them on the Eloquent model resource ($this in the resource), not the model itself. By default, Laravel API Resources ($this->resource) wrap the model, but if your resource is fed an array or individual values, accessors won’t run.
Solution:
Make sure your resource is receiving the Eloquent model, not an array. Instead of doing:
return new YourResource($yourModel->toArray());
just do:
return new YourResource($yourModel);
Or, if you want to be explicit in the resource itself, always fetch model attributes as properties:
'price' => $this->price,
'expenses' => $this->expenses,
If you already do this but still get raw values, double-check how you pass the data to the resource! Accessors only work when you’re using the Eloquent model, not plain arrays.