I have figured out that after I do my Eloquent call to get the data I want to edit, I can manipulate the array it is assigned to and create new columns with the original input names holding the separated values (thanks Carbon!).
public function edit($id)
{
// Get the event to be ammended
$event = Event::findOrFail($id);
// Add new fields to the array containing date and time for form inputs
$event['date'] = Carbon::parse($event['date_time'])->toDateString();
$event['time'] = Carbon::parse($event['date_time'])->toTimeString();
// remove original date_time field from array
unset($event['date_time']);
return view('events.edit', compact('event'));
}
If I was to create a function to do this since I might use it again, however, where would I keep something like that in my MVC structure?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community