Update Doctor Resource

This commit is contained in:
R
2022-09-23 08:36:30 +07:00
parent a67afc27b6
commit 5fe1dc4bc6
36 changed files with 92181 additions and 15 deletions

View File

@@ -32,4 +32,24 @@ class Address extends Model
{
return $this->morphTo();
}
public function province()
{
return $this->belongsTo(Province::class, 'province_id');
}
public function city()
{
return $this->belongsTo(City::class, 'city_id');
}
public function district()
{
return $this->belongsTo(District::class, 'district_id');
}
public function village()
{
return $this->belongsTo(Village::class, 'village_id');
}
}

27
app/Models/City.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class City extends Model
{
use HasFactory;
protected $fillable = [
'id',
'province_id',
'name'
];
public function district()
{
return $this->hasMany(District::class, 'city_id');
}
public function province()
{
return $this->belongsTo(Province::class, 'province_id');
}
}

27
app/Models/District.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class District extends Model
{
use HasFactory;
protected $fillable = [
'id',
'city_id',
'name'
];
public function city()
{
return $this->belongsTo(City::class, 'city_id');
}
public function villages()
{
return $this->hasMany(Village::class, 'district_id');
}
}

25
app/Models/Practice.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Practice extends Model
{
use HasFactory;
protected $fillable = [
'practitioner_role_id',
'service_code',
'active',
'created_by',
'updated_by',
'deleted_by'
];
public function prices()
{
return $this->morphMany(Price::class, 'priceable');
}
}

View File

@@ -18,6 +18,26 @@ class PractitionerRole extends Model
'period_end',
'active',
];
public function getIsChatAvailableAttribute()
{
return $this->practices->where('service_code', 'chat')->where('active', 1)->count() >= 1;
}
public function getIsWalkinAvailableAttribute()
{
return $this->practices->where('service_code', 'walkin')->where('active', 1)->count() >= 1;
}
public function getIsVideoAvailableAttribute()
{
return $this->practices->where('service_code', 'video')->where('active', 1)->count() >= 1;
}
public function getIsInstantChatAvailableAttribute()
{
return $this->practices->where('service_code', 'instant-chat')->where('active', 1)->count() >= 1;
}
public function metas()
{
@@ -38,4 +58,14 @@ class PractitionerRole extends Model
{
return $this->belongsTo(Speciality::class, 'speciality_id');
}
public function practices()
{
return $this->hasMany(Practice::class, 'practitioner_role_id');
}
public function availabilities()
{
return $this->hasMany(PractitionerRoleAvailability::class, 'practitioner_role_id');
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PractitionerRoleAvailability extends Model
{
use HasFactory;
protected $fillable = [
'practitioner_role_id',
'all_day',
'start_time',
'end_time',
];
public function days()
{
return $this->hasMany('days');
}
public function practitionerRole()
{
return $this->belongsTo(PractitionerRole::class, 'practitioner_role_id');
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class PractitionerRoleAvailabilityDay extends Model
{
use HasFactory;
protected $fillable = [
'availability_id',
'day',
];
public function availability()
{
return $this->belongsTo(PractitionerRoleAvailability::class, 'availability_id');
}
}

31
app/Models/Price.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Price extends Model
{
use HasFactory;
protected $fillable = [
'priceable',
'price_group_id',
'price_gross',
'price_net',
'has_tax',
'discount_type',
'discount_percentage',
'discount_absolute',
'created_by',
'updated_by',
'deleted_by',
];
public function priceable()
{
return $this->morphTo();
}
}

21
app/Models/Province.php Normal file
View File

@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Province extends Model
{
use HasFactory;
protected $protected = [
'id',
'name'
];
public function cities()
{
return $this->hasMany(City::class, 'province_id');
}
}

22
app/Models/Village.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Village extends Model
{
use HasFactory;
protected $fillable = [
'id',
'district_id',
'name'
];
public function district()
{
return $this->belongsTo(District::class, 'district_id');
}
}