ldc-groupe/app/Models/NewsCategory.php
2025-11-12 16:48:20 +01:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Models;
use App\Enums\News\NewsCategoryEnum;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $news_id' News focused.
* @property \App\Enums\News\NewsCategoryEnum $category Category of the news.
* @property-read \Illuminate\Support\Carbon $created_at Date on which the news was created.
* @property-read \Illuminate\Support\Carbon $updated_at Date on which the news was updated.
*/
class NewsCategory extends Model
{
protected $table = 'category_news';
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = ['news_id', 'category'];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'category' => NewsCategoryEnum::class,
];
/**
* The relation with News
*
* @return BelongsTo
*/
public function news(): BelongsTo
{
return $this->belongsTo(News::class);
}
}