How to remove item key from repeater on save to json

Hi, I have a piece of code that is like this, the goal is to pass it into https://github.com/kylekatarnls/business-time
Fieldset::make('Schedule Config')
->schema([
Repeater::make('schedule_config.monday')
->schema([
TextInput::make('time_range'),
]),
Repeater::make('schedule_config.tuesday')
->schema([
TextInput::make('time_range'),
]),
// other days...
])->columns(1),
Fieldset::make('Schedule Config')
->schema([
Repeater::make('schedule_config.monday')
->schema([
TextInput::make('time_range'),
]),
Repeater::make('schedule_config.tuesday')
->schema([
TextInput::make('time_range'),
]),
// other days...
])->columns(1),
However when I save it, it save as something like this in my json column
{"friday": [], "monday": [{"time_range": "09:00-12:00"}, {"time_range": "13:00-18:00"}], "sunday": [], "tuesday": [], "saturday": [], "thursday": [], "wednesday": []}
{"friday": [], "monday": [{"time_range": "09:00-12:00"}, {"time_range": "13:00-18:00"}], "sunday": [], "tuesday": [], "saturday": [], "thursday": [], "wednesday": []}
But what I want is more of something like this
{"friday": [], "monday": ["09:00-12:00", "13:00-18:00"], "sunday": [], "tuesday": [], "saturday": [], "thursday": [], "wednesday": []}
{"friday": [], "monday": ["09:00-12:00", "13:00-18:00"], "sunday": [], "tuesday": [], "saturday": [], "thursday": [], "wednesday": []}
Usage of the Schedule class of the business-time package is like this, hence i want to remove the time_range key
Schedule::create([
'monday' => ['09:00-12:00', '13:00-18:00'],
'tuesday' => ['09:00-12:00', '13:00-18:00'],
'wednesday' => ['09:00-12:00'],
'thursday' => ['09:00-12:00', '13:00-18:00'],
'friday' => ['09:00-12:00', '13:00-20:00'],
]);
Schedule::create([
'monday' => ['09:00-12:00', '13:00-18:00'],
'tuesday' => ['09:00-12:00', '13:00-18:00'],
'wednesday' => ['09:00-12:00'],
'thursday' => ['09:00-12:00', '13:00-18:00'],
'friday' => ['09:00-12:00', '13:00-20:00'],
]);
GitHub
GitHub - kylekatarnls/business-time: Carbon mixin to handle busines...
Carbon mixin to handle business days and opening hours - GitHub - kylekatarnls/business-time: Carbon mixin to handle business days and opening hours
3 Replies
Dan Harrin
Dan Harrin2y ago
if youre using the admin panel, use mutateFormDataBeforeSave() etc
pocket.racer
pocket.racerOP2y ago
what about when retrieving?
Dan Harrin
Dan Harrin2y ago
theres a similar method, read the docs
Want results from more Discord servers?
Add your server