added chart for displaying health metrix

This commit is contained in:
ghassan committed 2026-01-24 12:40:01 +03:00
1 parent a325919cd0
commit 87051e179d
22 files changed
+1383 -63

No files matched your search

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tournament_events', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('title');
$table->enum('type', ['championship', 'tournament']);
$table->string('sport');
$table->date('date');
$table->time('time')->nullable();
$table->string('location')->nullable();
$table->integer('participants_count')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tournament_events');
}
};
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('performance_results', function (Blueprint $table) {
$table->id();
$table->foreignId('tournament_event_id')->constrained()->onDelete('cascade');
$table->text('description')->nullable();
$table->enum('medal_type', ['1st', '2nd', '3rd', 'special']);
$table->integer('points')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('performance_results');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('notes_media', function (Blueprint $table) {
$table->id();
$table->foreignId('tournament_event_id')->constrained()->onDelete('cascade');
$table->text('note_text')->nullable();
$table->string('media_link')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notes_media');
}
};
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('goals', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('title');
$table->text('description')->nullable();
$table->date('start_date');
$table->date('target_date');
$table->decimal('current_progress_value', 8, 2)->default(0);
$table->decimal('target_value', 8, 2);
$table->enum('status', ['active', 'completed'])->default('active');
$table->enum('priority_level', ['high', 'medium', 'low'])->default('medium');
$table->string('unit')->nullable(); // e.g., lbs, min, kg
$table->string('icon_type')->default('target'); // e.g., target, dumbbell, clock
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('goals');
}
};
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('health_records', function (Blueprint $table) {
$table->decimal('height', 5, 2)->nullable()->after('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('health_records', function (Blueprint $table) {
$table->dropColumn('height');
});
}
};
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Goal;
use App\Models\User;
class GoalSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Get the first user or create sample goals for existing users
$users = User::all();
if ($users->isEmpty()) {
return; // No users to seed goals for
}
foreach ($users as $user) {
// Create sample goals
Goal::create([
'user_id' => $user->id,
'title' => 'Weight Loss Goal',
'description' => 'Reach target weight of 170 lbs.',
'start_date' => now()->subDays(30),
'target_date' => now()->addDays(60),
'current_progress_value' => 175.0,
'target_value' => 170.0,
'status' => 'active',
'priority_level' => 'high',
'unit' => 'lbs',
'icon_type' => 'target',
]);
Goal::create([
'user_id' => $user->id,
'title' => 'Bench Press Strength',
'description' => 'Increase bench press to 200 lbs.',
'start_date' => now()->subDays(15),
'target_date' => now()->addDays(45),
'current_progress_value' => 180.0,
'target_value' => 200.0,
'status' => 'active',
'priority_level' => 'medium',
'unit' => 'lbs',
'icon_type' => 'dumbbell',
]);
Goal::create([
'user_id' => $user->id,
'title' => '5K Running Time',
'description' => 'Complete 5K run in under 25 minutes.',
'start_date' => now()->subDays(20),
'target_date' => now()->addDays(40),
'current_progress_value' => 27.5,
'target_value' => 25.0,
'status' => 'active',
'priority_level' => 'medium',
'unit' => 'min',
'icon_type' => 'clock',
]);
Goal::create([
'user_id' => $user->id,
'title' => 'Daily Steps Goal',
'description' => 'Walk 10,000 steps per day.',
'start_date' => now()->subDays(10),
'target_date' => now()->addDays(20),
'current_progress_value' => 8500.0,
'target_value' => 10000.0,
'status' => 'completed',
'priority_level' => 'low',
'unit' => 'steps',
'icon_type' => 'target',
]);
}
}
}
+110
View File
@@ -0,0 +1,110 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use App\Models\TournamentEvent;
use App\Models\PerformanceResult;
use App\Models\NotesMedia;
class TournamentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Get the first user or create one
$user = User::first() ?? User::factory()->create();
// Create tournament events
$events = [
[
'title' => 'National Swimming Championship 2023',
'type' => 'championship',
'sport' => 'Swimming',
'date' => '2023-08-15',
'time' => '10:00',
'location' => 'Olympic Pool, Bahrain',
'participants_count' => 50,
],
[
'title' => 'Regional Basketball Tournament',
'type' => 'tournament',
'sport' => 'Basketball',
'date' => '2023-06-20',
'time' => '14:00',
'location' => 'Sports Arena, Manama',
'participants_count' => 32,
],
[
'title' => 'Youth Football League Finals',
'type' => 'championship',
'sport' => 'Football',
'date' => '2023-05-10',
'time' => '16:00',
'location' => 'National Stadium',
'participants_count' => 16,
],
[
'title' => 'Tennis Open Championship',
'type' => 'championship',
'sport' => 'Tennis',
'date' => '2023-04-05',
'time' => '09:00',
'location' => 'Tennis Club, Bahrain',
'participants_count' => 24,
],
];
foreach ($events as $eventData) {
$event = TournamentEvent::create(array_merge($eventData, ['user_id' => $user->id]));
// Add performance results
if ($event->sport === 'Swimming') {
PerformanceResult::create([
'tournament_event_id' => $event->id,
'description' => '100m Freestyle - Personal Best',
'medal_type' => '1st',
'points' => 100,
]);
} elseif ($event->sport === 'Basketball') {
PerformanceResult::create([
'tournament_event_id' => $event->id,
'description' => 'MVP Award',
'medal_type' => 'special',
'points' => 50,
]);
} elseif ($event->sport === 'Football') {
PerformanceResult::create([
'tournament_event_id' => $event->id,
'description' => 'Golden Boot Winner',
'medal_type' => 'special',
'points' => 75,
]);
PerformanceResult::create([
'tournament_event_id' => $event->id,
'description' => 'Championship Title',
'medal_type' => '1st',
'points' => 200,
]);
} elseif ($event->sport === 'Tennis') {
PerformanceResult::create([
'tournament_event_id' => $event->id,
'description' => 'Singles Final',
'medal_type' => '2nd',
'points' => 80,
]);
}
// Add notes/media
NotesMedia::create([
'tournament_event_id' => $event->id,
'note_text' => 'Outstanding performance in the championship. Set new personal records.',
'media_link' => 'https://example.com/ceremony-photo.jpg',
]);
}
}
}