Changed channel categories from DB-backed Category records to a backed PHP enum

This commit is contained in:
2026-05-18 06:55:03 +03:30
parent 295a408965
commit 59e4ae60da
20 changed files with 221 additions and 130 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Enums\ChannelCategory;
use Database\Factories\ChannelFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -12,7 +13,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
#[Fillable([
'user_id',
'category_id',
'category',
'live_broadcast_id',
'slug',
'display_name',
@@ -32,6 +33,7 @@ class Channel extends Model
protected function casts(): array
{
return [
'category' => ChannelCategory::class,
'is_live' => 'boolean',
'viewer_count' => 'integer',
'suspended_at' => 'datetime',
@@ -48,11 +50,6 @@ class Channel extends Model
return $this->belongsTo(User::class);
}
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function streamKey(): HasOne
{
return $this->hasOne(StreamKey::class);