Added auto deletion logic - record created 6 months ago
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Prunable;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
class WeightValidation extends Model
|
class WeightValidation extends Model
|
||||||
{
|
{
|
||||||
|
use Prunable;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
@@ -33,4 +36,13 @@ class WeightValidation extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Item::class);
|
return $this->belongsTo(Item::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function prunable(): Builder
|
||||||
|
{
|
||||||
|
// $startOfTwoMonthsAgo = now()->subMonthsNoOverflow(3)->startOfMonth();
|
||||||
|
// $endOfPrevMonth = now()->subMonthNoOverflow()->endOfMonth();
|
||||||
|
|
||||||
|
// return static::whereBetween('created_at', [$startOfTwoMonthsAgo, $endOfPrevMonth]);
|
||||||
|
return static::where('created_at', '<=', now()->subMonthsNoOverflow(6));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user