<?php

namespace App\Indexer;

use Fobia\Database\SphinxConnection\Eloquent\Model;

class SeoIndex extends Model
{
    protected $table = 'seoes_index';

    protected $casts = [
        'id'        => 'integer',
        'post_id'      => 'integer',
        'is_amp'     => 'integer',
    ];

    /**
     * Safe query - returns null if Manticore/Sphinx index unavailable
     */
    public static function safeFindByUri(string $uri)
    {
        try {
            return static::where('uri', $uri)->first();
        } catch (\Exception $e) {
            return null;
        }
    }
}
