mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Fix for the issue when the user tries to query assets due for audit without appropiate configuration [ch9625] (#7273)
* Added propper routes to the controller * Logic to handle the not setted ->audit_warning_days variable * Change the variable name for more clarity * Got rid of the unnecesary if sentence in sake of brevity * Adding the null coalesce operator so it can properly handle when the setting is null
This commit is contained in:
parent
4c61d330e6
commit
af1857b6ee
|
@ -1068,8 +1068,10 @@ class Asset extends Depreciable
|
|||
|
||||
public function scopeDueOrOverdueForAudit($query, $settings)
|
||||
{
|
||||
$interval = $settings->audit_warning_days ?? 0;
|
||||
|
||||
return $query->whereNotNull('assets.next_audit_date')
|
||||
->whereRaw("DATE_SUB(assets.next_audit_date, INTERVAL $settings->audit_warning_days DAY) <= '".Carbon::now()."'")
|
||||
->whereRaw("DATE_SUB(assets.next_audit_date, INTERVAL $interval DAY) <= '".Carbon::now()."'")
|
||||
->where('assets.archived', '=', 0)
|
||||
->NotArchived();
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ Route::group(
|
|||
|
||||
Route::get('audit/due', [
|
||||
'as' => 'assets.audit.due',
|
||||
'uses' => 'AssetsController@dueForAudit'
|
||||
'uses' => 'Assets\AssetsController@dueForAudit'
|
||||
]);
|
||||
|
||||
Route::get('audit/overdue', [
|
||||
'as' => 'assets.audit.overdue',
|
||||
'uses' => 'AssetsController@overdueForAudit'
|
||||
'uses' => 'Assets\AssetsController@overdueForAudit'
|
||||
]);
|
||||
|
||||
Route::get('audit/{id}', [
|
||||
|
|
Loading…
Reference in a new issue