In my Laravel 5 app I've got a relationship, and from this one-to-many relationship, I want to query and get only results whose date diff between their creation_date and an arbitrary date is between 0 and 2 days.
If you need I can show you a pseudocode, even if I think that it's clear what I need.
Thank you!
Just create a arbitrary date using carbon (as you are using laravel):
$start = Carbon\Carbon::create(year,month,day);
$end = $start->copy()->addDays(2);
And a little DB::raw in the mix, to format the created_at field to your needs:
Model::where(DB::raw('DATE_FORMAT(created_at,"%Y-%m-%d")'),'>=',$start)->where(DB::raw('DATE_FORMAT(created_at,"%Y-%m-%d")'),'<=',$end)->get();
That's it.