valueObject -- change case automatically from requests (add Attribute to set cases)
$BPOfferToClientData = BPOfferToClientData::make(
SalePrice: request()->input('sale_price'),
PaymentAmount: request()->input('payment_amount'),
NumberOfPayments: request()->input('number_of_payments'),
ClientPaysTotal: request()->input('client_pays_total'),
ClientBuyersPremiumAmount: request()->input('client_buyers_premium_amount')
);
should be
<?php
declare(strict_types=1);
namespace App\Notifications\DataObjects;
use CustomD\LaravelHelpers\ValueObjects\ValueObject;
/**
* A parcel of information that is sent from legacy zon code,
* for the purpose of generating a email to a client,
* to advise them that a Buyer's Premium offer is ready for them to accept.
*/
#[MapMakeCaseValue('camel')]
class BPOfferToClientData extends ValueObject
{
public function __construct(
public float $SalePrice,
public float $PaymentAmount,
public int $NumberOfPayments,
public float $ClientPaysTotal,
public float $ClientBuyersPremiumAmount,
) {}
}
&&
BPOfferToClientData::fromRequest($formRequest,true|false);
or
BPIfferToClientData::make(...$request->only(['sale_price','xxx']))