Support the ongoing development of Laravel.io →
Input Database Forms
Last updated 2 years ago.
0

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?

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Sensors sensors Joined 8 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.