33 lines
725 B
PHP
33 lines
725 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Jobs\Arcadia;
|
||
|
|
|
||
|
|
use App\Models\TraceaEgg;
|
||
|
|
use App\Models\TraceaPoultry;
|
||
|
|
|
||
|
|
class RemoveOldXmlEntries
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Execute the job.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function handle()
|
||
|
|
{
|
||
|
|
try {
|
||
|
|
$q = TraceaPoultry::query();
|
||
|
|
$q->where('exp_date', '<=', now()->subMonths(config('tracea.keepPoultryMonths', 18)));
|
||
|
|
$q->delete();
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
report($e);
|
||
|
|
}
|
||
|
|
try {
|
||
|
|
$q = TraceaEgg::query();
|
||
|
|
$q->where('dcr', '<=', now()->subMonths(config('tracea.keepEggMonths', 12)))->destroy();
|
||
|
|
$q->delete();
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
report($e);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|