36 lines
1.7 KiB
PHP
36 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Facades\CommonService;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class HealthLog extends Model
|
|
{
|
|
use HasFactory;
|
|
public const DESC_KET = ['Weight.1002','Weight.1003','Weight.1004','Weight.1005','Weight.1006','Bodyfat.1002','Bodyfat.1003','Bodyfat.1004','Bodyfat.1005','BMI.1002','BMI.1003','BMI.1004','BMI.1005','Bone.1002','Bone.1003','Bone.1004','HeartIndex.1002','HeartIndex.1003','HeartIndex.1004','HeartRate.1002','HeartRate.1003','HeartRate.1004','HeartRate.1005','HeartRate.1006','Muscle.1002','Muscle.1003','Muscle.1004','Sinew.1002','Sinew.1003','Sinew.1004','Protein.1002','Protein.1003','Protein.1004','Subfat.1002','Subfat.1003','Subfat.1004','Visfat.1002','Visfat.1003','Visfat.1004','Water.1002','Water.1003','Water.1004', 'Score.1002', 'Score.1003', 'Score.1004', 'Score.1005','LBM.1002','BodyAge.1002', 'BodyAge.1003','BMR.1002','BMR.1003','BodyShape.1002','BodyShape.1003','BodyShape.1004','BodyShape.1005','BodyShape.1006','BodyShape.1007', 'BodyShape.1008', 'BodyShape.1009', 'BodyShape.1010'];
|
|
public function healthKind()
|
|
{
|
|
return $this->hasOne(HealthKind::class, 'e_name', 'e_name');
|
|
}
|
|
|
|
public function healthLevel()
|
|
{
|
|
return $this->hasOne(HealthLevel::class, 'desc_key', 'desc_key');
|
|
}
|
|
|
|
public function healthLevels()
|
|
{
|
|
return $this->hasMany(HealthLevel::class, 'e_name', 'e_name');
|
|
}
|
|
|
|
protected function boundariesType(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn ($value) => json_decode($value, true)?:[],
|
|
);
|
|
}
|
|
}
|