fedi-feed-router/app/Models/Route.php

63 lines
1.3 KiB
PHP
Raw Normal View History

2025-07-05 23:54:43 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Support\Carbon;
/**
* @property int $feed_id
* @property int $platform_channel_id
* @property bool $is_active
* @property int $priority
2025-07-07 00:51:32 +02:00
* @property array<string, mixed> $filters
2025-07-05 23:54:43 +02:00
* @property Carbon $created_at
* @property Carbon $updated_at
*/
2025-07-10 11:14:06 +02:00
class Route extends Pivot
2025-07-05 23:54:43 +02:00
{
2025-07-10 11:14:06 +02:00
protected $table = 'routes';
2025-07-06 16:51:09 +02:00
2025-07-05 23:54:43 +02:00
public $incrementing = false;
2025-07-06 16:51:09 +02:00
2025-07-05 23:54:43 +02:00
protected $fillable = [
'feed_id',
'platform_channel_id',
'is_active',
'priority',
'filters'
];
protected $casts = [
'is_active' => 'boolean',
'filters' => 'array'
];
2025-07-07 00:51:32 +02:00
/**
* @return BelongsTo<Feed, $this>
*/
2025-07-05 23:54:43 +02:00
public function feed(): BelongsTo
{
return $this->belongsTo(Feed::class);
}
2025-07-07 00:51:32 +02:00
/**
* @return BelongsTo<PlatformChannel, $this>
*/
2025-07-05 23:54:43 +02:00
public function platformChannel(): BelongsTo
{
return $this->belongsTo(PlatformChannel::class);
}
2025-07-07 00:51:32 +02:00
/**
* @return HasMany<Keyword, $this>
*/
2025-07-05 23:54:43 +02:00
public function keywords(): HasMany
{
return $this->hasMany(Keyword::class, 'feed_id', 'feed_id')
->where('platform_channel_id', $this->platform_channel_id);
}
2025-07-06 16:51:09 +02:00
}