saloon icon indicating copy to clipboard operation
saloon copied to clipboard

Add Macroable to Request?

Open aarondfrancis opened this issue 4 months ago • 4 comments

First off, this has gotta be one of the top packages in the Laravel ecosystem. I just absolutely love it.

To the issue: would it be possible to add the Macroable trait to the Request class? Any reason you've avoided it until now? I want my Requests to have a send() method (I know I know it's not SOLID) and right now I'm forced to create a base request class.

Any opinions on that?

aarondfrancis avatar Sep 04 '25 16:09 aarondfrancis

Hey @aarondfrancis just wanted to first off say a huge apology for not seeing your issue sooner, life is so. so. busy at the moment. Thank you for the love for Saloon! ❤️

I think the main reason it was avoided is because Macroable to my knowledge is a Laravel-specific pattern and this package is meant to be used by any PHP application/framework.

Adding a send method to the request used to be supported, funnily enough - https://docs.saloon.dev/2/upgrade/upgrading-from-v1#updated-way-to-send-requests

The docs also detail some of the reasons why we changed it this way. You can actually restore this functionality with the HasConnector trait:

Although this is being taken out of the request, you may still add the functionality back with the HasConnector trait on the request. However, if you add it back - you need to be aware of the downsides like not being able to have constructor arguments on your connector.

Sammyjo20 avatar Oct 19 '25 16:10 Sammyjo20

Oh nice! Good to know, thank you so much! I'll give that a go

aarondfrancis avatar Oct 20 '25 18:10 aarondfrancis

Hmmm @Sammyjo20 we are using Spatie's Macroable (https://github.com/spatie/macroable) and you have the macroable trait (https://github.com/saloonphp/saloon/blob/v3/src/Traits/Macroable.php) in Saloon..... I reckon we could shine our spurs and rowels and added it to the Request class as well 🤔

craigpotter avatar Oct 21 '25 00:10 craigpotter