2025-06-29 09:37:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2025-06-29 09:48:45 +02:00
|
|
|
use App\Events\ArticleFetched;
|
2025-06-29 09:37:49 +02:00
|
|
|
use Database\Factories\ArticleFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @method static firstOrCreate(string[] $array)
|
|
|
|
|
*/
|
|
|
|
|
class Article extends Model
|
|
|
|
|
{
|
|
|
|
|
/** @use HasFactory<ArticleFactory> */
|
|
|
|
|
use HasFactory;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'url',
|
2025-06-29 09:53:45 +02:00
|
|
|
'is_relevant',
|
2025-06-29 09:37:49 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'created_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
2025-06-29 09:48:45 +02:00
|
|
|
|
|
|
|
|
protected static function booted()
|
|
|
|
|
{
|
|
|
|
|
static::created(function ($article) {
|
|
|
|
|
event(new ArticleFetched($article));
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-06-29 09:37:49 +02:00
|
|
|
}
|