Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Route | |
50.00% |
2 / 4 |
|
66.67% |
2 / 3 |
4.12 | |
0.00% |
0 / 1 |
| feed | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| platformChannel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| keywords | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Database\Factories\RouteFactory; |
| 6 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 7 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 8 | use Illuminate\Database\Eloquent\Relations\HasMany; |
| 9 | use Illuminate\Database\Eloquent\Relations\Pivot; |
| 10 | use Illuminate\Support\Carbon; |
| 11 | |
| 12 | /** |
| 13 | * @property int $feed_id |
| 14 | * @property int $platform_channel_id |
| 15 | * @property bool $is_active |
| 16 | * @property int $priority |
| 17 | * @property array<string, mixed> $filters |
| 18 | * @property Carbon $created_at |
| 19 | * @property Carbon $updated_at |
| 20 | */ |
| 21 | class Route extends Pivot |
| 22 | { |
| 23 | /** @use HasFactory<RouteFactory> */ |
| 24 | use HasFactory; |
| 25 | |
| 26 | protected $table = 'routes'; |
| 27 | |
| 28 | public $incrementing = false; |
| 29 | |
| 30 | protected $fillable = [ |
| 31 | 'feed_id', |
| 32 | 'platform_channel_id', |
| 33 | 'is_active', |
| 34 | 'priority', |
| 35 | 'filters' |
| 36 | ]; |
| 37 | |
| 38 | protected $casts = [ |
| 39 | 'is_active' => 'boolean', |
| 40 | 'filters' => 'array' |
| 41 | ]; |
| 42 | |
| 43 | /** |
| 44 | * @return BelongsTo<Feed, $this> |
| 45 | */ |
| 46 | public function feed(): BelongsTo |
| 47 | { |
| 48 | return $this->belongsTo(Feed::class); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @return BelongsTo<PlatformChannel, $this> |
| 53 | */ |
| 54 | public function platformChannel(): BelongsTo |
| 55 | { |
| 56 | return $this->belongsTo(PlatformChannel::class); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @return HasMany<Keyword, $this> |
| 61 | */ |
| 62 | public function keywords(): HasMany |
| 63 | { |
| 64 | return $this->hasMany(Keyword::class, 'feed_id', 'feed_id') |
| 65 | ->where('platform_channel_id', $this->platform_channel_id); |
| 66 | } |
| 67 | } |