<?php

namespace App\Models;

use App\Traits\Auditable;

use Illuminate\Database\Eloquent\Model;

/**
 * @property string $id
 * @property string $section_type_id
 * @property string $key
 * @property string $value
 * @property string $created_at
 * @property string $updated_at
 * @property SectionType $sectionType
 * @property SectionHistory[] $sectionHistories
 */
class SectionType extends Model
{
    use Auditable;
    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'section_type';

    /**
     * The "type" of the auto-incrementing ID.
     * 
     * @var string
     */
    protected $keyType = 'string';

    /**
     * Indicates if the IDs are auto-incrementing.
     * 
     * @var bool
     */
    public $incrementing = false;

    /**
     * @var array
     */
    protected $fillable = ['section_type_id', 'key', 'value','position', 'created_at', 'updated_at'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function sectionType()
    {
        return $this->belongsTo('App\Models\SectionType');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function sectionHistories()
    {
        return $this->hasMany('App\Models\SectionHistory');
    }

    /**
     * 
     */
    public function noHaveChildres(){
        return (count($this->get()->where("section_type_id",$this->id)->all()) == 0);
    }
}
