100 lines
2.1 KiB
PHP
100 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models\OLDLMS;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Appointment extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
const CREATED_AT = 'dCreateOn';
|
|
const UPDATED_AT = 'dUpdateOn';
|
|
const DELETED_AT = 'dDeleteOn';
|
|
|
|
public $sStatusNames = [
|
|
0 => 'Menunggu Konfirmasi',
|
|
1 => 'Diterima',
|
|
2 => 'Ditolak',
|
|
3 => 'Selesai',
|
|
4 => 'Dibatalkan',
|
|
];
|
|
|
|
public $sPaymentMethodName = [
|
|
1 => 'Transfer Bank',
|
|
2 => 'Kartu Kredit',
|
|
3 => 'Dompet Digital',
|
|
4 => 'Gerai Retail',
|
|
5 => 'QRIS',
|
|
];
|
|
|
|
protected $connection = 'oldlms';
|
|
|
|
protected $table = 'tx_appointment';
|
|
|
|
protected $primaryKey = 'nID';
|
|
|
|
public $incrementing = false;
|
|
|
|
protected $keyType = 'string';
|
|
|
|
protected $fillable = [
|
|
'nID',
|
|
'nIDDokter',
|
|
'nIDUser',
|
|
'sStatus',
|
|
'dCreateOn',
|
|
'dUpdateOn',
|
|
'dDeleteOn',
|
|
];
|
|
|
|
|
|
|
|
protected $appends = [
|
|
'status_name',
|
|
'payment_method'
|
|
];
|
|
|
|
protected function StatusName(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: function ($value) {
|
|
return $this->sStatusNames[$this->sStatus] ?? '-';
|
|
},
|
|
);
|
|
}
|
|
|
|
protected function PaymentMethod(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: function ($value) {
|
|
return $this->sPaymentMethodName[$this->sPaymentMethod] ?? '-';
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
public function appointmentDetail()
|
|
{
|
|
return $this->hasOne(AppointmentDetail::class, 'nIDAppointment', 'nID');
|
|
}
|
|
|
|
public function doctor()
|
|
{
|
|
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID');
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
|
}
|
|
|
|
public function healthCare()
|
|
{
|
|
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
|
|
}
|
|
}
|