initial commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Chatify\Traits\UUID;
|
||||
|
||||
class ChFavorite extends Model
|
||||
{
|
||||
use UUID;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Chatify\Traits\UUID;
|
||||
|
||||
class ChMessage extends Model
|
||||
{
|
||||
use UUID;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Consultation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
'consultation_date',
|
||||
'consultation_time',
|
||||
'location',
|
||||
'consultation_status',
|
||||
];
|
||||
|
||||
public function patient()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'patient_id');
|
||||
}
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'doctor_id');
|
||||
}
|
||||
|
||||
public function result()
|
||||
{
|
||||
return $this->hasOne(Result::class, 'consultation_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class HealthData extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $table = 'health_datas';
|
||||
|
||||
protected $fillable = [
|
||||
'users_id',
|
||||
'birthdate',
|
||||
'weight',
|
||||
'height',
|
||||
'sleeptime',
|
||||
'disease',
|
||||
'food',
|
||||
'alergi_makanan',
|
||||
'obesity_status',
|
||||
'calorie_recommendation',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'users_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Notification extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'consultation_id',
|
||||
'message',
|
||||
'is_read',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function consultation()
|
||||
{
|
||||
return $this->belongsTo(Consultation::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PhysicalActivity extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'users_id',
|
||||
//'id',
|
||||
'date',
|
||||
'type',
|
||||
'distance',
|
||||
'duration',
|
||||
'avg_speed',
|
||||
'avg_steps',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'users_id');
|
||||
}
|
||||
|
||||
public function calculateCaloriesBurned()
|
||||
{
|
||||
$user = $this->user;
|
||||
$healthData = $user->healthDatas()->latest()->first();
|
||||
$weight = $healthData ? $healthData->weight : 0;
|
||||
|
||||
$duration = $this->duration / 3600; // Convert duration from seconds to minutes
|
||||
$caloriesBurned = 0;
|
||||
|
||||
switch ($this->type) {
|
||||
case 'bicycle':
|
||||
$caloriesBurned = 0.061 * $weight * $duration;
|
||||
break;
|
||||
case 'Run':
|
||||
$caloriesBurned = 9.8 * $weight * $duration;
|
||||
break;
|
||||
case 'walk':
|
||||
$caloriesBurned = 0.035 * $weight * $duration;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return round($caloriesBurned, 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Result extends Model
|
||||
{
|
||||
protected $table = 'result';
|
||||
|
||||
protected $fillable = [
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
'consultation_id',
|
||||
'jarak_lari',
|
||||
'sleeptime',
|
||||
'food',
|
||||
'unrecommended_food',
|
||||
'notes',
|
||||
];
|
||||
|
||||
public function patient()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'patient_id');
|
||||
}
|
||||
|
||||
public function doctor()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'doctor_id');
|
||||
}
|
||||
|
||||
public function consultation()
|
||||
{
|
||||
return $this->belongsTo(Consultation::class, 'consultation_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'user_role',
|
||||
'username',
|
||||
'password',
|
||||
'name',
|
||||
'email',
|
||||
'telepon',
|
||||
'alamat',
|
||||
'gender'
|
||||
];
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function physicalActivities()
|
||||
{
|
||||
return $this->hasMany(PhysicalActivity::class, 'users_id');
|
||||
}
|
||||
|
||||
public function healthDatas()
|
||||
{
|
||||
return $this->hasMany(HealthData::class, 'users_id');
|
||||
}
|
||||
|
||||
public function patientResults()
|
||||
{
|
||||
return $this->hasMany(Result::class, 'patient_id');
|
||||
}
|
||||
|
||||
public function doctorResults()
|
||||
{
|
||||
return $this->hasMany(Result::class, 'doctor_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user