Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0
function scopeUpcoming($query)
{
	$date = Carbon::now()->addDays(7);
	return $query->where('start_date', '>', $date);
}

maybe this?

Last updated 9 years ago.
0

Kryptonit3 said:

function scopeUpcoming($query)
{
  $date = Carbon::now()->addDays(7);
  return $query->where('start_date', '>', $date);
}

maybe this?

That is a possibility but that would do from whatever the day is, so a week would go from mon to mon, tues to tues, wed to wed, etc..

0

I think i've nailed it:

This sunday: 2015-02-22

This monday: 2015-02-23

Next sunday: 2015-03-01

Next monday: 2015-03-02

This sunday: {{ Carbon::parse('this sunday')->toDateString() }}

This monday: {{ Carbon::parse('this monday')->toDateString() }}

Next sunday: {{ Carbon::parse('next sunday')->addDays(7)->toDateString() }}

Next monday: {{ Carbon::parse('next week')->addDays(7)->toDateString() }}

0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.