added attendance and fixed body composition

This commit is contained in:
ghassan committed 2026-01-24 13:11:20 +03:00
1 parent 87051e179d
commit 125e1c34af
8 files changed
+293 -4

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('attendance_records', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->foreignId('tenant_id')->constrained()->onDelete('cascade');
$table->string('member_type')->default('Basic'); // Premium, Basic, Student, Family
$table->datetime('check_in_time');
$table->datetime('check_out_time')->nullable();
$table->string('duration')->nullable(); // e.g., "1h 45m"
$table->string('activity'); // e.g., "Gym Floor", "Yoga Class"
$table->enum('status', ['active', 'completed'])->default('active');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('attendance_records');
}
};
@@ -0,0 +1,33 @@
<?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('members_attendance', function (Blueprint $table) {
$table->id();
$table->foreignId('member_id')->constrained('users')->onDelete('cascade');
$table->string('session_type'); // e.g. Personal Training, Group Fitness, Yoga, Pilates
$table->string('trainer_name');
$table->datetime('session_datetime');
$table->enum('status', ['completed', 'no_show']);
$table->text('notes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('members_attendance');
}
};
+79
View File
@@ -0,0 +1,79 @@
<?php
namespace Database\Seeders;
use App\Models\Attendance;
use App\Models\User;
use App\Models\Tenant;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class AttendanceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$user = User::where('email', '[email protected]')->first();
if (!$user) {
return; // Skip if test data not found
}
$attendanceRecords = [
[
'member_id' => $user->id,
'session_type' => 'Personal Training',
'trainer_name' => 'John Smith',
'session_datetime' => now()->subDays(1)->setTime(10, 0),
'status' => 'completed',
'notes' => 'Great session, focused on upper body strength',
],
[
'member_id' => $user->id,
'session_type' => 'Group Fitness',
'trainer_name' => 'Sarah Johnson',
'session_datetime' => now()->subDays(2)->setTime(18, 30),
'status' => 'completed',
'notes' => 'High-intensity cardio workout',
],
[
'member_id' => $user->id,
'session_type' => 'Yoga',
'trainer_name' => 'Mike Wilson',
'session_datetime' => now()->subDays(3)->setTime(9, 0),
'status' => 'no_show',
'notes' => 'Member did not attend scheduled session',
],
[
'member_id' => $user->id,
'session_type' => 'Pilates',
'trainer_name' => 'Emily Davis',
'session_datetime' => now()->subDays(4)->setTime(17, 0),
'status' => 'completed',
'notes' => 'Core strengthening and flexibility',
],
[
'member_id' => $user->id,
'session_type' => 'Personal Training',
'trainer_name' => 'John Smith',
'session_datetime' => now()->subDays(5)->setTime(14, 0),
'status' => 'completed',
'notes' => 'Lower body strength training',
],
[
'member_id' => $user->id,
'session_type' => 'Group Fitness',
'trainer_name' => 'Sarah Johnson',
'session_datetime' => now()->subDays(6)->setTime(19, 0),
'status' => 'no_show',
'notes' => 'Late cancellation',
],
];
foreach ($attendanceRecords as $record) {
Attendance::create($record);
}
}
}
+3
View File
@@ -65,5 +65,8 @@ class DatabaseSeeder extends Seeder
'status' => 'pending',
'due_date' => now()->addDays(15),
]);
// Seed attendance data
$this->call(AttendanceSeeder::class);
}
}