<?php

namespace App\Models;

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

class Persona extends Model
{
    use HasFactory;
    
    protected $table = 'personas';

    protected $fillable = [
        'dni',
        'nombre',
        'apellido',
        'cuil',
        'fechanac',
        'foto_id'
    ];

    public function Foto()
    {
        return $this->belongsTo(Foto::class, 'foto_id', 'id');
    }

    public function profesionales()
    {
        return $this->hasMany(Profesional::class, 'persona_id');
    }

    public function cliente()
    {
        return $this->hasOne(Cliente::class, 'persona_id', 'id');
    }

    public function telefonos()
    {
        return $this->belongsToMany(Telefono::class, 'personas_telefonos', 'persona_id', 'telefono_id');
    }
}
