api doctor detail

This commit is contained in:
Muhammad Fajar
2022-10-27 14:37:12 +07:00
parent 0ece467d21
commit 2f84f43ae5
11 changed files with 245 additions and 106 deletions

View File

@@ -27,7 +27,7 @@ class Organization extends Model
public $appends = [
'meta'
];
public function setCodeAttribute($value)
{
$this->attributes['code'] = !empty($value) ? $value : Str::upper(Str::random('6'));

View File

@@ -18,6 +18,25 @@ class Practice extends Model
'deleted_by'
];
// public $appends = [
// 'price'
// ];
// public function getPriceAttribute()
// {
// $orgPrice = [];
// foreach ($this->prices as $price) {
// $orgPrice[$this->service_code] = $price->price_net;
// }
// return $orgPrice;
// }
public function getPriceAttribute()
{
return $this->prices->where('priceable_id', $this->id)->max('price_net');
}
public function prices()
{
return $this->morphMany(Price::class, 'priceable');

View File

@@ -39,39 +39,6 @@ class PractitionerRole extends Model
return $this->practices->where('service_code', 'instant-chat')->where('active', 1)->count() >= 1;
}
public function getDailyAvailabilitiesAttribute()
{
$schedules = [
'Senin' => [],
'Selasa' => [],
'Rabu' => [],
'Kamis' => [],
'Jumat' => [],
'Sabtu' => [],
'Minggu' => []
];
foreach ($this->availabilities as $availability) {
if (count($availability->days)) {
foreach ($availability->days as $day) {
$schedules[$day][] = $availability->start_time;
}
} else {
foreach ($schedules as $day => $times) {
$schedules[$day][] = $availability->start_time;
}
}
}
return $schedules;
}
public function metas()
{
return $this->morphMany(Meta::class, 'metaable');