95 lines
2.1 KiB
PHP
95 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
class Turno extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'turnos';
|
|
|
|
protected $fillable = [
|
|
'inicio',
|
|
'correo',
|
|
'nombrecompleto',
|
|
'descripcion',
|
|
'cliente_id',
|
|
'estadoturno_id',
|
|
'agenda_id',
|
|
'profesional_id',
|
|
'servicio_id',
|
|
'modalidad_id',
|
|
];
|
|
|
|
protected $casts = [
|
|
'inicio' => 'datetime',
|
|
];
|
|
|
|
public function estadoTurno()
|
|
{
|
|
return $this->belongsTo(EstadoTurno::class, 'estadoturno_id', 'id');
|
|
}
|
|
|
|
public function cliente()
|
|
{
|
|
return $this->belongsTo(Cliente::class, 'cliente_id', 'id');
|
|
}
|
|
public function agenda()
|
|
{
|
|
return $this->belongsTo(Agenda::class, 'agenda_id', 'id');
|
|
}
|
|
|
|
public function profesional()
|
|
{
|
|
return $this->belongsTo(Profesional::class, 'profesional_id', 'id');
|
|
}
|
|
|
|
public function servicio()
|
|
{
|
|
return $this->belongsTo(Servicio::class, 'servicio_id', 'id');
|
|
}
|
|
|
|
public function modalidad()
|
|
{
|
|
return $this->belongsTo(Modalidad::class, 'modalidad_id', 'id');
|
|
}
|
|
|
|
public function confirmar()
|
|
{
|
|
$this->estadoturno_id = 1; // ID del estado Confirmado (dato maestro)
|
|
$this->save();
|
|
return $this;
|
|
}
|
|
|
|
public function cancelar()
|
|
{
|
|
$this->estadoturno_id = 2; // ID del estado Cancelado (dato maestro)
|
|
$this->save();
|
|
return $this;
|
|
}
|
|
|
|
public function reprogramar()
|
|
{
|
|
$this->estadoturno_id = 3; // ID del estado Reprogramado (dato maestro)
|
|
$this->save();
|
|
return $this;
|
|
}
|
|
|
|
public function clienteAusente()
|
|
{
|
|
$this->estadoturno_id = 4; // ID del estado Cliente Ausente (dato maestro)
|
|
$this->save();
|
|
return $this;
|
|
}
|
|
|
|
public function clientePresente()
|
|
{
|
|
$this->estadoturno_id = 5; // ID del estado Cliente Presente (dato maestro)
|
|
$this->save();
|
|
return $this;
|
|
}
|
|
|
|
}
|