added chart for displaying health metrix
This commit is contained in:
1 parent
a325919cd0
commit
87051e179d
22 files changed
+1383
-63
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Goal extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'title',
|
||||
'description',
|
||||
'start_date',
|
||||
'target_date',
|
||||
'current_progress_value',
|
||||
'target_value',
|
||||
'status',
|
||||
'priority_level',
|
||||
'unit',
|
||||
'icon_type',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'target_date' => 'date',
|
||||
'current_progress_value' => 'decimal:2',
|
||||
'target_value' => 'decimal:2',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function getProgressPercentageAttribute(): float
|
||||
{
|
||||
if ($this->target_value == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return min(100, ($this->current_progress_value / $this->target_value) * 100);
|
||||
}
|
||||
|
||||
public function getIsCompletedAttribute(): bool
|
||||
{
|
||||
return $this->status === 'completed' || $this->current_progress_value >= $this->target_value;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class HealthRecord extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'height',
|
||||
'recorded_at',
|
||||
'weight',
|
||||
'body_fat_percentage',
|
||||
@@ -26,6 +27,7 @@ class HealthRecord extends Model
|
||||
|
||||
protected $casts = [
|
||||
'recorded_at' => 'date',
|
||||
'height' => 'decimal:2',
|
||||
'weight' => 'decimal:2',
|
||||
'body_fat_percentage' => 'decimal:2',
|
||||
'bmi' => 'decimal:2',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class NotesMedia extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tournament_event_id',
|
||||
'note_text',
|
||||
'media_link',
|
||||
];
|
||||
|
||||
public function tournamentEvent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TournamentEvent::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class PerformanceResult extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'tournament_event_id',
|
||||
'description',
|
||||
'medal_type',
|
||||
'points',
|
||||
];
|
||||
|
||||
public function tournamentEvent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(TournamentEvent::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class TournamentEvent extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'title',
|
||||
'type',
|
||||
'sport',
|
||||
'date',
|
||||
'time',
|
||||
'location',
|
||||
'participants_count',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
'time' => 'datetime:H:i',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function performanceResults(): HasMany
|
||||
{
|
||||
return $this->hasMany(PerformanceResult::class);
|
||||
}
|
||||
|
||||
public function notesMedia(): HasMany
|
||||
{
|
||||
return $this->hasMany(NotesMedia::class);
|
||||
}
|
||||
}
|
||||
@@ -226,6 +226,22 @@ class User extends Authenticatable
|
||||
return $this->hasMany(HealthRecord::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tournament events for the user.
|
||||
*/
|
||||
public function tournamentEvents(): HasMany
|
||||
{
|
||||
return $this->hasMany(TournamentEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the goals for the user.
|
||||
*/
|
||||
public function goals(): HasMany
|
||||
{
|
||||
return $this->hasMany(Goal::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the email verification notification.
|
||||
* Override to prevent sending the default Laravel notification.
|
||||
|
||||
Reference in new issue
Block a user