Files
aso/app/Models/OLDLMS/Livechat.php
2024-04-30 17:03:44 +07:00

78 lines
1.7 KiB
PHP

<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
class Livechat extends Model
{
use HasFactory;
// public $sStatusNames = [
// 0 => 'Menunggu Konfirmasi',
// 1 => 'Diterima',
// 3 => 'Ditolak',
// 2 => 'Selesai',
// 4 => 'Expired',
// ];
public $sStatusNames = [
0 => 'Request TC',
1 => 'Accepted by Doctor but User not Payment',
3 => 'Decline by Doctor',
2 => 'Payment Success',
4 => 'Payment Expired',
5 => 'Cancel by Patient'
];
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_livechat';
protected $appends = [
'status_name',
];
protected function statusName(): Attribute
{
return Attribute::make(
get: function ($value) {
return $this->sStatusNames[$this->sStatus] ?? '-';
},
);
}
public function user()
{
return $this->belongsTo(User::class, 'nIDUser', 'nID');
}
public function doctor()
{
return $this->belongsTo(Dokter::class, 'nIDDokter', 'nIDUser');
}
public function appointment()
{
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
}
public function healthCare()
{
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
}
public function summary(){
return $this->belongsTo(LivechatSummary::class, 'nID', 'nIDLivechat');
}
}