<?php

namespace App\Indexer;

use Fobia\Database\SphinxConnection\Eloquent\Model;

class AreaIndex extends Model
{
    protected $table = 'areas_index';

    protected $casts = [
        'id'           => 'integer',
        'show_top'     => 'integer',
        'show_search'  => 'integer',
        'parent_id'    => 'integer',
        'position'     => 'integer',
        'is_activated' => 'integer',
    ];

    public function parent() {
        return $this->belongsTo(AreaIndex::class, 'parent_id', 'id')->select('id', 'name', 'slug', 'parent_id')->where('is_activated', true);
    }
}
