initial commit

This commit is contained in:
Debian
2026-06-03 04:18:36 +07:00
commit a5569ce2a0
220 changed files with 30797 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
*.sqlite*
@@ -0,0 +1,43 @@
<?php
namespace Database\Factories;
use App\Models\Consultation;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Consultation>
*/
class ConsultationFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Consultation::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
// Get a random patient from the users table
$patient = User::where('user_role', 'user')->inRandomOrder()->first();
// Get a random doctor from the users table
$doctor = User::where('user_role', 'doctor')->inRandomOrder()->first();
return [
'patient_id' => $patient->id,
'doctor_id' => $doctor->id,
'consultation_date' => $this->faker->dateTimeBetween('-1 year', '+1 year')->format('Y-m-d'),
'consultation_time' => $this->faker->time('H:i:s'),
'location' => $this->faker->city,
'consultation_status' => $this->faker->randomElement(['pending', 'declined', 'approved', 'finished']),
];
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use App\Models\User;
use Faker\Factory as FakerFactory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
protected $model = User::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$faker = FakerFactory::create('en_US');
return [
'user_role' => $faker->randomElement(['admin', 'user', 'doctor']),
'username' => $faker->userName,
'password' => Hash::make('password'),
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'telepon' => $faker->phoneNumber,
'alamat' => $faker->address,
'gender' => $faker->randomElement(['male', 'female']),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}
@@ -0,0 +1,54 @@
<?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('users', function (Blueprint $table) {
$table->id();
$table->string('user_role');
$table->string('username')->unique();
$table->string('password');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('telepon');
$table->string('alamat');
$table->string('gender');
$table->rememberToken();
$table->timestamps();
});
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
}
};
@@ -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('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,57 @@
<?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('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -0,0 +1,37 @@
<?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('health_datas', function (Blueprint $table) {
$table->id();
$table->foreignId('users_id')->constrained('users')->onDelete('cascade');
$table->date('birthdate');
$table->float('weight');
$table->float('height');
$table->integer('sleeptime');
$table->string('disease');
$table->string('food');
$table->string('alergi_makanan');
$table->string('obesity_status')->nullable();
$table->integer('calorie_recommendation')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('health_datas');
}
};
@@ -0,0 +1,34 @@
<?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('physical_activities', function (Blueprint $table) {
$table->id();
$table->foreignId('users_id')->constrained('users')->onDelete('cascade');
$table->timestamp('date');
$table->string('type');
$table->decimal('distance', 8, 2);
$table->integer('duration');
$table->decimal('avg_speed', 8, 2);
$table->integer('avg_steps');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('physical_activities');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddActiveStatusToUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
// if not exist, add the new column
if (!Schema::hasColumn('users', 'active_status')) {
$table->boolean('active_status')->default(0);
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('active_status');
});
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAvatarToUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
// if not exist, add the new column
if (!Schema::hasColumn('users', 'avatar')) {
$table->string('avatar')->default(config('chatify.user_avatar.default'));
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('avatar');
});
}
}
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddDarkModeToUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
// if not exist, add the new column
if (!Schema::hasColumn('users', 'dark_mode')) {
$table->boolean('dark_mode')->default(0);
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('dark_mode');
});
}
}
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddMessengerColorToUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
if (!Schema::hasColumn('users', 'messenger_color')) {
$table->string('messenger_color')->nullable();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('messenger_color');
});
}
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateChatifyFavoritesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ch_favorites', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->bigInteger('user_id');
$table->bigInteger('favorite_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ch_favorites');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateChatifyMessagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ch_messages', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->bigInteger('from_id');
$table->bigInteger('to_id');
$table->string('body',5000)->nullable();
$table->string('attachment')->nullable();
$table->boolean('seen')->default(false);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('ch_messages');
}
}
@@ -0,0 +1,36 @@
<?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('consultations', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('patient_id');
$table->unsignedBigInteger('doctor_id');
$table->date('consultation_date');
$table->time('consultation_time');
$table->string('location');
$table->string('consultation_status')->default('pending');
$table->timestamps();
$table->foreign('patient_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('doctor_id')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('consultations');
}
};
@@ -0,0 +1,34 @@
<?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('notifications', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id');
$table->unsignedBigInteger('consultation_id');
$table->string('message');
$table->boolean('is_read')->default(false);
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('consultation_id')->references('id')->on('consultations')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('notifications');
}
};
@@ -0,0 +1,36 @@
<?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('result', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('patient_id');
$table->unsignedBigInteger('doctor_id');
$table->unsignedBigInteger('consultation_id')->nullable();
$table->integer('jarak_lari');
$table->float('sleeptime');
$table->string('food');
$table->string('unrecommended_food');
$table->text('notes');
$table->timestamps();
$table->foreign('patient_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('doctor_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('consultation_id')->references('id')->on('consultations')->onDelete('set null');
});
}
public function down(): void
{
Schema::dropIfExists('result');
}
};
@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class ConsultationSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run()
{
\App\Models\Consultation::factory()->count(15)->create();
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Database\Seeders;
use App\Models\User;
use App\Models\Consultation;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
User::factory()->count(2)->create([
'user_role' => 'user',
]);
User::factory()->count(1)->create([
'user_role' => 'doctor',
]);
User::factory()->count(1)->create([
'user_role' => 'admin',
]);
$this->call([
ConsultationSeeder::class,
]);
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use Database\Factories\UserFactory;
class UserSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
UserFactory::new()->count(10)->create();
}
}