24 lines
603 B
PHP
24 lines
603 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class ChatMenu extends Model
|
|
{
|
|
protected $table = 'chat_menus';
|
|
protected $fillable = ['nombre', 'mensaje', 'es_raiz', 'activo'];
|
|
protected $casts = ['es_raiz' => 'boolean', 'activo' => 'boolean'];
|
|
|
|
public function options(): HasMany
|
|
{
|
|
return $this->hasMany(ChatMenuOption::class, 'menu_id')->orderBy('orden');
|
|
}
|
|
|
|
public static function raiz(): ?self
|
|
{
|
|
return static::where('es_raiz', true)->where('activo', true)->first();
|
|
}
|
|
}
|