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

45 lines
1,016 B
PHP
Raw Normal View History

2025-07-05 02:19:59 +02:00
<?php
namespace App\Models;
use App\Enums\PlatformEnum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* @method static updateOrCreate(array $array, $instanceData)
* @method static where(string $string, mixed $operator)
* @property PlatformEnum $platform
* @property string $url
* @property string $name
* @property string $description
* @property boolean $is_active
*/
class PlatformInstance extends Model
{
protected $fillable = [
'platform',
'url',
'name',
'description',
'is_active'
];
protected $casts = [
'platform' => PlatformEnum::class,
'is_active' => 'boolean'
];
public function communities(): HasMany
{
return $this->hasMany(Community::class);
}
public static function findByUrl(PlatformEnum $platform, string $url): ?self
{
return static::where('platform', $platform)
->where('url', $url)
->first();
}
}