first commit

This commit is contained in:
Muhammad Herdy Iskandar
2024-07-26 10:33:44 +00:00
commit 7117a42b13
399 changed files with 19527 additions and 0 deletions

1
database/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.sqlite*

View File

@@ -0,0 +1,44 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @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;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}

View File

@@ -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::create('user_roles', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('user_roles');
}
};

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('username')->default(strtolower(Str::random(8)))->unique();
$table->string('email')->unique();
$table->foreignId('user_role_id')->constrained('user_roles')->cascadeOnDelete()->default(3);
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->default(Hash::make('password'));
$table->string('avatar_url')->default('avatar.jpg');
$table->json('custom_fields')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};

View File

@@ -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::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('password_reset_tokens');
}
};

View File

@@ -0,0 +1,32 @@
<?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('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('failed_jobs');
}
};

View File

@@ -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('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
$table->timestamp('last_used_at')->nullable();
$table->timestamp('expires_at')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('personal_access_tokens');
}
};

View File

@@ -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('cofasilitators', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('nim')->unique();
$table->string('email')->unique();
$table->string('phone')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cofasilitators');
}
};

View File

@@ -0,0 +1,29 @@
<?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('peletons', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->foreignId('cofasilitator_id')->constrained('cofasilitators')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('peletons');
}
};

View File

@@ -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::create('faculties', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('faculties');
}
};

View File

@@ -0,0 +1,29 @@
<?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('majors', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->foreignId('faculty_id')->constrained('faculties')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('majors');
}
};

View File

@@ -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('students', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('nim')->unique();
$table->string('image')->nullable();
$table->foreignId('major_id')->constrained('majors')->cascadeOnDelete();
$table->string('email')->unique();
$table->string('phone')->nullable();
$table->foreignId('peleton_id')->constrained('peletons');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('students');
}
};

View File

@@ -0,0 +1,29 @@
<?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('themes', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->year('year');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('themes');
}
};

View File

@@ -0,0 +1,27 @@
<?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('attendances', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('attendances');
}
};

View File

@@ -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
{
public function up()
{
Schema::create('breezy_sessions', function (Blueprint $table) {
$table->id();
$table->morphs('authenticatable');
$table->string('panel_id')->nullable();
$table->string('guard')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->timestamp('expires_at')->nullable();
$table->text('two_factor_secret')->nullable();
$table->text('two_factor_recovery_codes')->nullable();
$table->timestamp('two_factor_confirmed_at')->nullable();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('breezy_sessions');
}
};

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class AttendanceSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Database\Seeders;
use App\Models\Cofasilitator;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class CofasilitatorSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Cofasilitator::create([
'name' => 'Budi Santosa',
'nim' => '202200221',
'email' => 'budi@gmail.com',
'phone' => '08123456789',
]);
Cofasilitator::create([
'name' => 'Citra Bayanti',
'nim' => '202299013',
'email' => 'lala@gmail.com',
'phone' => '08123456789',
]);
Cofasilitator::create([
'name' => 'Monalika',
'nim' => '202221095',
'email' => 'monalika@gmail.com',
'phone' => '08123456789',
]);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace Database\Seeders;
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*/
public function run(): void
{
$this->call([
UserRoleSeeder::class,
]);
User::create([
'name' => 'Super Admin',
'username' => 'admin',
'email' => 'admin@m.co',
'user_role_id' => 1,
'email_verified_at' => now(),
'password' => Hash::make('password'),
'remember_token' => null,
'created_at' => now(),
'updated_at' => null,
]);
$this->call([
CofasilitatorSeeder::class,
PeletonSeeder::class,
FacultySeeder::class,
MajorSeeder::class,
StudentSeeder::class,
ThemeSeeder::class,
AttendanceSeeder::class,
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Seeders;
use App\Models\Faculty;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class FacultySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Faculty::create([
'name' => 'FAKULTAS KETENAGALISTRIKAN DAN ENERGI TERBARUKAN',
]);
Faculty::create([
'name' => 'FAKULTAS TELEMATIKA ENERGI',
]);
Faculty::create([
'name' => 'FAKULTAS TEKNOLOGI DAN BISNIS ENERGI',
]);
Faculty::create([
'name' => 'FAKULTAS TEKNOLOGI INFRASTRUKTUR DAN KEWILAYAHAN',
]);
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Database\Seeders;
use App\Models\Major;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class MajorSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Major::create([
'name' => 'S2 TEKNIK ELEKTRO',
'faculty_id' => 1,
]);
Major::create([
'name' => 'S1 TEKNIK ELEKTRO',
'faculty_id' => 1,
]);
Major::create([
'name' => 'S1 TEKNIK SISTEM ENERGI',
'faculty_id' => 1,
]);
Major::create([
'name' => 'S1 TEKNIK TELEKOMUNIKASI',
'faculty_id' => 1,
]);
Major::create([
'name' => 'S1 TEKNIK TEKNOLOGI LISTRIK',
'faculty_id' => 1,
]);
Major::create([
'name' => 'D3 TEKNOLOGI LISTRIK',
'faculty_id' => 1,
]);
Major::create([
'name' => 'S1 TEKNIK INFORMATIKA',
'faculty_id' => 2,
]);
Major::create([
'name' => 'S1 SISTEM INFORMASI',
'faculty_id' => 2,
]);
Major::create([
'name' => 'S1 TEKNIK MESIN',
'faculty_id' => 3,
]);
Major::create([
'name' => 'SI TEKNIK SIPIL',
'faculty_id' => 4,
]);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Seeders;
use App\Models\Peleton;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class PeletonSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Peleton::create([
'name' => 'Abhaya',
'cofasilitator_id' => 1,
]);
Peleton::create([
'name' => 'Lakshya',
'cofasilitator_id' => 2,
]);
Peleton::create([
'name' => 'Sanjaya',
'cofasilitator_id' => 3,
]);
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace Database\Seeders;
use App\Models\Student;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class StudentSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Student::create([
'name' => 'Rayyanza Malik Ahmad',
'nim' => '202411023',
'image' => 'default.jpg',
'major_id' => 2,
'email' => 'rayyanza@gmail.com',
'phone' => '08123456789',
'peleton_id' => 1
]);
Student::create([
'name' => 'Muhammad Rizky Akbar',
'nim' => '202431091',
'image' => 'default.jpg',
'major_id' => 7,
'email' => 'rizky@gmail.com',
'phone' => '08123456789',
'peleton_id' => 2
]);
Student::Create([
'name' => 'Mazaya Amania',
'nim' => '202432092',
'image' => 'default.jpg',
'major_id' => 8,
'email' => 'mazaya@gmail.com',
'phone' => '08123456789',
'peleton_id' => 3
]);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Database\Seeders;
use App\Models\Theme;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class ThemeSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Theme::create([
'name' => 'KAIZEN',
'year' => 2022,
]);
Theme::create([
'name' => 'RENAISANS',
'year' => 2023,
]);
Theme::create([
'name' => 'SANTULITAM',
'year' => 2024,
]);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Database\Seeders;
use App\Models\UserRole;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
class UserRoleSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
UserRole::create([
'name' => 'Super Admin',
]);
UserRole::create([
'name' => 'Admin',
]);
UserRole::create([
'name' => 'Mentor',
]);
UserRole::create([
'name' => 'Peserta',
]);
}
}