<?php

namespace App\Models;

use Database\Factories\ArticlePublicationFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;

/**
 * @property int $id
 * @property int $article_id
 * @property int $platform_channel_id
 * @property string $post_id
 * @property string $platform
 * @property string $published_by
 * @property array<string, mixed>|null $publication_data
 * @property Carbon $published_at
 * @property Carbon $created_at
 * @property Carbon $updated_at
 *
 * @method static create(array<string, mixed> $array)
 */
class ArticlePublication extends Model
{
    /** @use HasFactory<ArticlePublicationFactory> */
    use HasFactory;

    protected $fillable = [
        'article_id',
        'platform_channel_id',
        'post_id',
        'published_at',
        'published_by',
        'platform',
        'publication_data',
    ];

    protected $casts = [
        'published_at' => 'datetime',
        'publication_data' => 'array',
    ];

    /**
     * @return BelongsTo<Article, $this>
     */
    public function article(): BelongsTo
    {
        return $this->belongsTo(Article::class);
    }
}
