Inserting the information for a range of dates

Posted 2 months ago by twoarmtom

I'm trying to find examples of properly looping through a range of dates to insert information.

Currently, I am creating a schedule row with the user, location etc., and a single date in a form using:

Schedule::create($request->all());

But I would like to add start and end date and create identical row information (user, location, etc.), looping through each date in the range, and stopping after the end date is inserted. Assuming two dates would be something like:

$request->start_date
$request->end_date

I found some examples with messy PHP, but I'm assuming there is a more 'eloquent' way to do this. Any help would be greatly appreciated.

Thank you.

Please sign in or create an account to participate in this conversation.