You need an accessor in your model.
Suppose you have a field datesin your table.
public function getDatesAttribute($value)
{
$this->attributes['dates'] = Carbon::createFromFormat('m/d/Y', $value);
}
The above function converts a date from a string to a Carbon object. By default, Laravel supports Carbon.
Now you have a controller:
$test = Test::where('dates', '>=', Carbon::now()->subMonth())->get();
I have not tested the code, but should work. :)
source
share