initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UUID;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
/**
|
||||
* Class Diagnose
|
||||
* @package App\Models
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
|
||||
class Diagnose extends Model
|
||||
{
|
||||
use HasFactory, UUID;
|
||||
protected $table = 'diagnoses';
|
||||
protected $fillable = ['patient_id', 'doctor_id', 'diagnoses','notes','is_verified','file'];
|
||||
|
||||
public function doctor() {
|
||||
return $this->belongsTo(Doctor::class, 'doctor_id', 'id');
|
||||
}
|
||||
|
||||
public function patient() {
|
||||
return $this->belongsTo(Patient::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UUID;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Eloquent;
|
||||
|
||||
/**
|
||||
* Class Doctor
|
||||
* @package App\Models
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
|
||||
class Doctor extends Model
|
||||
{
|
||||
use HasFactory, UUID;
|
||||
|
||||
protected $table = 'doctors';
|
||||
protected $fillable = ['user_id', 'fullname', 'address', 'phone', 'emergency_phone', 'gender', 'age'];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'string'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'pivot'
|
||||
];
|
||||
|
||||
public function user(){
|
||||
return $this->hasOne(User::class,'id','user_id');
|
||||
}
|
||||
|
||||
public function patients(){
|
||||
return $this->belongsToMany(Patient::class,'doctor_patients',
|
||||
'doctor_id','patient_id')->
|
||||
withTimestamps();
|
||||
}
|
||||
|
||||
public function pivot(){
|
||||
return $this->belongsToMany(Patient::class,'doctor_patients',
|
||||
'doctor_id','patient_id')->
|
||||
withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DoctorPatient extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'doctor_patients';
|
||||
protected $fillable = [
|
||||
'doctor_id',
|
||||
'patient_id'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'doctor_id' => 'string',
|
||||
'patient_id' => 'string'
|
||||
];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Heartwave extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\UUID;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Patient
|
||||
* @package App\Models
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Patient extends Model
|
||||
{
|
||||
use HasFactory, UUID;
|
||||
protected $table = 'patients';
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'fullname',
|
||||
'address',
|
||||
'phone',
|
||||
'emergency_phone',
|
||||
'gender',
|
||||
'age',
|
||||
'device_id',
|
||||
'condition'
|
||||
];
|
||||
protected $casts = [
|
||||
'id' => 'string'
|
||||
];
|
||||
|
||||
protected $hidden = [
|
||||
'pivot'
|
||||
];
|
||||
|
||||
public function doctors(){
|
||||
return $this->belongsToMany(Doctor::class,'doctor_patients',
|
||||
'patient_id','doctor_id')->
|
||||
withTimestamps();
|
||||
}
|
||||
|
||||
public function user(){
|
||||
return $this->hasOne(User::class,'id','user_id');
|
||||
}
|
||||
|
||||
public function diagnoses(){
|
||||
return $this->hasMany(Diagnose::class,'patient_id','id');
|
||||
}
|
||||
|
||||
public function pivot(){
|
||||
return $this->belongsToMany(Doctor::class,'doctor_patients',
|
||||
'patient_id','doctor_id')->
|
||||
withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Passport\HasApiTokens;
|
||||
use App\Traits\UUID;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Eloquent;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
* @package App\Models
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable, UUID, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'roles'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $guard_name = 'api';
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->hasOne(Doctor::class);
|
||||
}
|
||||
|
||||
public function role_data()
|
||||
{
|
||||
if (Auth::user()->hasRole('doctor')) {
|
||||
return $this->hasOne(Doctor::class);
|
||||
} elseif (Auth::user()->hasRole('patient')) {
|
||||
return $this->hasOne(Patient::class);
|
||||
}
|
||||
}
|
||||
|
||||
// public function admin() {
|
||||
// }
|
||||
|
||||
public function patient()
|
||||
{
|
||||
return $this->hasOne(Patient::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user