<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

class LandingPage extends Model
{
    protected $fillable = [
        'title',
        'slug',
        'product_id',
        'landing_price',
        'fb_pixel_id',
        'is_active',
        'template_style',
        'primary_color',
        'secondary_color',
        'gradient_angle',
        'font_family',
    ];

    protected $casts = [
        'is_active' => 'boolean',
        'landing_price' => 'decimal:2',
        'gradient_angle' => 'integer',
    ];

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

    public function sections(): HasMany
    {
        return $this->hasMany(LandingPageSection::class)->orderBy('sort_order', 'asc');
    }
}
