<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Seo extends Model
{
    use HasFactory;

    protected $fillable = [
        'page_key',
        'title',
        'description',
        'og_image',
        'canonical',
        'robots',
        'schema_json',
        'meta_tags',
    ];

    protected $casts = [
        'meta_tags' => 'array',
        'schema_json' => 'array',
    ];

    /**
     * Get SEO by page_key
     */
    public static function forPage(string $pageKey): ?self
    {
        return self::where('page_key', $pageKey)->first();
    }
}