65 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Treatment extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'patient_id',
'appointment_id',
'user_id',
'treatment_code',
'name',
'description',
'sessions_count',
'sessions_completed',
'start_date',
'end_date',
'status',
'total_cost',
'currency_id',
'notes',
];
protected $casts = [
'start_date' => 'date',
'end_date' => 'date',
'sessions_count' => 'integer',
'sessions_completed' => 'integer',
'total_cost' => 'decimal:2',
];
public function patient(): BelongsTo
{
return $this->belongsTo(Patient::class);
}
public function appointment(): BelongsTo
{
return $this->belongsTo(Appointment::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function currency(): BelongsTo
{
return $this->belongsTo(Currency::class);
}
public function invoices(): HasMany
{
return $this->hasMany(Invoice::class);
}
}