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

54 lines
1.2 KiB
PHP

<?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
* @property array $filters
* @property Carbon $created_at
* @property Carbon $updated_at
* @method static create(array $array)
*/
class FeedPlatformChannel extends Pivot
{
protected $table = 'feed_platform_channels';
public $incrementing = false;
protected $fillable = [
'feed_id',
'platform_channel_id',
'is_active',
'priority',
'filters'
];
protected $casts = [
'is_active' => 'boolean',
'filters' => 'array'
];
public function feed(): BelongsTo
{
return $this->belongsTo(Feed::class);
}
public function platformChannel(): BelongsTo
{
return $this->belongsTo(PlatformChannel::class);
}
public function keywords(): HasMany
{
return $this->hasMany(Keyword::class, 'feed_id', 'feed_id')
->where('platform_channel_id', $this->platform_channel_id);
}
}