<?php

declare(strict_types=1);

namespace Plugins\Larablog\PaidContent\Models;

use App\Models\Article;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ArticleProduct extends Model
{
    protected $table = 'article_products';

    protected $fillable = [
        'article_id',
        'enabled',
        'price',
        'currency',
        'trial_mode',
        'trial_value',
    ];

    protected function casts(): array
    {
        return [
            'enabled' => 'boolean',
            'price' => 'decimal:2',
            'trial_value' => 'integer',
        ];
    }

    public function article(): BelongsTo
    {
        return $this->belongsTo(Article::class);
    }
}
