爬虫开发
This commit is contained in:
48
app/Models/CrawlAlert.php
Normal file
48
app/Models/CrawlAlert.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CrawlAlertSeverity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CrawlAlert extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'run_id',
|
||||
'rule_id',
|
||||
'severity',
|
||||
'type',
|
||||
'message',
|
||||
'context',
|
||||
'is_resolved',
|
||||
'resolved_by',
|
||||
'resolved_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'severity' => CrawlAlertSeverity::class,
|
||||
'context' => 'array',
|
||||
'is_resolved' => 'boolean',
|
||||
'resolved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function run(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CrawlRun::class, 'run_id');
|
||||
}
|
||||
|
||||
public function rule(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CrawlRule::class, 'rule_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user