Merge branch 'feature/aso-digital-card' into staging
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\Blameable;
|
||||
use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@@ -23,7 +24,7 @@ class Corporate extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'linking_rules' => 'array',
|
||||
'linking_rules' => AsArrayObject::class,
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
|
||||
@@ -141,7 +141,8 @@ class Member extends Model
|
||||
|
||||
public function currentPlan()
|
||||
{
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')->latest();
|
||||
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id')
|
||||
->latest(); // TODO Fix This
|
||||
}
|
||||
|
||||
public function policies()
|
||||
|
||||
@@ -31,4 +31,17 @@ class MemberPlan extends Model
|
||||
{
|
||||
return $this->belongsTo(CorporatePlan::class, 'plan_id', 'code');
|
||||
}
|
||||
|
||||
public function plan()
|
||||
{
|
||||
return $this->belongsTo(Plan::class, 'plan_id');
|
||||
}
|
||||
|
||||
public function scopeActive($q)
|
||||
{
|
||||
return $q
|
||||
->where('start', '<', now())
|
||||
->where('end', '>', now())
|
||||
->latest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
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;
|
||||
@@ -14,12 +15,99 @@ class Appointment extends Model
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
public $sStatusNames = [
|
||||
0 => 'Menunggu Pembayaran',
|
||||
1 => 'Pembayaran Terkonfirmasi', // Pembayaran Diterima
|
||||
2 => 'Ditolak',
|
||||
3 => 'Dibatalkan', // Canceled
|
||||
4 => 'Expired',
|
||||
];
|
||||
|
||||
public $sPaymentMethodName = [
|
||||
1 => 'Pribadi',
|
||||
2 => 'On-Site Payment',
|
||||
3 => 'OVO',
|
||||
4 => 'Asuransi',
|
||||
5 => 'Voucher',
|
||||
];
|
||||
|
||||
public $nIDJenisBookingNames = [
|
||||
1 => 'Rawat Jalan',
|
||||
2 => 'Telekonsultasi',
|
||||
3 => 'Chat Sekarang'
|
||||
];
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_appointment';
|
||||
|
||||
public function detail()
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
public $incrementing = false;
|
||||
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'nID',
|
||||
'nIDDokter',
|
||||
'nIDUser',
|
||||
'sStatus',
|
||||
'dCreateOn',
|
||||
'dUpdateOn',
|
||||
'dDeleteOn',
|
||||
];
|
||||
|
||||
protected $appends = [
|
||||
'status_name',
|
||||
'payment_method',
|
||||
'type'
|
||||
];
|
||||
|
||||
protected function statusName(): Attribute
|
||||
{
|
||||
return $this->hasOne(AppointmentDetail::class, '');
|
||||
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] ?? '-';
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
protected function type(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function($value) {
|
||||
return $this->nIDJenisBookingNames[$this->nIDJenisBooking] ?? '-';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,19 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class AppointmentDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tx_appointment_detail';
|
||||
protected $casts = [
|
||||
'sPaymentDetails' => 'array',
|
||||
];
|
||||
public function appointment()
|
||||
{
|
||||
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,4 +24,14 @@ class Dokter extends Model
|
||||
{
|
||||
return $this->hasMany(JadwalDokter::class, 'nIDDokter', 'nID');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'nIDUser', 'nID');
|
||||
}
|
||||
|
||||
public function speciality()
|
||||
{
|
||||
return $this->belongsTo(Speciality::class, 'nIDSpesialis', 'nID');
|
||||
}
|
||||
}
|
||||
|
||||
64
app/Models/OLDLMS/Livechat.php
Normal file
64
app/Models/OLDLMS/Livechat.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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',
|
||||
2 => 'Ditolak',
|
||||
3 => 'Selesai',
|
||||
4 => 'Expired',
|
||||
];
|
||||
|
||||
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', 'nID');
|
||||
}
|
||||
|
||||
|
||||
public function appointment()
|
||||
{
|
||||
return $this->belongsTo(Appointment::class, 'nIDAppointment', 'nID');
|
||||
}
|
||||
|
||||
public function healthCare()
|
||||
{
|
||||
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
|
||||
}
|
||||
}
|
||||
26
app/Models/OLDLMS/Speciality.php
Normal file
26
app/Models/OLDLMS/Speciality.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\OLDLMS;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Speciality extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tm_spesialis';
|
||||
|
||||
protected $primaryKey = 'nID';
|
||||
|
||||
public function dokter()
|
||||
{
|
||||
return $this->hasMany(Dokter::class, 'nIDSpesialis', 'nID');
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,46 @@
|
||||
|
||||
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 User extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tm_users';
|
||||
|
||||
protected $appends = [
|
||||
'full_name',
|
||||
];
|
||||
|
||||
protected function fullName(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: function ($value) {
|
||||
$names = [];
|
||||
if (!empty($this->sFirstName)) {
|
||||
array_push($names, $this->sFirstName);
|
||||
}
|
||||
if (!empty($this->sLastName)) {
|
||||
array_push($names, $this->sLastName);
|
||||
}
|
||||
|
||||
return implode(' ', $names);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
return $this->hasOne(UserDetail::class, 'nIDUser', 'nID');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,13 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class UserDetail extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
const CREATED_AT = 'dCreateOn';
|
||||
const UPDATED_AT = 'dUpdateOn';
|
||||
const DELETED_AT = 'dDeleteOn';
|
||||
|
||||
protected $connection = 'oldlms';
|
||||
|
||||
protected $table = 'tm_users_detail';
|
||||
|
||||
}
|
||||
|
||||
@@ -114,6 +114,11 @@ class Person extends Model
|
||||
return $this->hasOne(User::class, 'person_id');
|
||||
}
|
||||
|
||||
public function practitioner()
|
||||
{
|
||||
return $this->hasOne(Practitioner::class, 'person_id');
|
||||
}
|
||||
|
||||
public function appointmentParticipantables()
|
||||
{
|
||||
return $this->morphMany(AppointmentParticipant::class, 'participantable');
|
||||
|
||||
Reference in New Issue
Block a user