If it's common for your project to display that i'ld use a get attribute and do your check if started at < 24 hours for example out put diffForHumans() or your format. Then in your view just use start_at.
Blade / helper function, simple date & string conditional formatting question
I have an Event model that has two dates: start and end - they are instances of Carbon. When displaying the dates I would like to do some checking and format a string depending on a few things.
This is what I have so far:
<h6 class="card-subtitle text-muted">
{{ $event->started_at->format('H:i D d M Y') }} - {{ $event->ended_at->format('H:i D d M Y') }}
</h6>
This prints out "06:30 Sun 20 Mar 2016 - 08:45 Sun 20 Mar 2016 " which is great although it isn't easy/quick/intuitive to tell that the event is only 2hrs 15mins long on the Sunday, I'd rather it say "Sun 20 Mar 2016 06:30 - 08:45". This means that I need to check that the date parts of the timestamps are the same.
Is this a use case for Service Injection or just a helpers.php file?
Please or to participate in this conversation.