I have a really simple Data written as the following
use Spatie\LaravelData\Data;
class FrequencyData extends Data
{
public function __construct(
public string $type,
public bool $hasEndDate,
public string $repeat,
public Carbon|null $endDate
) {
}
// how do I get this to be added to the object
public function createRRule()
{
// do the logic for the rule
return 'DTSTART:20230510T043520Z
RRULE:FREQ=WEEKLY;UNTIL=20231110T043520Z;BYDAY=WE'
}
}
What I want to know is, is it possible to be able to have something where when you call
$frequency = FrequencyData::from(request());
print_r($frequency);
instead of it outputting
Array
(
[type] => recurring
[hasEndDate] =>
[repeat] => weekly
[endDate] => 2023-11-16T11:00:00.000000+00:00
)
it will output me something like
Array
(
[type] => recurring
[hasEndDate] =>
[repeat] => weekly
[endDate] => 2023-11-16T11:00:00.000000+00:00
[rrule] => DTSTART:20230510T043520Z
RRULE:FREQ=WEEKLY;UNTIL=20231110T043520Z;BYDAY=WE
)
is that possible?