You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wouldn't it be nicer to do these calculations in PHP rather than tiring the MySQL?
/** * Find items for current year * @param string $column * @return $this */publicfunctionwhereCurrentYear($column = 'created_at')
{
$now = now()->toDateTimeString();
$startOfThisYear = Carbon::parse('first day of this year')->toDateTimeString();
return$this->whereRaw("$column between {$startOfThisYear} and {$now}");
}
return$this->whereRaw("$column between date_format(now() ,'%Y-01-01') and now()");
}
SELECT*FROM`candidates`WHERE created_at BETWEEN date_format(now() ,'%Y-01-01') and now();
SELECT*FROM`candidates`WHERE created_at BETWEEN "2022-01-01 00:00:00"and"2022-09-28 23:59:59";
The text was updated successfully, but these errors were encountered:
Wouldn't it be nicer to do these calculations in PHP rather than tiring the MySQL?
laravel-sub-query/src/Traits/LaravelSubQuerySugar.php
Lines 105 to 113 in 42e586f
The text was updated successfully, but these errors were encountered: