Enable type inferring of Spatie Laravel Data in responses #211
Replies: 4 comments 6 replies
-
Hey @vilhelmjosander It is a great idea. I plan to build the extension for spatie/laravel-data, I'm just not sure when exactly. Meanwhile, do you have any particular questions about how to make it work? I believe that you'd need an extension that helps Scramble to infer return type of In general would be cool if you share questions you had when you tried to approach building extensions! I'm really looking toward improving extensions docs. Thank you 🫶 |
Beta Was this translation helpful? Give feedback.
-
bump! we really need that as well. |
Beta Was this translation helpful? Give feedback.
-
It would also be great to infer the request body if the data object is injected in the controller instead of the generic /**
* Duplicate Check.
*
* Check address for duplicates in the system.
*/
public function __invoke(AddressData $data): JsonResponse
{
//
} |
Beta Was this translation helpful? Give feedback.
-
@vilhelmjosander @slnw @jericdei Added Laravel Data support in 0.11.0 https://scramble.dedoc.co/blog/scrambledrop-scramble-0110 (as a part of Scramble PRO package) |
Beta Was this translation helpful? Give feedback.
-
Hi all,
This package is really awesome, great work! One thing that would make it even greater would be if it would be possible to enable automatic type inferring for responses of Spaties package Laravel Data (https://github.com/spatie/laravel-data) which is very popular within the Laravel community. We usually return the laravel data object directly in controllers, not an API Resource.
Example:
Data object
Controller
I tried looking into the extensions documentation to build this extension myself but I can't seem to make it work. Any hints or guidance would be welcome and then I could try implementing it myself and make a PR eventually.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions