One possible solution to this dilemma is to store the event dates in the more "correct/standardized" manner, where the end date is the start time of the next day. This approach ensures that the event spans the whole day in the calendar view and aligns well when calculating date differences.
To handle the presentation of the data in Blade, you can make necessary adjustments in either the model or controller. One approach is to create an accessor in your model that formats the start and end dates for display. Here's an example:
// Event model
public function getFormattedStartDateAttribute()
{
return $this->start->format('Y-m-d');
}
public function getFormattedEndDateAttribute()
{
return $this->end->subDay()->format('Y-m-d');
}
In your Blade view, you can then use these accessor methods to display the formatted dates:
@forelse ($events as $event)
{{ $event->formattedStartDate }} - {{ $event->formattedEndDate }}
{{ $event->title }}
@empty
No events found.
@endforelse
This way, the dates will be displayed correctly in the list format, taking into account the adjusted end date.
When sending events to FullCalendar, you can add an extra day to the end date to ensure that the event spans the correct duration. If events are modified via drag-and-drop in the frontend, you can modify the date again before saving it back to the database.
Overall, this approach allows you to store the event dates in a standardized manner, handle the presentation in Blade, and ensure the correct duration in FullCalendar.