<?php

namespace App\Models\Mitigation;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Prunable;

/**
 * A link to download a mitigated attacks report. These last for a week normally.
 */
class MitigationReportLink extends Model
{
    use Prunable;

    protected $table = 'mitigation_report_link';

    protected $fillable = [
        'token',
        'attack_id',
        'organisation_id',
        'expires_at'
    ];

    protected $casts = [
        'created_at'    => 'datetime',
        'updated_at'    => 'datetime',
        'expires_at'    => 'datetime',
    ];

    public function prunable() {
        return static::where('expires_at', '<=', now());
    }
}
