Initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[compose.yaml]
|
||||||
|
indent_size = 4
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
APP_LOCALE=en
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
# PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=sqlite
|
||||||
|
# DB_HOST=127.0.0.1
|
||||||
|
# DB_PORT=3306
|
||||||
|
# DB_DATABASE=laravel
|
||||||
|
# DB_USERNAME=root
|
||||||
|
# DB_PASSWORD=
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
.styleci.yml export-ignore
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.nova
|
||||||
|
/.phpunit.cache
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
||||||
|
/auth.json
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/pail
|
||||||
|
/storage/app/*
|
||||||
|
!/storage/app/.gitignore
|
||||||
|
!/storage/app/private/
|
||||||
|
/storage/app/private/*
|
||||||
|
!/storage/app/private/.gitignore
|
||||||
|
!/storage/app/private/regions/
|
||||||
|
!/storage/app/private/regions/*.csv
|
||||||
|
!/storage/app/regions/
|
||||||
|
!/storage/app/regions/*.csv
|
||||||
|
!/storage/app/public/
|
||||||
|
/storage/app/public/*
|
||||||
|
!/storage/app/public/.gitignore
|
||||||
|
/storage/framework/cache/*
|
||||||
|
!/storage/framework/cache/.gitignore
|
||||||
|
!/storage/framework/cache/data/
|
||||||
|
/storage/framework/cache/data/*
|
||||||
|
!/storage/framework/cache/data/.gitignore
|
||||||
|
/storage/framework/sessions/*
|
||||||
|
!/storage/framework/sessions/.gitignore
|
||||||
|
/storage/framework/testing/*
|
||||||
|
!/storage/framework/testing/.gitignore
|
||||||
|
/storage/framework/views/*
|
||||||
|
!/storage/framework/views/.gitignore
|
||||||
|
/storage/logs/*
|
||||||
|
!/storage/logs/.gitignore
|
||||||
|
/vendor
|
||||||
|
_ide_helper.php
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
Thumbs.db
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## About Laravel
|
||||||
|
|
||||||
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
|
|
||||||
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
|
## Learning Laravel
|
||||||
|
|
||||||
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||||
|
|
||||||
|
In addition, [Laracasts](https://laracasts.com) contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
|
You can also watch bite-sized lessons with real-world projects on [Laravel Learn](https://laravel.com/learn), where you will be guided through building a Laravel application from scratch while learning PHP fundamentals.
|
||||||
|
|
||||||
|
## Agentic Development
|
||||||
|
|
||||||
|
Laravel's predictable structure and conventions make it ideal for AI coding agents like Claude Code, Cursor, and GitHub Copilot. Install [Laravel Boost](https://laravel.com/docs/ai) to supercharge your AI workflow:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer require laravel/boost --dev
|
||||||
|
|
||||||
|
php artisan boost:install
|
||||||
|
```
|
||||||
|
|
||||||
|
Boost provides your agent 15+ tools and skills that help agents build Laravel applications while following best practices.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Student;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class GenerateStudentSelfServiceCodes extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'students:generate-self-service-codes {--reset : Generate ulang walau kode sudah ada}';
|
||||||
|
protected $description = 'Generate kode akses self-service untuk siswa';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$students = Student::query()
|
||||||
|
->whereNull('deleted_at')
|
||||||
|
->when(! $this->option('reset'), fn ($query) => $query->whereNull('self_service_access_code'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($students->isEmpty()) {
|
||||||
|
$this->info('Tidak ada siswa yang perlu dibuatkan kode akses.');
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bar = $this->output->createProgressBar($students->count());
|
||||||
|
$bar->start();
|
||||||
|
|
||||||
|
foreach ($students as $student) {
|
||||||
|
$student->forceFill([
|
||||||
|
'self_service_access_code' => $this->generateUniqueCode(),
|
||||||
|
'self_service_code_generated_at' => now(),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
$bar->advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
$bar->finish();
|
||||||
|
$this->newLine(2);
|
||||||
|
$this->info('Kode akses self-service berhasil digenerate.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateUniqueCode(): string
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
$code = strtoupper(Str::random(8));
|
||||||
|
} while (Student::where('self_service_access_code', $code)->exists());
|
||||||
|
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ImportRegionsCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'regions:import {--fresh : Kosongkan tabel wilayah sebelum import} {--download : Unduh ulang dataset CSV terbaru sebelum import}';
|
||||||
|
protected $description = 'Import master wilayah Indonesia dari dataset publik dengan bulk insert dari CSV';
|
||||||
|
|
||||||
|
protected string $disk = 'local';
|
||||||
|
protected string $datasetDir = 'regions';
|
||||||
|
protected string $baseUrl = 'https://raw.githubusercontent.com/emsifa/api-wilayah-indonesia/master/data';
|
||||||
|
protected int $chunkSize = 1000;
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->option('download') || ! $this->datasetExists()) {
|
||||||
|
$this->downloadDatasets();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->datasetExists()) {
|
||||||
|
$this->error('Dataset wilayah tidak ditemukan setelah proses download.');
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->option('fresh')) {
|
||||||
|
$this->truncateTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->importCsv('provinces', ['id', 'name'], ['id']);
|
||||||
|
$this->importCsv('regencies', ['id', 'province_id', 'name'], ['id']);
|
||||||
|
$this->importCsv('districts', ['id', 'regency_id', 'name'], ['id']);
|
||||||
|
$this->importCsv('villages', ['id', 'district_id', 'name'], ['id']);
|
||||||
|
|
||||||
|
$counts = [
|
||||||
|
'provinces' => DB::table('provinces')->count(),
|
||||||
|
'regencies' => DB::table('regencies')->count(),
|
||||||
|
'districts' => DB::table('districts')->count(),
|
||||||
|
'villages' => DB::table('villages')->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->info('Import wilayah selesai.');
|
||||||
|
foreach ($counts as $table => $count) {
|
||||||
|
$this->line(sprintf('- %s: %s', $table, number_format($count, 0, ',', '.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->error('Import wilayah gagal: ' . $e->getMessage());
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function datasetExists(): bool
|
||||||
|
{
|
||||||
|
foreach (['provinces.csv', 'regencies.csv', 'districts.csv', 'villages.csv'] as $file) {
|
||||||
|
if (! Storage::disk($this->disk)->exists($this->datasetDir . '/' . $file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function downloadDatasets(): void
|
||||||
|
{
|
||||||
|
Storage::disk($this->disk)->makeDirectory($this->datasetDir);
|
||||||
|
|
||||||
|
$http = Http::timeout(120)->retry(3, 1000);
|
||||||
|
|
||||||
|
foreach (['provinces.csv', 'regencies.csv', 'districts.csv', 'villages.csv'] as $file) {
|
||||||
|
$this->line('Mengunduh ' . $file . ' ...');
|
||||||
|
$content = $http->get($this->baseUrl . '/' . $file)->throw()->body();
|
||||||
|
Storage::disk($this->disk)->put($this->datasetDir . '/' . $file, $content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function truncateTables(): void
|
||||||
|
{
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||||
|
DB::table('villages')->truncate();
|
||||||
|
DB::table('districts')->truncate();
|
||||||
|
DB::table('regencies')->truncate();
|
||||||
|
DB::table('provinces')->truncate();
|
||||||
|
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function importCsv(string $table, array $columns, array $uniqueBy): void
|
||||||
|
{
|
||||||
|
$path = Storage::disk($this->disk)->path($this->datasetDir . '/' . $table . '.csv');
|
||||||
|
$handle = fopen($path, 'r');
|
||||||
|
|
||||||
|
if ($handle === false) {
|
||||||
|
throw new \RuntimeException('Tidak bisa membuka file dataset: ' . $path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line('Import ' . $table . ' ...');
|
||||||
|
|
||||||
|
$rows = [];
|
||||||
|
while (($data = fgetcsv($handle)) !== false) {
|
||||||
|
if ($data === [null] || count($data) < count($columns)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = [];
|
||||||
|
foreach ($columns as $index => $column) {
|
||||||
|
$row[$column] = isset($data[$index]) ? trim((string) $data[$index]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($row['id'] ?? null) === null || $row['id'] === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows[$row['id']] = $row;
|
||||||
|
|
||||||
|
if (count($rows) >= $this->chunkSize) {
|
||||||
|
DB::table($table)->upsert(array_values($rows), $uniqueBy, $columns);
|
||||||
|
$rows = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($handle);
|
||||||
|
|
||||||
|
if ($rows !== []) {
|
||||||
|
DB::table($table)->upsert(array_values($rows), $uniqueBy, $columns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\StudentAcademicHistory;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class AcademicYearController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
|
||||||
|
$academicYears = AcademicYear::withCount(['classes', 'students'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('start_year', 'like', "%{$search}%")
|
||||||
|
->orWhere('end_year', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('academic-years.index', compact('academicYears', 'search'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('academic-years.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:50', 'unique:academic_years,name'],
|
||||||
|
'start_year' => ['required', 'integer', 'digits:4'],
|
||||||
|
'end_year' => ['required', 'integer', 'digits:4', 'gte:start_year'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
if ($data['is_active']) {
|
||||||
|
AcademicYear::query()->update(['is_active' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
AcademicYear::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('academic-years.index')->with('success', 'Tahun angkatan berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(AcademicYear $academicYear): RedirectResponse
|
||||||
|
{
|
||||||
|
return redirect()->route('academic-years.edit', $academicYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(AcademicYear $academicYear): View
|
||||||
|
{
|
||||||
|
return view('academic-years.edit', [
|
||||||
|
'academicYear' => $academicYear,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, AcademicYear $academicYear): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:50', Rule::unique('academic_years', 'name')->ignore($academicYear->id)],
|
||||||
|
'start_year' => ['required', 'integer', 'digits:4'],
|
||||||
|
'end_year' => ['required', 'integer', 'digits:4', 'gte:start_year'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
if ($data['is_active']) {
|
||||||
|
AcademicYear::whereKeyNot($academicYear->id)->update(['is_active' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$academicYear->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('academic-years.index')->with('success', 'Tahun angkatan berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(AcademicYear $academicYear): RedirectResponse
|
||||||
|
{
|
||||||
|
$academicYear->loadCount('students');
|
||||||
|
$classesWithStudentsCount = $academicYear->classes()->withCount('students')->get()->where('students_count', '>', 0)->count();
|
||||||
|
$emptyClassesCount = $academicYear->classes()->withCount('students')->get()->where('students_count', 0)->count();
|
||||||
|
|
||||||
|
if ($academicYear->students_count > 0 || $classesWithStudentsCount > 0) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Tahun angkatan ini masih digunakan oleh data siswa aktif atau kelas yang masih berisi siswa.');
|
||||||
|
|
||||||
|
return redirect()->route('academic-years.index')->withErrors([
|
||||||
|
'delete' => 'Tahun angkatan tidak bisa dihapus karena masih digunakan oleh data siswa aktif atau kelas yang masih berisi siswa.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($academicYear) {
|
||||||
|
$classIds = $academicYear->classes()->pluck('id');
|
||||||
|
|
||||||
|
StudentAcademicHistory::query()
|
||||||
|
->whereIn('class_id', $classIds)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$academicYear->classes()->delete();
|
||||||
|
$academicYear->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
$message = $emptyClassesCount > 0
|
||||||
|
? "Tahun angkatan berhasil dihapus beserta {$emptyClassesCount} kelas kosong terkait."
|
||||||
|
: 'Tahun angkatan berhasil dihapus.';
|
||||||
|
|
||||||
|
Alert::success('Berhasil', $message);
|
||||||
|
|
||||||
|
return redirect()->route('academic-years.index')->with('success', $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\District;
|
||||||
|
use App\Models\Regency;
|
||||||
|
use App\Models\Village;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class RegionController extends Controller
|
||||||
|
{
|
||||||
|
public function regencies(string $provinceId): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(
|
||||||
|
Regency::where('province_id', $provinceId)->orderBy('name')->get(['id', 'name'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function districts(string $regencyId): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(
|
||||||
|
District::where('regency_id', $regencyId)->orderBy('name')->get(['id', 'name'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function villages(string $districtId): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json(
|
||||||
|
Village::where('district_id', $districtId)->orderBy('name')->get(['id', 'name'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Auth\LoginRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AuthenticatedSessionController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the login view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming authentication request.
|
||||||
|
*/
|
||||||
|
public function store(LoginRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->authenticate();
|
||||||
|
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy an authenticated session.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
Auth::guard('web')->logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ConfirmablePasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the confirm password view.
|
||||||
|
*/
|
||||||
|
public function show(): View
|
||||||
|
{
|
||||||
|
return view('auth.confirm-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm the user's password.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if (! Auth::guard('web')->validate([
|
||||||
|
'email' => $request->user()->email,
|
||||||
|
'password' => $request->password,
|
||||||
|
])) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'password' => __('auth.password'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->session()->put('auth.password_confirmed_at', time());
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class EmailVerificationNotificationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Send a new email verification notification.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->sendEmailVerificationNotification();
|
||||||
|
|
||||||
|
return back()->with('status', 'verification-link-sent');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class EmailVerificationPromptController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the email verification prompt.
|
||||||
|
*/
|
||||||
|
public function __invoke(Request $request): RedirectResponse|View
|
||||||
|
{
|
||||||
|
return $request->user()->hasVerifiedEmail()
|
||||||
|
? redirect()->intended(route('dashboard', absolute: false))
|
||||||
|
: view('auth.verify-email');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\PasswordReset;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class NewPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset view.
|
||||||
|
*/
|
||||||
|
public function create(Request $request): View
|
||||||
|
{
|
||||||
|
return view('auth.reset-password', ['request' => $request]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming new password request.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'token' => ['required'],
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Here we will attempt to reset the user's password. If it is successful we
|
||||||
|
// will update the password on an actual user model and persist it to the
|
||||||
|
// database. Otherwise we will parse the error and return the response.
|
||||||
|
$status = Password::reset(
|
||||||
|
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||||
|
function (User $user) use ($request) {
|
||||||
|
$user->forceFill([
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'remember_token' => Str::random(60),
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
event(new PasswordReset($user));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the password was successfully reset, we will redirect the user back to
|
||||||
|
// the application's home authenticated view. If there is an error we can
|
||||||
|
// redirect them back to where they came from with their error message.
|
||||||
|
return $status == Password::PASSWORD_RESET
|
||||||
|
? redirect()->route('login')->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
|
class PasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Update the user's password.
|
||||||
|
*/
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validateWithBag('updatePassword', [
|
||||||
|
'current_password' => ['required', 'current_password'],
|
||||||
|
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$request->user()->update([
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('status', 'password-updated');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Password;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class PasswordResetLinkController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the password reset link request view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.forgot-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming password reset link request.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'email' => ['required', 'email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// We will send the password reset link to this user. Once we have attempted
|
||||||
|
// to send the link, we will examine the response then see the message we
|
||||||
|
// need to show to the user. Finally, we'll send out a proper response.
|
||||||
|
$status = Password::sendResetLink(
|
||||||
|
$request->only('email')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $status == Password::RESET_LINK_SENT
|
||||||
|
? back()->with('status', __($status))
|
||||||
|
: back()->withInput($request->only('email'))
|
||||||
|
->withErrors(['email' => __($status)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class RegisteredUserController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the registration view.
|
||||||
|
*/
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('auth.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming registration request.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'lowercase', 'email', 'max:255', 'unique:'.User::class],
|
||||||
|
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
]);
|
||||||
|
|
||||||
|
event(new Registered($user));
|
||||||
|
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
return redirect(route('dashboard', absolute: false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Auth\Events\Verified;
|
||||||
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class VerifyEmailController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Mark the authenticated user's email address as verified.
|
||||||
|
*/
|
||||||
|
public function __invoke(EmailVerificationRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->user()->hasVerifiedEmail()) {
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->user()->markEmailAsVerified()) {
|
||||||
|
event(new Verified($request->user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AppSetting;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class BrandingSettingController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
return view('settings.branding', [
|
||||||
|
'branding' => AppSetting::branding(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'app_name' => ['required', 'string', 'max:255'],
|
||||||
|
'app_short_name' => ['required', 'string', 'max:20'],
|
||||||
|
'app_logo' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg', 'max:2048'],
|
||||||
|
'app_favicon' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg,ico', 'max:1024'],
|
||||||
|
'public_portal_logo' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp,svg', 'max:2048'],
|
||||||
|
'remove_app_logo' => ['nullable', 'boolean'],
|
||||||
|
'remove_app_favicon' => ['nullable', 'boolean'],
|
||||||
|
'remove_public_portal_logo' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
AppSetting::setValue('app_name', $data['app_name']);
|
||||||
|
AppSetting::setValue('app_short_name', $data['app_short_name']);
|
||||||
|
|
||||||
|
$this->handleAssetUpdate($request, 'app_logo', 'branding/app-logo', (bool) ($data['remove_app_logo'] ?? false));
|
||||||
|
$this->handleAssetUpdate($request, 'app_favicon', 'branding/app-favicon', (bool) ($data['remove_app_favicon'] ?? false));
|
||||||
|
$this->handleAssetUpdate($request, 'public_portal_logo', 'branding/public-portal-logo', (bool) ($data['remove_public_portal_logo'] ?? false));
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Pengaturan branding aplikasi berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('settings.branding.index')->with('success', 'Pengaturan branding aplikasi berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleAssetUpdate(Request $request, string $field, string $directory, bool $remove = false): void
|
||||||
|
{
|
||||||
|
$currentPath = AppSetting::getValue($field);
|
||||||
|
|
||||||
|
if ($remove) {
|
||||||
|
if ($currentPath && Storage::disk('public')->exists($currentPath)) {
|
||||||
|
Storage::disk('public')->delete($currentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppSetting::setValue($field, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $request->hasFile($field)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($currentPath && Storage::disk('public')->exists($currentPath)) {
|
||||||
|
Storage::disk('public')->delete($currentPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $request->file($field)->store($directory, 'public');
|
||||||
|
AppSetting::setValue($field, $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
abstract class Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\DocumentType;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentExit;
|
||||||
|
use App\Models\StudentTransfer;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke(): View
|
||||||
|
{
|
||||||
|
$requiredDocumentTypeIds = DocumentType::where('is_active', true)
|
||||||
|
->where('is_required', true)
|
||||||
|
->pluck('id');
|
||||||
|
|
||||||
|
$students = Student::with('documents')->get();
|
||||||
|
|
||||||
|
$completion = $this->calculateCompletion($students, $requiredDocumentTypeIds);
|
||||||
|
|
||||||
|
return view('dashboard', [
|
||||||
|
'stats' => [
|
||||||
|
'academicYears' => AcademicYear::count(),
|
||||||
|
'departments' => Department::count(),
|
||||||
|
'classes' => SchoolClass::count(),
|
||||||
|
'documentTypes' => DocumentType::count(),
|
||||||
|
'students' => Student::count(),
|
||||||
|
'studentsDropped' => StudentExit::count(),
|
||||||
|
'studentsTransferred' => StudentTransfer::count(),
|
||||||
|
'studentsGraduated' => Student::where('status', 'graduated')->count(),
|
||||||
|
'studentsCompleteDocuments' => $completion['complete'],
|
||||||
|
'studentsIncompleteDocuments' => $completion['incomplete'],
|
||||||
|
'studentsVerifiedDocuments' => $completion['verified_complete'],
|
||||||
|
'studentsUnverifiedDocuments' => $completion['verified_incomplete'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function calculateCompletion(Collection $students, Collection $requiredDocumentTypeIds): array
|
||||||
|
{
|
||||||
|
if ($requiredDocumentTypeIds->isEmpty()) {
|
||||||
|
return [
|
||||||
|
'complete' => $students->count(),
|
||||||
|
'incomplete' => 0,
|
||||||
|
'verified_complete' => $students->count(),
|
||||||
|
'verified_incomplete' => 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$complete = 0;
|
||||||
|
$verifiedComplete = 0;
|
||||||
|
|
||||||
|
foreach ($students as $student) {
|
||||||
|
$requiredDocuments = $student->documents->whereIn('document_type_id', $requiredDocumentTypeIds);
|
||||||
|
|
||||||
|
$uploadedRequired = $requiredDocuments
|
||||||
|
->pluck('document_type_id')
|
||||||
|
->unique()
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$verifiedRequired = $requiredDocuments
|
||||||
|
->where('verification_status', 'valid')
|
||||||
|
->pluck('document_type_id')
|
||||||
|
->unique()
|
||||||
|
->count();
|
||||||
|
|
||||||
|
if ($uploadedRequired >= $requiredDocumentTypeIds->count()) {
|
||||||
|
$complete++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($verifiedRequired >= $requiredDocumentTypeIds->count()) {
|
||||||
|
$verifiedComplete++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'complete' => $complete,
|
||||||
|
'incomplete' => max($students->count() - $complete, 0),
|
||||||
|
'verified_complete' => $verifiedComplete,
|
||||||
|
'verified_incomplete' => max($students->count() - $verifiedComplete, 0),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\StudentAcademicHistory;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class DepartmentController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
|
||||||
|
$departments = Department::withCount(['classes', 'students'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where('code', 'like', "%{$search}%")
|
||||||
|
->orWhere('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('description', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('departments.index', compact('departments', 'search'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('departments.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'code' => ['required', 'string', 'max:20', 'unique:departments,code'],
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'description' => ['nullable', 'string'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
$data['code'] = strtoupper($data['code']);
|
||||||
|
|
||||||
|
Department::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('departments.index')->with('success', 'Program keahlian berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Department $department): RedirectResponse
|
||||||
|
{
|
||||||
|
return redirect()->route('departments.edit', $department);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Department $department): View
|
||||||
|
{
|
||||||
|
return view('departments.edit', [
|
||||||
|
'department' => $department,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Department $department): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'code' => ['required', 'string', 'max:20', Rule::unique('departments', 'code')->ignore($department->id)],
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'description' => ['nullable', 'string'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
$data['code'] = strtoupper($data['code']);
|
||||||
|
|
||||||
|
$department->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('departments.index')->with('success', 'Program keahlian berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Department $department): RedirectResponse
|
||||||
|
{
|
||||||
|
$department->loadCount('students');
|
||||||
|
$classesWithStudentsCount = $department->classes()->withCount('students')->get()->where('students_count', '>', 0)->count();
|
||||||
|
$emptyClassesCount = $department->classes()->withCount('students')->get()->where('students_count', 0)->count();
|
||||||
|
|
||||||
|
if ($department->students_count > 0 || $classesWithStudentsCount > 0) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Program keahlian ini masih digunakan oleh data siswa aktif atau kelas yang masih berisi siswa.');
|
||||||
|
|
||||||
|
return redirect()->route('departments.index')->withErrors([
|
||||||
|
'delete' => 'Program keahlian tidak bisa dihapus karena masih digunakan oleh data siswa aktif atau kelas yang masih berisi siswa.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($department) {
|
||||||
|
$classIds = $department->classes()->pluck('id');
|
||||||
|
|
||||||
|
StudentAcademicHistory::query()
|
||||||
|
->whereIn('class_id', $classIds)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$department->classes()->delete();
|
||||||
|
$department->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
$message = $emptyClassesCount > 0
|
||||||
|
? "Program keahlian berhasil dihapus beserta {$emptyClassesCount} kelas kosong terkait."
|
||||||
|
: 'Program keahlian berhasil dihapus.';
|
||||||
|
|
||||||
|
Alert::success('Berhasil', $message);
|
||||||
|
|
||||||
|
return redirect()->route('departments.index')->with('success', $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentType;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class DocumentTypeController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
|
||||||
|
$documentTypes = DocumentType::withCount('studentDocuments')
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where('code', 'like', "%{$search}%")
|
||||||
|
->orWhere('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('description', 'like', "%{$search}%")
|
||||||
|
->orWhere('allowed_extensions', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('document-types.index', compact('documentTypes', 'search'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('document-types.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'code' => ['required', 'string', 'max:50', 'unique:document_types,code'],
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'description' => ['nullable', 'string'],
|
||||||
|
'max_file_size_kb' => ['nullable', 'integer', 'min:1', 'max:10240'],
|
||||||
|
'allowed_extensions' => ['nullable', 'string', 'max:255'],
|
||||||
|
'is_required' => ['nullable', 'boolean'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['code'] = strtoupper($data['code']);
|
||||||
|
$data['allowed_extensions'] = $this->normalizeExtensions($data['allowed_extensions'] ?? null);
|
||||||
|
$data['is_required'] = $request->boolean('is_required');
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
DocumentType::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('document-types.index')->with('success', 'Jenis dokumen berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(DocumentType $documentType): RedirectResponse
|
||||||
|
{
|
||||||
|
return redirect()->route('document-types.edit', $documentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(DocumentType $documentType): View
|
||||||
|
{
|
||||||
|
return view('document-types.edit', [
|
||||||
|
'documentType' => $documentType,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, DocumentType $documentType): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'code' => ['required', 'string', 'max:50', Rule::unique('document_types', 'code')->ignore($documentType->id)],
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'description' => ['nullable', 'string'],
|
||||||
|
'max_file_size_kb' => ['nullable', 'integer', 'min:1', 'max:10240'],
|
||||||
|
'allowed_extensions' => ['nullable', 'string', 'max:255'],
|
||||||
|
'is_required' => ['nullable', 'boolean'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['code'] = strtoupper($data['code']);
|
||||||
|
$data['allowed_extensions'] = $this->normalizeExtensions($data['allowed_extensions'] ?? null);
|
||||||
|
$data['is_required'] = $request->boolean('is_required');
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
$documentType->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('document-types.index')->with('success', 'Jenis dokumen berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(DocumentType $documentType): RedirectResponse
|
||||||
|
{
|
||||||
|
$documentType->loadCount('studentDocuments');
|
||||||
|
|
||||||
|
if ($documentType->student_documents_count > 0) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Jenis dokumen ini masih digunakan oleh data dokumen siswa.');
|
||||||
|
|
||||||
|
return redirect()->route('document-types.index')->withErrors([
|
||||||
|
'delete' => "Jenis dokumen '{$documentType->name}' tidak bisa dihapus karena masih digunakan oleh {$documentType->student_documents_count} dokumen siswa.",
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$documentType->delete();
|
||||||
|
} catch (QueryException $exception) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Jenis dokumen ini masih direferensikan oleh data lain di sistem.');
|
||||||
|
|
||||||
|
return redirect()->route('document-types.index')->withErrors([
|
||||||
|
'delete' => "Jenis dokumen '{$documentType->name}' tidak bisa dihapus karena masih direferensikan oleh data lain di sistem. Untuk kasus ini, cek dokumen siswa yang masih memakai jenis dokumen tersebut terlebih dahulu.",
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Jenis dokumen berhasil dihapus.');
|
||||||
|
|
||||||
|
return redirect()->route('document-types.index')->with('success', 'Jenis dokumen berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function normalizeExtensions(?string $extensions): ?string
|
||||||
|
{
|
||||||
|
if (! $extensions) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalized = collect(explode(',', $extensions))
|
||||||
|
->map(fn ($item) => strtolower(trim($item)))
|
||||||
|
->filter()
|
||||||
|
->map(fn ($item) => ltrim($item, '.'))
|
||||||
|
->unique()
|
||||||
|
->implode(',');
|
||||||
|
|
||||||
|
return $normalized !== '' ? $normalized : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\DocumentType;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentDocument;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class MaintenanceController extends Controller
|
||||||
|
{
|
||||||
|
protected array $availableTargets = [
|
||||||
|
'academic_years' => 'Tahun Angkatan',
|
||||||
|
'departments' => 'Program Keahlian',
|
||||||
|
'classes' => 'Kelas',
|
||||||
|
'document_types' => 'Jenis Dokumen',
|
||||||
|
'students' => 'Data Siswa',
|
||||||
|
'student_parents' => 'Orang Tua / Wali',
|
||||||
|
'student_documents' => 'Dokumen Siswa + file storage',
|
||||||
|
'student_academic_histories' => 'Histori Akademik Siswa',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
return view('maintenance.reset-data', [
|
||||||
|
'stats' => [
|
||||||
|
'academicYears' => AcademicYear::count(),
|
||||||
|
'departments' => Department::count(),
|
||||||
|
'classes' => SchoolClass::count(),
|
||||||
|
'documentTypes' => DocumentType::count(),
|
||||||
|
'students' => Student::withTrashed()->count(),
|
||||||
|
'studentParents' => DB::table('student_parents')->count(),
|
||||||
|
'studentDocuments' => StudentDocument::withTrashed()->count(),
|
||||||
|
'studentAcademicHistories' => DB::table('student_academic_histories')->count(),
|
||||||
|
],
|
||||||
|
'targets' => $this->availableTargets,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function reset(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'targets' => ['required', 'array', 'min:1'],
|
||||||
|
'targets.*' => ['string'],
|
||||||
|
'admin_password' => ['required', 'string'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (! Hash::check($data['admin_password'], (string) $request->user()->password)) {
|
||||||
|
return back()->withErrors([
|
||||||
|
'admin_password' => 'Password admin tidak valid.',
|
||||||
|
])->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = collect($data['targets'])
|
||||||
|
->filter(fn ($target) => array_key_exists($target, $this->availableTargets))
|
||||||
|
->values();
|
||||||
|
|
||||||
|
if ($targets->isEmpty()) {
|
||||||
|
return back()->withErrors([
|
||||||
|
'targets' => 'Pilih minimal satu kelompok data yang ingin dikosongkan.',
|
||||||
|
])->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$resolvedTargets = $this->resolveTargets($targets->all());
|
||||||
|
|
||||||
|
DB::transaction(function () use ($resolvedTargets) {
|
||||||
|
if (in_array('students', $resolvedTargets, true)) {
|
||||||
|
Student::withTrashed()->get()->each->forceDelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('student_documents', $resolvedTargets, true)) {
|
||||||
|
StudentDocument::withTrashed()->get()->each(function (StudentDocument $document) {
|
||||||
|
if ($document->file_path && Storage::disk('public')->exists($document->file_path)) {
|
||||||
|
Storage::disk('public')->delete($document->file_path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
DB::table('student_documents')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('student_parents', $resolvedTargets, true)) {
|
||||||
|
DB::table('student_parents')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('student_academic_histories', $resolvedTargets, true)) {
|
||||||
|
DB::table('student_academic_histories')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('students', $resolvedTargets, true)) {
|
||||||
|
DB::table('students')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('classes', $resolvedTargets, true)) {
|
||||||
|
DB::table('classes')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('document_types', $resolvedTargets, true)) {
|
||||||
|
DB::table('document_types')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('departments', $resolvedTargets, true)) {
|
||||||
|
DB::table('departments')->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('academic_years', $resolvedTargets, true)) {
|
||||||
|
DB::table('academic_years')->delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (in_array('student_documents', $resolvedTargets, true)) {
|
||||||
|
Storage::disk('public')->deleteDirectory('student-documents');
|
||||||
|
}
|
||||||
|
|
||||||
|
$labels = collect($resolvedTargets)
|
||||||
|
->map(fn ($target) => $this->availableTargets[$target] ?? $target)
|
||||||
|
->implode(', ');
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Data berhasil dikosongkan: ' . $labels . '.');
|
||||||
|
|
||||||
|
return redirect()->route('settings.reset-data.index')->with('success', 'Data berhasil dikosongkan: ' . $labels . '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resolveTargets(array $targets): array
|
||||||
|
{
|
||||||
|
$resolved = collect($targets);
|
||||||
|
|
||||||
|
if ($resolved->contains('students')) {
|
||||||
|
$resolved = $resolved->merge(['student_documents', 'student_parents', 'student_academic_histories']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolved->contains('classes')) {
|
||||||
|
$resolved = $resolved->merge(['students', 'student_academic_histories']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolved->contains('document_types')) {
|
||||||
|
$resolved = $resolved->merge(['student_documents']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolved->contains('departments')) {
|
||||||
|
$resolved = $resolved->merge(['classes', 'students', 'student_academic_histories']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolved->contains('academic_years')) {
|
||||||
|
$resolved = $resolved->merge(['classes', 'students', 'student_academic_histories']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resolved->unique()->values()->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Requests\ProfileUpdateRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Redirect;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the user's profile form.
|
||||||
|
*/
|
||||||
|
public function edit(Request $request): View
|
||||||
|
{
|
||||||
|
return view('profile.edit', [
|
||||||
|
'user' => $request->user(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the user's profile information.
|
||||||
|
*/
|
||||||
|
public function update(ProfileUpdateRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$request->user()->fill($request->validated());
|
||||||
|
|
||||||
|
if ($request->user()->isDirty('email')) {
|
||||||
|
$request->user()->email_verified_at = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->user()->save();
|
||||||
|
|
||||||
|
return Redirect::route('profile.edit')->with('status', 'profile-updated');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentType;
|
||||||
|
use App\Models\Student;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class PublicStudentLookupController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$query = trim((string) $request->get('q'));
|
||||||
|
$students = collect();
|
||||||
|
$selectedStudent = null;
|
||||||
|
$requiredDocumentSummary = null;
|
||||||
|
$matchedBy = null;
|
||||||
|
$selectedStudentId = $request->integer('student');
|
||||||
|
|
||||||
|
if ($query !== '') {
|
||||||
|
$students = Student::query()
|
||||||
|
->with([
|
||||||
|
'academicYear',
|
||||||
|
'department',
|
||||||
|
'classRoom',
|
||||||
|
'documents.documentType',
|
||||||
|
])
|
||||||
|
->where(function ($builder) use ($query) {
|
||||||
|
$builder->where('student_number', 'like', "%{$query}%")
|
||||||
|
->orWhere('nisn', 'like', "%{$query}%")
|
||||||
|
->orWhere('full_name', 'like', "%{$query}%");
|
||||||
|
})
|
||||||
|
->orderByRaw('CASE WHEN student_number = ? THEN 0 WHEN nisn = ? THEN 1 WHEN full_name = ? THEN 2 ELSE 3 END', [$query, $query, $query])
|
||||||
|
->orderBy('full_name')
|
||||||
|
->limit(10)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$selectedStudent = $students->firstWhere('id', $selectedStudentId) ?? $students->first();
|
||||||
|
|
||||||
|
if ($selectedStudent) {
|
||||||
|
$requiredDocumentSummary = $this->buildRequiredDocumentSummary($selectedStudent);
|
||||||
|
$matchedBy = $this->detectMatchedBy($selectedStudent, $query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$students->each(function (Student $student) {
|
||||||
|
$student->public_photo_url = $this->resolvePhotoUrl($student);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('public.student-lookup', [
|
||||||
|
'query' => $query,
|
||||||
|
'students' => $students,
|
||||||
|
'student' => $selectedStudent,
|
||||||
|
'requiredDocumentSummary' => $requiredDocumentSummary,
|
||||||
|
'matchedBy' => $matchedBy,
|
||||||
|
'selectedStudentId' => $selectedStudent?->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function detectMatchedBy(Student $student, string $query): ?string
|
||||||
|
{
|
||||||
|
if ($student->student_number && strcasecmp($student->student_number, $query) === 0) {
|
||||||
|
return 'NIS';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($student->nisn && strcasecmp($student->nisn, $query) === 0) {
|
||||||
|
return 'NISN';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Nama';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resolvePhotoUrl(Student $student): ?string
|
||||||
|
{
|
||||||
|
$photoDocument = $student->documents
|
||||||
|
->filter(function ($document) {
|
||||||
|
$code = strtoupper((string) ($document->documentType?->code ?? ''));
|
||||||
|
$name = strtolower((string) ($document->documentType?->name ?? ''));
|
||||||
|
|
||||||
|
return $code === 'PAS_FOTO'
|
||||||
|
|| $code === 'PASFOTO'
|
||||||
|
|| str_contains($name, 'pas foto')
|
||||||
|
|| str_contains($name, 'pasfoto');
|
||||||
|
})
|
||||||
|
->sortByDesc('created_at')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $photoDocument?->file_path) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return asset('storage/' . $photoDocument->file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildRequiredDocumentSummary(Student $student): array
|
||||||
|
{
|
||||||
|
$requiredTypes = DocumentType::query()
|
||||||
|
->where('is_active', true)
|
||||||
|
->where('is_required', true)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($requiredTypes->isEmpty()) {
|
||||||
|
return [
|
||||||
|
'total' => 0,
|
||||||
|
'uploaded' => 0,
|
||||||
|
'verified' => 0,
|
||||||
|
'missing' => 0,
|
||||||
|
'unverified' => 0,
|
||||||
|
'percentage' => 100,
|
||||||
|
'verification_percentage' => 100,
|
||||||
|
'missing_items' => collect(),
|
||||||
|
'unverified_items' => collect(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$documents = $student->documents;
|
||||||
|
|
||||||
|
$uploaded = 0;
|
||||||
|
$verified = 0;
|
||||||
|
$missingItems = collect();
|
||||||
|
$unverifiedItems = collect();
|
||||||
|
|
||||||
|
foreach ($requiredTypes as $type) {
|
||||||
|
$matchingDocuments = $documents->where('document_type_id', $type->id);
|
||||||
|
$latestDocument = $matchingDocuments->sortByDesc('created_at')->first();
|
||||||
|
|
||||||
|
if (! $latestDocument) {
|
||||||
|
$missingItems->push($type->name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$uploaded++;
|
||||||
|
|
||||||
|
if ($latestDocument->verification_status === 'valid') {
|
||||||
|
$verified++;
|
||||||
|
} else {
|
||||||
|
$unverifiedItems->push($type->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = $requiredTypes->count();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'total' => $total,
|
||||||
|
'uploaded' => $uploaded,
|
||||||
|
'verified' => $verified,
|
||||||
|
'missing' => max($total - $uploaded, 0),
|
||||||
|
'unverified' => max($total - $verified, 0),
|
||||||
|
'percentage' => $total > 0 ? (int) round(($uploaded / $total) * 100) : 100,
|
||||||
|
'verification_percentage' => $total > 0 ? (int) round(($verified / $total) * 100) : 100,
|
||||||
|
'missing_items' => $missingItems,
|
||||||
|
'unverified_items' => $unverifiedItems,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentParent;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class PublicStudentSelfServiceController extends Controller
|
||||||
|
{
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
return view('public.student-self-service.verify');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verify(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'identity_number' => ['required', 'string', 'max:30'],
|
||||||
|
'access_code' => ['required', 'string', 'max:20'],
|
||||||
|
], [
|
||||||
|
'identity_number.required' => 'NIS atau NISN wajib diisi.',
|
||||||
|
'access_code.required' => 'Kode akses wajib diisi.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$student = Student::query()
|
||||||
|
->where('self_service_access_code', strtoupper(trim($data['access_code'])))
|
||||||
|
->where(function ($query) use ($data) {
|
||||||
|
$query->where('student_number', $data['identity_number'])
|
||||||
|
->orWhere('nisn', $data['identity_number']);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $student) {
|
||||||
|
return back()
|
||||||
|
->withInput()
|
||||||
|
->withErrors([
|
||||||
|
'identity_number' => 'Data siswa tidak ditemukan atau kode akses tidak cocok.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->session()->put('student_self_service.student_id', $student->id);
|
||||||
|
$request->session()->put('student_self_service.verified_at', now()->toIso8601String());
|
||||||
|
|
||||||
|
$student->forceFill([
|
||||||
|
'self_service_last_access_at' => now(),
|
||||||
|
'self_service_status' => $student->self_service_status === 'submitted' ? 'submitted' : 'draft',
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return redirect()->route('public.student-self-service.edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Request $request): View|RedirectResponse
|
||||||
|
{
|
||||||
|
$student = $this->resolveVerifiedStudent($request);
|
||||||
|
|
||||||
|
if (! $student) {
|
||||||
|
return redirect()->route('public.student-self-service.index')
|
||||||
|
->withErrors([
|
||||||
|
'identity_number' => 'Sesi pelengkapan data tidak valid atau sudah berakhir. Silakan verifikasi ulang.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$student->load(['parents', 'academicYear', 'department', 'classRoom']);
|
||||||
|
|
||||||
|
return view('public.student-self-service.edit', [
|
||||||
|
'student' => $student,
|
||||||
|
'genders' => [
|
||||||
|
'L' => 'Laki-laki',
|
||||||
|
'P' => 'Perempuan',
|
||||||
|
],
|
||||||
|
'religions' => [
|
||||||
|
'Islam' => 'Islam',
|
||||||
|
'Kristen' => 'Kristen',
|
||||||
|
'Katolik' => 'Katolik',
|
||||||
|
'Hindu' => 'Hindu',
|
||||||
|
'Buddha' => 'Buddha',
|
||||||
|
'Khonghucu' => 'Khonghucu',
|
||||||
|
'Lainnya' => 'Lainnya',
|
||||||
|
],
|
||||||
|
'provinces' => Province::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'parentRelationLabels' => [
|
||||||
|
'father' => 'Ayah',
|
||||||
|
'mother' => 'Ibu',
|
||||||
|
'guardian' => 'Wali',
|
||||||
|
],
|
||||||
|
'educationOptions' => [
|
||||||
|
'Tidak Sekolah' => 'Tidak Sekolah',
|
||||||
|
'Tidak Tamat SD' => 'Tidak Tamat SD',
|
||||||
|
'SD' => 'SD',
|
||||||
|
'SMP' => 'SMP',
|
||||||
|
'SLTA' => 'SLTA',
|
||||||
|
'D1' => 'D1',
|
||||||
|
'D2' => 'D2',
|
||||||
|
'D3' => 'D3',
|
||||||
|
'D4' => 'D4',
|
||||||
|
'S1' => 'S1',
|
||||||
|
'S2' => 'S2',
|
||||||
|
'S3' => 'S3',
|
||||||
|
'Lainnya' => 'Lainnya',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$student = $this->resolveVerifiedStudent($request);
|
||||||
|
|
||||||
|
if (! $student) {
|
||||||
|
return redirect()->route('public.student-self-service.index')
|
||||||
|
->withErrors([
|
||||||
|
'identity_number' => 'Sesi pelengkapan data tidak valid atau sudah berakhir. Silakan verifikasi ulang.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'full_name' => ['required', 'string', 'max:150'],
|
||||||
|
'gender' => ['required', Rule::in(['L', 'P'])],
|
||||||
|
'place_of_birth' => ['nullable', 'string', 'max:100'],
|
||||||
|
'date_of_birth' => ['nullable', 'date'],
|
||||||
|
'religion' => ['nullable', 'string', 'max:50'],
|
||||||
|
'nationality' => ['nullable', 'string', 'max:50'],
|
||||||
|
'family_card_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'child_order' => ['nullable', 'integer', 'min:1', 'max:50'],
|
||||||
|
'number_of_siblings' => ['nullable', 'integer', 'min:0', 'max:50'],
|
||||||
|
'phone_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'email' => ['nullable', 'email', 'max:100'],
|
||||||
|
'address' => ['nullable', 'string'],
|
||||||
|
'province_id' => ['nullable', 'exists:provinces,id'],
|
||||||
|
'regency_id' => ['nullable', 'exists:regencies,id'],
|
||||||
|
'district_id' => ['nullable', 'exists:districts,id'],
|
||||||
|
'village_id' => ['nullable', 'exists:villages,id'],
|
||||||
|
'postal_code' => ['nullable', 'string', 'max:10'],
|
||||||
|
'parents.father.name' => ['nullable', 'string', 'max:150'],
|
||||||
|
'parents.father.nik' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.father.birth_year' => ['nullable', 'integer', 'min:1900', 'max:' . now()->year],
|
||||||
|
'parents.father.education' => ['nullable', Rule::in(['Tidak Sekolah', 'Tidak Tamat SD', 'SD', 'SMP', 'SLTA', 'D1', 'D2', 'D3', 'D4', 'S1', 'S2', 'S3', 'Lainnya'])],
|
||||||
|
'parents.father.occupation' => ['nullable', 'string', 'max:100'],
|
||||||
|
'parents.father.phone_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.father.address' => ['nullable', 'string'],
|
||||||
|
'parents.father.is_alive' => ['nullable', 'boolean'],
|
||||||
|
'parents.mother.name' => ['nullable', 'string', 'max:150'],
|
||||||
|
'parents.mother.nik' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.mother.birth_year' => ['nullable', 'integer', 'min:1900', 'max:' . now()->year],
|
||||||
|
'parents.mother.education' => ['nullable', Rule::in(['Tidak Sekolah', 'Tidak Tamat SD', 'SD', 'SMP', 'SLTA', 'D1', 'D2', 'D3', 'D4', 'S1', 'S2', 'S3', 'Lainnya'])],
|
||||||
|
'parents.mother.occupation' => ['nullable', 'string', 'max:100'],
|
||||||
|
'parents.mother.phone_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.mother.address' => ['nullable', 'string'],
|
||||||
|
'parents.mother.is_alive' => ['nullable', 'boolean'],
|
||||||
|
'parents.guardian.name' => ['nullable', 'string', 'max:150'],
|
||||||
|
'parents.guardian.nik' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.guardian.birth_year' => ['nullable', 'integer', 'min:1900', 'max:' . now()->year],
|
||||||
|
'parents.guardian.education' => ['nullable', Rule::in(['Tidak Sekolah', 'Tidak Tamat SD', 'SD', 'SMP', 'SLTA', 'D1', 'D2', 'D3', 'D4', 'S1', 'S2', 'S3', 'Lainnya'])],
|
||||||
|
'parents.guardian.occupation' => ['nullable', 'string', 'max:100'],
|
||||||
|
'parents.guardian.phone_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'parents.guardian.address' => ['nullable', 'string'],
|
||||||
|
'parents.guardian.is_alive' => ['nullable', 'boolean'],
|
||||||
|
'submit_action' => ['required', Rule::in(['draft', 'submit'])],
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::transaction(function () use ($student, $data) {
|
||||||
|
$student->fill([
|
||||||
|
'full_name' => $data['full_name'],
|
||||||
|
'gender' => $data['gender'],
|
||||||
|
'place_of_birth' => $data['place_of_birth'] ?? null,
|
||||||
|
'date_of_birth' => $data['date_of_birth'] ?? null,
|
||||||
|
'religion' => $data['religion'] ?? null,
|
||||||
|
'nationality' => $data['nationality'] ?? 'Indonesia',
|
||||||
|
'family_card_number' => $data['family_card_number'] ?? null,
|
||||||
|
'child_order' => $data['child_order'] ?? null,
|
||||||
|
'number_of_siblings' => $data['number_of_siblings'] ?? null,
|
||||||
|
'phone_number' => $data['phone_number'] ?? null,
|
||||||
|
'email' => $data['email'] ?? null,
|
||||||
|
'address' => $data['address'] ?? null,
|
||||||
|
'province_id' => $data['province_id'] ?? null,
|
||||||
|
'regency_id' => $data['regency_id'] ?? null,
|
||||||
|
'district_id' => $data['district_id'] ?? null,
|
||||||
|
'village_id' => $data['village_id'] ?? null,
|
||||||
|
'postal_code' => $data['postal_code'] ?? null,
|
||||||
|
'province' => ! empty($data['province_id']) ? DB::table('provinces')->where('id', $data['province_id'])->value('name') : null,
|
||||||
|
'city' => ! empty($data['regency_id']) ? DB::table('regencies')->where('id', $data['regency_id'])->value('name') : null,
|
||||||
|
'district' => ! empty($data['district_id']) ? DB::table('districts')->where('id', $data['district_id'])->value('name') : null,
|
||||||
|
'village' => ! empty($data['village_id']) ? DB::table('villages')->where('id', $data['village_id'])->value('name') : null,
|
||||||
|
'self_service_status' => $data['submit_action'] === 'submit' ? 'submitted' : 'draft',
|
||||||
|
'self_service_last_access_at' => now(),
|
||||||
|
'self_service_submitted_at' => $data['submit_action'] === 'submit' ? now() : null,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
foreach (['father', 'mother', 'guardian'] as $relationType) {
|
||||||
|
$parentData = $data['parents'][$relationType] ?? [];
|
||||||
|
$hasMeaningfulValue = collect($parentData)
|
||||||
|
->except('is_alive')
|
||||||
|
->filter(fn ($value) => filled($value))
|
||||||
|
->isNotEmpty();
|
||||||
|
|
||||||
|
$existingParent = $student->parents()->where('relation_type', $relationType)->first();
|
||||||
|
|
||||||
|
if (! $hasMeaningfulValue) {
|
||||||
|
if ($existingParent) {
|
||||||
|
$existingParent->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$payload = [
|
||||||
|
'name' => $parentData['name'] ?? '-',
|
||||||
|
'nik' => $parentData['nik'] ?? null,
|
||||||
|
'birth_year' => $parentData['birth_year'] ?? null,
|
||||||
|
'education' => $parentData['education'] ?? null,
|
||||||
|
'occupation' => $parentData['occupation'] ?? null,
|
||||||
|
'phone_number' => $parentData['phone_number'] ?? null,
|
||||||
|
'address' => $parentData['address'] ?? null,
|
||||||
|
'is_alive' => (bool) ($parentData['is_alive'] ?? false),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($existingParent) {
|
||||||
|
$existingParent->update($payload);
|
||||||
|
} else {
|
||||||
|
$student->parents()->create([
|
||||||
|
'relation_type' => $relationType,
|
||||||
|
...$payload,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return redirect()->route('public.student-self-service.edit')
|
||||||
|
->with('success', $data['submit_action'] === 'submit'
|
||||||
|
? 'Data berhasil dikirim. Silakan tunggu pemeriksaan admin sekolah.'
|
||||||
|
: 'Draft berhasil disimpan. Anda bisa melanjutkan lagi nanti selama sesi masih aktif.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resolveVerifiedStudent(Request $request): ?Student
|
||||||
|
{
|
||||||
|
$studentId = $request->session()->get('student_self_service.student_id');
|
||||||
|
|
||||||
|
if (! $studentId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Student::find($studentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class SchoolClassController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
|
||||||
|
$classes = SchoolClass::with(['academicYear', 'department'])
|
||||||
|
->withCount(['students', 'academicHistories'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('level', 'like', "%{$search}%")
|
||||||
|
->orWhere('homeroom_teacher', 'like', "%{$search}%");
|
||||||
|
})
|
||||||
|
->latest()
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('classes.index', [
|
||||||
|
'classes' => $classes,
|
||||||
|
'search' => $search,
|
||||||
|
'academicYears' => AcademicYear::orderByDesc('start_year')->orderByDesc('end_year')->get(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('classes.create', [
|
||||||
|
'academicYears' => AcademicYear::where('is_active', true)->orderBy('name')->pluck('name', 'id'),
|
||||||
|
'departments' => Department::where('is_active', true)->orderBy('name')->pluck('name', 'id'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'academic_year_id' => ['required', Rule::exists('academic_years', 'id')->where(fn ($query) => $query->where('is_active', true))],
|
||||||
|
'department_id' => ['required', Rule::exists('departments', 'id')->where(fn ($query) => $query->where('is_active', true))],
|
||||||
|
'name' => ['required', 'string', 'max:100', Rule::unique('classes', 'name')->where(fn ($query) => $query->where('academic_year_id', $request->academic_year_id))],
|
||||||
|
'level' => ['required', 'string', 'max:10'],
|
||||||
|
'homeroom_teacher' => ['nullable', 'string', 'max:100'],
|
||||||
|
'capacity' => ['nullable', 'integer', 'min:1'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
SchoolClass::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->with('success', 'Kelas berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generate(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'source_academic_year_id' => ['required', 'exists:academic_years,id', 'different:target_academic_year_id'],
|
||||||
|
'target_academic_year_id' => ['required', 'exists:academic_years,id'],
|
||||||
|
'generation_mode' => ['required', Rule::in(['same_level', 'promote_level'])],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$sourceClasses = SchoolClass::query()
|
||||||
|
->where('academic_year_id', $data['source_academic_year_id'])
|
||||||
|
->orderBy('department_id')
|
||||||
|
->orderBy('level')
|
||||||
|
->orderBy('name')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($sourceClasses->isEmpty()) {
|
||||||
|
Alert::error('Gagal', 'Tidak ada kelas pada tahun ajaran sumber yang bisa digenerate.');
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->withErrors([
|
||||||
|
'generate' => 'Tidak ada kelas pada tahun ajaran sumber yang bisa digenerate.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$created = 0;
|
||||||
|
$skipped = 0;
|
||||||
|
|
||||||
|
DB::transaction(function () use ($sourceClasses, $data, &$created, &$skipped) {
|
||||||
|
foreach ($sourceClasses as $sourceClass) {
|
||||||
|
$targetLevel = $data['generation_mode'] === 'promote_level'
|
||||||
|
? $this->nextLevel($sourceClass->level)
|
||||||
|
: $sourceClass->level;
|
||||||
|
|
||||||
|
if ($targetLevel === null) {
|
||||||
|
$skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetName = $this->transformClassName($sourceClass->name, $sourceClass->level, $targetLevel);
|
||||||
|
|
||||||
|
$exists = SchoolClass::query()
|
||||||
|
->where('academic_year_id', $data['target_academic_year_id'])
|
||||||
|
->where('name', $targetName)
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
$skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SchoolClass::create([
|
||||||
|
'academic_year_id' => $data['target_academic_year_id'],
|
||||||
|
'department_id' => $sourceClass->department_id,
|
||||||
|
'name' => $targetName,
|
||||||
|
'level' => $targetLevel,
|
||||||
|
'homeroom_teacher' => $sourceClass->homeroom_teacher,
|
||||||
|
'capacity' => $sourceClass->capacity,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$created++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Alert::success('Berhasil', "Generate kelas selesai. {$created} kelas dibuat, {$skipped} dilewati.");
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->with('success', "Generate kelas selesai. {$created} kelas dibuat, {$skipped} dilewati.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(SchoolClass $class): RedirectResponse
|
||||||
|
{
|
||||||
|
return redirect()->route('classes.edit', $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(SchoolClass $class): View
|
||||||
|
{
|
||||||
|
$class->loadMissing(['academicYear', 'department']);
|
||||||
|
|
||||||
|
$academicYears = AcademicYear::query()
|
||||||
|
->where(function ($query) use ($class) {
|
||||||
|
$query->where('is_active', true)
|
||||||
|
->orWhere('id', $class->academic_year_id);
|
||||||
|
})
|
||||||
|
->orderBy('name')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
$departments = Department::query()
|
||||||
|
->where(function ($query) use ($class) {
|
||||||
|
$query->where('is_active', true)
|
||||||
|
->orWhere('id', $class->department_id);
|
||||||
|
})
|
||||||
|
->orderBy('name')
|
||||||
|
->pluck('name', 'id');
|
||||||
|
|
||||||
|
return view('classes.edit', [
|
||||||
|
'class' => $class,
|
||||||
|
'academicYears' => $academicYears,
|
||||||
|
'departments' => $departments,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, SchoolClass $class): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'academic_year_id' => ['required', Rule::exists('academic_years', 'id')->where(fn ($query) => $query->where('is_active', true)->orWhere('id', $class->academic_year_id))],
|
||||||
|
'department_id' => ['required', Rule::exists('departments', 'id')->where(fn ($query) => $query->where('is_active', true)->orWhere('id', $class->department_id))],
|
||||||
|
'name' => ['required', 'string', 'max:100', Rule::unique('classes', 'name')->ignore($class->id)->where(fn ($query) => $query->where('academic_year_id', $request->academic_year_id))],
|
||||||
|
'level' => ['required', 'string', 'max:10'],
|
||||||
|
'homeroom_teacher' => ['nullable', 'string', 'max:100'],
|
||||||
|
'capacity' => ['nullable', 'integer', 'min:1'],
|
||||||
|
'is_active' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$data['is_active'] = $request->boolean('is_active');
|
||||||
|
|
||||||
|
$class->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->with('success', 'Kelas berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(SchoolClass $class): RedirectResponse
|
||||||
|
{
|
||||||
|
$class->loadCount(['students', 'academicHistories']);
|
||||||
|
|
||||||
|
if ($class->students_count > 0) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Kelas ini masih digunakan oleh data siswa aktif.');
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->withErrors([
|
||||||
|
'delete' => 'Kelas tidak bisa dihapus karena masih digunakan oleh data siswa aktif.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($class->academic_histories_count > 0) {
|
||||||
|
Alert::error('Tidak bisa dihapus', 'Kelas ini masih tercatat pada histori akademik siswa.');
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->withErrors([
|
||||||
|
'delete' => 'Kelas tidak bisa dihapus karena masih tercatat pada histori akademik siswa. Hapus atau ubah histori terkait terlebih dahulu.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Kelas berhasil dihapus.');
|
||||||
|
|
||||||
|
$class->delete();
|
||||||
|
|
||||||
|
return redirect()->route('classes.index')->with('success', 'Kelas berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function nextLevel(?string $level): ?string
|
||||||
|
{
|
||||||
|
return match (strtoupper((string) $level)) {
|
||||||
|
'X' => 'XI',
|
||||||
|
'XI' => 'XII',
|
||||||
|
'XII' => null,
|
||||||
|
default => $level,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function transformClassName(string $name, ?string $fromLevel, ?string $toLevel): string
|
||||||
|
{
|
||||||
|
if (! $fromLevel || ! $toLevel || strtoupper($fromLevel) === strtoupper($toLevel)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return preg_replace('/^' . preg_quote($fromLevel, '/') . '\b/i', $toLevel, $name) ?: $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,241 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentType;
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentDocument;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class StudentDocumentController extends Controller
|
||||||
|
{
|
||||||
|
public function create(Student $student): View
|
||||||
|
{
|
||||||
|
return view('student-documents.create', [
|
||||||
|
'student' => $student,
|
||||||
|
'documentTypes' => DocumentType::where('is_active', true)->orderBy('name')->get(),
|
||||||
|
'verificationStatuses' => $this->verificationStatuses(),
|
||||||
|
'defaultMaxFileSizeKb' => 5120,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request, Student $student): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $this->validateDocument($request);
|
||||||
|
$uploadedFile = $request->file('document_file');
|
||||||
|
$path = $uploadedFile->store("student-documents/{$student->id}", 'public');
|
||||||
|
|
||||||
|
StudentDocument::create([
|
||||||
|
'student_id' => $student->id,
|
||||||
|
'document_type_id' => $data['document_type_id'],
|
||||||
|
'file_name' => $uploadedFile->getClientOriginalName(),
|
||||||
|
'file_path' => $path,
|
||||||
|
'file_extension' => $uploadedFile->getClientOriginalExtension(),
|
||||||
|
'mime_type' => $uploadedFile->getMimeType(),
|
||||||
|
'file_size' => $uploadedFile->getSize(),
|
||||||
|
'document_number' => $data['document_number'] ?? null,
|
||||||
|
'issued_date' => $data['issued_date'] ?? null,
|
||||||
|
'expired_date' => $data['expired_date'] ?? null,
|
||||||
|
'description' => $data['description'] ?? null,
|
||||||
|
'verification_status' => $data['verification_status'],
|
||||||
|
'verification_note' => $data['verification_note'] ?? null,
|
||||||
|
'uploaded_by' => auth()->id(),
|
||||||
|
'verified_by' => in_array($data['verification_status'], ['valid', 'invalid', 'revision']) ? auth()->id() : null,
|
||||||
|
'verified_at' => in_array($data['verification_status'], ['valid', 'invalid', 'revision']) ? now() : null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Dokumen siswa berhasil diunggah.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Dokumen siswa berhasil diunggah.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Student $student, StudentDocument $document): View
|
||||||
|
{
|
||||||
|
abort_unless($document->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
return view('student-documents.edit', [
|
||||||
|
'student' => $student,
|
||||||
|
'document' => $document,
|
||||||
|
'documentTypes' => DocumentType::where('is_active', true)->orderBy('name')->get(),
|
||||||
|
'verificationStatuses' => $this->verificationStatuses(),
|
||||||
|
'defaultMaxFileSizeKb' => 5120,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Student $student, StudentDocument $document): RedirectResponse
|
||||||
|
{
|
||||||
|
abort_unless($document->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
$data = $this->validateDocument($request, false);
|
||||||
|
|
||||||
|
if ($request->hasFile('document_file')) {
|
||||||
|
if ($document->file_path && Storage::disk('public')->exists($document->file_path)) {
|
||||||
|
Storage::disk('public')->delete($document->file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$uploadedFile = $request->file('document_file');
|
||||||
|
$path = $uploadedFile->store("student-documents/{$student->id}", 'public');
|
||||||
|
|
||||||
|
$document->file_name = $uploadedFile->getClientOriginalName();
|
||||||
|
$document->file_path = $path;
|
||||||
|
$document->file_extension = $uploadedFile->getClientOriginalExtension();
|
||||||
|
$document->mime_type = $uploadedFile->getMimeType();
|
||||||
|
$document->file_size = $uploadedFile->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
$document->fill([
|
||||||
|
'document_type_id' => $data['document_type_id'],
|
||||||
|
'document_number' => $data['document_number'] ?? null,
|
||||||
|
'issued_date' => $data['issued_date'] ?? null,
|
||||||
|
'expired_date' => $data['expired_date'] ?? null,
|
||||||
|
'description' => $data['description'] ?? null,
|
||||||
|
'verification_status' => $data['verification_status'],
|
||||||
|
'verification_note' => $data['verification_note'] ?? null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (in_array($data['verification_status'], ['valid', 'invalid', 'revision'])) {
|
||||||
|
$document->verified_by = auth()->id();
|
||||||
|
$document->verified_at = now();
|
||||||
|
} else {
|
||||||
|
$document->verified_by = null;
|
||||||
|
$document->verified_at = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document->save();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Dokumen siswa berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Dokumen siswa berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Student $student, StudentDocument $document): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->ensureAdmin();
|
||||||
|
abort_unless($document->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
if ($document->file_path && Storage::disk('public')->exists($document->file_path)) {
|
||||||
|
Storage::disk('public')->delete($document->file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$document->delete();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Dokumen siswa berhasil dihapus.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Dokumen siswa berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preview(StudentDocument $document): Response|View
|
||||||
|
{
|
||||||
|
abort_unless($document->file_path && Storage::disk('public')->exists($document->file_path), 404);
|
||||||
|
|
||||||
|
$mimeType = $document->mime_type ?: Storage::disk('public')->mimeType($document->file_path);
|
||||||
|
$url = asset('storage/' . $document->file_path);
|
||||||
|
$isImage = str_starts_with((string) $mimeType, 'image/');
|
||||||
|
$isPdf = $mimeType === 'application/pdf';
|
||||||
|
|
||||||
|
return view('student-documents.preview', [
|
||||||
|
'document' => $document,
|
||||||
|
'fileUrl' => $url,
|
||||||
|
'mimeType' => $mimeType,
|
||||||
|
'isImage' => $isImage,
|
||||||
|
'isPdf' => $isPdf,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function quickVerify(Request $request, Student $student, StudentDocument $document): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->ensureAdmin();
|
||||||
|
abort_unless($document->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'verification_status' => ['required', Rule::in(['valid', 'revision', 'invalid'])],
|
||||||
|
'verification_note' => ['nullable', 'string', 'max:1000'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$document->update([
|
||||||
|
'verification_status' => $data['verification_status'],
|
||||||
|
'verification_note' => $data['verification_note'] ?? null,
|
||||||
|
'verified_by' => auth()->id(),
|
||||||
|
'verified_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Status verifikasi dokumen berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Status verifikasi dokumen berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function download(StudentDocument $document): StreamedResponse
|
||||||
|
{
|
||||||
|
abort_unless($document->file_path && Storage::disk('public')->exists($document->file_path), 404);
|
||||||
|
|
||||||
|
return Storage::disk('public')->download($document->file_path, $document->file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publicPreview(StudentDocument $document): Response|View
|
||||||
|
{
|
||||||
|
abort_unless($document->file_path && Storage::disk('public')->exists($document->file_path), 404);
|
||||||
|
|
||||||
|
$mimeType = $document->mime_type ?: Storage::disk('public')->mimeType($document->file_path);
|
||||||
|
$url = asset('storage/' . $document->file_path);
|
||||||
|
$isImage = str_starts_with((string) $mimeType, 'image/');
|
||||||
|
$isPdf = $mimeType === 'application/pdf';
|
||||||
|
|
||||||
|
return view('public.document-preview', [
|
||||||
|
'document' => $document,
|
||||||
|
'fileUrl' => $url,
|
||||||
|
'mimeType' => $mimeType,
|
||||||
|
'isImage' => $isImage,
|
||||||
|
'isPdf' => $isPdf,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publicDownload(StudentDocument $document): StreamedResponse
|
||||||
|
{
|
||||||
|
return $this->download($document);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateDocument(Request $request, bool $fileRequired = true): array
|
||||||
|
{
|
||||||
|
$documentType = DocumentType::findOrFail($request->input('document_type_id'));
|
||||||
|
$maxFileSizeKb = $documentType->max_file_size_kb ?: 5120;
|
||||||
|
$allowedExtensions = $documentType->allowed_extensions
|
||||||
|
? collect(explode(',', $documentType->allowed_extensions))->map(fn ($item) => trim($item))->filter()->implode(',')
|
||||||
|
: 'jpg,jpeg,png,pdf,webp';
|
||||||
|
|
||||||
|
return $request->validate([
|
||||||
|
'document_type_id' => ['required', 'exists:document_types,id'],
|
||||||
|
'document_number' => ['nullable', 'string', 'max:100'],
|
||||||
|
'issued_date' => ['nullable', 'date'],
|
||||||
|
'expired_date' => ['nullable', 'date', 'after_or_equal:issued_date'],
|
||||||
|
'description' => ['nullable', 'string'],
|
||||||
|
'verification_status' => ['required', Rule::in(array_keys($this->verificationStatuses()))],
|
||||||
|
'verification_note' => ['nullable', 'string', 'max:1000'],
|
||||||
|
'document_file' => [$fileRequired ? 'required' : 'nullable', 'file', 'mimes:' . $allowedExtensions, 'max:' . $maxFileSizeKb],
|
||||||
|
], [
|
||||||
|
'document_file.max' => 'Ukuran file melebihi batas maksimal untuk jenis dokumen ini (' . number_format($maxFileSizeKb / 1024, 2) . ' MB).',
|
||||||
|
'document_file.mimes' => 'Format file tidak sesuai. Format yang diizinkan untuk jenis dokumen ini: ' . strtoupper(str_replace(',', ', ', $allowedExtensions)) . '.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function verificationStatuses(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'pending' => 'Pending',
|
||||||
|
'valid' => 'Valid',
|
||||||
|
'invalid' => 'Invalid',
|
||||||
|
'revision' => 'Perlu Revisi',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function ensureAdmin(): void
|
||||||
|
{
|
||||||
|
abort_unless(auth()->user()?->isAdmin(), 403, 'Aksi ini hanya boleh dilakukan administrator.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\StudentExit;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class StudentExitController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
$academicYearId = $request->get('academic_year_id');
|
||||||
|
$departmentId = $request->get('department_id');
|
||||||
|
$classId = $request->get('class_id');
|
||||||
|
|
||||||
|
$studentExits = StudentExit::query()
|
||||||
|
->with(['academicYear', 'department', 'classRoom'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where(function ($subQuery) use ($search) {
|
||||||
|
$subQuery->where('full_name', 'like', "%{$search}%")
|
||||||
|
->orWhere('student_number', 'like', "%{$search}%")
|
||||||
|
->orWhere('nisn', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($academicYearId, fn ($query) => $query->where('academic_year_id', $academicYearId))
|
||||||
|
->when($departmentId, fn ($query) => $query->where('department_id', $departmentId))
|
||||||
|
->when($classId, fn ($query) => $query->where('class_id', $classId))
|
||||||
|
->latest('exit_date')
|
||||||
|
->latest('id')
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('student-exits.index', [
|
||||||
|
'studentExits' => $studentExits,
|
||||||
|
'search' => $search,
|
||||||
|
'filters' => [
|
||||||
|
'academic_year_id' => $academicYearId,
|
||||||
|
'department_id' => $departmentId,
|
||||||
|
'class_id' => $classId,
|
||||||
|
],
|
||||||
|
'academicYears' => AcademicYear::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'departments' => Department::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'classes' => SchoolClass::orderBy('name')->pluck('name', 'id'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(StudentExit $studentExit): View
|
||||||
|
{
|
||||||
|
$studentExit->load(['academicYear', 'department', 'classRoom']);
|
||||||
|
|
||||||
|
return view('student-exits.show', [
|
||||||
|
'studentExit' => $studentExit,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, StudentExit $studentExit): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'exit_date' => ['nullable', 'date'],
|
||||||
|
'exit_reason' => ['nullable', 'string'],
|
||||||
|
'exit_letter' => ['nullable', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:2048'],
|
||||||
|
], [
|
||||||
|
'exit_letter.mimes' => 'Surat keluar harus berupa file PDF, JPG, JPEG, atau PNG.',
|
||||||
|
'exit_letter.max' => 'Ukuran surat keluar maksimal 2 MB.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$studentExit->exit_date = $validated['exit_date'] ?? $studentExit->exit_date;
|
||||||
|
$studentExit->exit_reason = $validated['exit_reason'] ?? $studentExit->exit_reason;
|
||||||
|
|
||||||
|
if ($request->hasFile('exit_letter')) {
|
||||||
|
if ($studentExit->exit_letter_file_path && Storage::disk('public')->exists($studentExit->exit_letter_file_path)) {
|
||||||
|
Storage::disk('public')->delete($studentExit->exit_letter_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $request->file('exit_letter');
|
||||||
|
$path = $file->store("student-exit-letters/{$studentExit->student_id}", 'public');
|
||||||
|
|
||||||
|
$studentExit->exit_letter_file_name = $file->getClientOriginalName();
|
||||||
|
$studentExit->exit_letter_file_path = $path;
|
||||||
|
$studentExit->exit_letter_mime_type = $file->getMimeType();
|
||||||
|
$studentExit->exit_letter_file_size = $file->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
$studentExit->save();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Arsip siswa keluar berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('student-exits.show', $studentExit)->with('success', 'Arsip siswa keluar berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function previewLetter(StudentExit $studentExit): View
|
||||||
|
{
|
||||||
|
abort_unless($studentExit->exit_letter_file_path && Storage::disk('public')->exists($studentExit->exit_letter_file_path), 404);
|
||||||
|
|
||||||
|
$mimeType = $studentExit->exit_letter_mime_type ?: Storage::disk('public')->mimeType($studentExit->exit_letter_file_path);
|
||||||
|
$fileUrl = asset('storage/' . $studentExit->exit_letter_file_path);
|
||||||
|
$isImage = str_starts_with((string) $mimeType, 'image/');
|
||||||
|
$isPdf = $mimeType === 'application/pdf';
|
||||||
|
|
||||||
|
return view('student-exits.preview-letter', [
|
||||||
|
'studentExit' => $studentExit,
|
||||||
|
'fileUrl' => $fileUrl,
|
||||||
|
'mimeType' => $mimeType,
|
||||||
|
'isImage' => $isImage,
|
||||||
|
'isPdf' => $isPdf,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentParent;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class StudentParentController extends Controller
|
||||||
|
{
|
||||||
|
public function create(Student $student): View
|
||||||
|
{
|
||||||
|
return view('student-parents.create', [
|
||||||
|
'student' => $student,
|
||||||
|
'relations' => $this->relationOptions(),
|
||||||
|
'educationOptions' => $this->educationOptions(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request, Student $student): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $this->validateParent($request, $student);
|
||||||
|
$data['student_id'] = $student->id;
|
||||||
|
|
||||||
|
StudentParent::create($data);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Data orang tua/wali berhasil ditambahkan.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Data orang tua/wali berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Student $student, StudentParent $parent): View
|
||||||
|
{
|
||||||
|
abort_unless($parent->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
return view('student-parents.edit', [
|
||||||
|
'student' => $student,
|
||||||
|
'parent' => $parent,
|
||||||
|
'relations' => $this->relationOptions(),
|
||||||
|
'educationOptions' => $this->educationOptions(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, Student $student, StudentParent $parent): RedirectResponse
|
||||||
|
{
|
||||||
|
abort_unless($parent->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
$data = $this->validateParent($request, $student, $parent);
|
||||||
|
$parent->update($data);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Data orang tua/wali berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Data orang tua/wali berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Student $student, StudentParent $parent): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->ensureAdmin();
|
||||||
|
abort_unless($parent->student_id === $student->id, 404);
|
||||||
|
|
||||||
|
$parent->delete();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Data orang tua/wali berhasil dihapus.');
|
||||||
|
|
||||||
|
return redirect()->route('students.show', $student)->with('success', 'Data orang tua/wali berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateParent(Request $request, Student $student, ?StudentParent $parent = null): array
|
||||||
|
{
|
||||||
|
return $request->validate([
|
||||||
|
'relation_type' => ['required', Rule::in(array_keys($this->relationOptions())), Rule::unique('student_parents', 'relation_type')->ignore($parent?->id)->where(fn ($query) => $query->where('student_id', $student->id))],
|
||||||
|
'name' => ['required', 'string', 'max:150'],
|
||||||
|
'nik' => ['nullable', 'string', 'max:30'],
|
||||||
|
'birth_year' => ['nullable', 'integer', 'digits:4'],
|
||||||
|
'education' => ['nullable', Rule::in(array_keys($this->educationOptions()))],
|
||||||
|
'occupation' => ['nullable', 'string', 'max:100'],
|
||||||
|
'phone_number' => ['nullable', 'string', 'max:30'],
|
||||||
|
'address' => ['nullable', 'string'],
|
||||||
|
'is_alive' => ['nullable', 'boolean'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function relationOptions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'father' => 'Ayah',
|
||||||
|
'mother' => 'Ibu',
|
||||||
|
'guardian' => 'Wali',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function educationOptions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Tidak Sekolah' => 'Tidak Sekolah',
|
||||||
|
'Tidak Tamat SD' => 'Tidak Tamat SD',
|
||||||
|
'SD' => 'SD',
|
||||||
|
'SMP' => 'SMP',
|
||||||
|
'SLTA' => 'SLTA',
|
||||||
|
'D1' => 'D1',
|
||||||
|
'D2' => 'D2',
|
||||||
|
'D3' => 'D3',
|
||||||
|
'D4' => 'D4',
|
||||||
|
'S1' => 'S1',
|
||||||
|
'S2' => 'S2',
|
||||||
|
'S3' => 'S3',
|
||||||
|
'Lainnya' => 'Lainnya',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function ensureAdmin(): void
|
||||||
|
{
|
||||||
|
abort_unless(auth()->user()?->isAdmin(), 403, 'Aksi ini hanya boleh dilakukan administrator.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,392 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\Student;
|
||||||
|
use App\Models\StudentAcademicHistory;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class StudentPromotionController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$fromAcademicYearId = $request->integer('from_academic_year_id') ?: AcademicYear::where('is_active', true)->value('id');
|
||||||
|
$toAcademicYearId = $request->integer('to_academic_year_id');
|
||||||
|
|
||||||
|
$academicYears = AcademicYear::orderByDesc('start_year')->orderByDesc('end_year')->get();
|
||||||
|
|
||||||
|
$students = collect();
|
||||||
|
|
||||||
|
if ($fromAcademicYearId) {
|
||||||
|
$students = Student::query()
|
||||||
|
->with(['academicYear', 'department', 'classRoom'])
|
||||||
|
->where('academic_year_id', $fromAcademicYearId)
|
||||||
|
->where('status', 'active')
|
||||||
|
->orderBy('full_name')
|
||||||
|
->get()
|
||||||
|
->map(function (Student $student) use ($toAcademicYearId) {
|
||||||
|
$student->promotion_recommendation = $this->buildPromotionRecommendation($student, $toAcademicYearId);
|
||||||
|
|
||||||
|
return $student;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('student-promotions.index', [
|
||||||
|
'academicYears' => $academicYears,
|
||||||
|
'students' => $students,
|
||||||
|
'filters' => [
|
||||||
|
'from_academic_year_id' => $fromAcademicYearId,
|
||||||
|
'to_academic_year_id' => $toAcademicYearId,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'from_academic_year_id' => ['required', 'exists:academic_years,id'],
|
||||||
|
'to_academic_year_id' => ['required', 'exists:academic_years,id', 'different:from_academic_year_id'],
|
||||||
|
'promotions' => ['required', 'array', 'min:1'],
|
||||||
|
'promotions.*.student_id' => ['required', 'exists:students,id'],
|
||||||
|
'promotions.*.target_class_id' => ['nullable', 'exists:classes,id'],
|
||||||
|
'promotions.*.action' => ['required', 'in:promote,repeat,graduate,skip'],
|
||||||
|
'promotions.*.notes' => ['nullable', 'string'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$students = Student::query()
|
||||||
|
->with(['classRoom'])
|
||||||
|
->whereIn('id', collect($data['promotions'])->pluck('student_id')->all())
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
|
||||||
|
$targetClassIds = collect($data['promotions'])
|
||||||
|
->pluck('target_class_id')
|
||||||
|
->filter()
|
||||||
|
->unique()
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$targetClasses = SchoolClass::query()
|
||||||
|
->whereIn('id', $targetClassIds)
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
|
||||||
|
$plannedClassAssignments = collect($data['promotions'])
|
||||||
|
->filter(fn (array $promotion) => in_array($promotion['action'] ?? 'skip', ['promote', 'repeat'], true) && ! empty($promotion['target_class_id']))
|
||||||
|
->countBy('target_class_id');
|
||||||
|
|
||||||
|
foreach ($data['promotions'] as $index => $promotion) {
|
||||||
|
if (in_array($promotion['action'], ['promote', 'repeat'], true) && empty($promotion['target_class_id'])) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => 'Kelas tujuan wajib dipilih untuk aksi naik kelas atau tinggal kelas.'])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$student = $students->get($promotion['student_id']);
|
||||||
|
|
||||||
|
if (! $student) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.student_id" => 'Data siswa tidak ditemukan.'])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int) $student->academic_year_id !== (int) $data['from_academic_year_id']) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.student_id" => "Siswa {$student->full_name} tidak berasal dari tahun ajaran asal yang dipilih."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($student->status !== 'active') {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.student_id" => "Siswa {$student->full_name} tidak berstatus aktif sehingga tidak bisa diproses promosi."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($promotion['action'] ?? 'skip') === 'graduate') {
|
||||||
|
if (strtoupper((string) $student->classRoom?->level) !== 'XII') {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.action" => "Siswa {$student->full_name} hanya bisa diluluskan jika berada di kelas XII."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($promotion['action'] ?? 'skip') === 'skip') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetClass = $targetClasses->get($promotion['target_class_id']);
|
||||||
|
|
||||||
|
if (! $targetClass) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => "Kelas tujuan untuk {$student->full_name} tidak ditemukan."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int) $targetClass->academic_year_id !== (int) $data['to_academic_year_id']) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => "Kelas tujuan {$student->full_name} harus berasal dari tahun ajaran tujuan yang dipilih."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $targetClass->is_active) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => "Kelas tujuan {$student->full_name} tidak aktif."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int) $student->department_id !== (int) $targetClass->department_id) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => "Jurusan kelas tujuan {$student->full_name} harus sama dengan jurusan siswa saat ini."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->isTargetClassValidForAction($student, $targetClass, $promotion['action'])) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.target_class_id" => "Level kelas tujuan {$student->full_name} tidak sesuai dengan aksi yang dipilih."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$hasHistoryInTargetYear = StudentAcademicHistory::query()
|
||||||
|
->where('student_id', $student->id)
|
||||||
|
->where('academic_year_id', $data['to_academic_year_id'])
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($hasHistoryInTargetYear) {
|
||||||
|
return back()
|
||||||
|
->withErrors(["promotions.$index.student_id" => "Siswa {$student->full_name} sudah memiliki histori akademik pada tahun ajaran tujuan."])
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$capacityErrors = $this->validateTargetClassCapacities($plannedClassAssignments, $targetClasses);
|
||||||
|
|
||||||
|
if ($capacityErrors->isNotEmpty()) {
|
||||||
|
return back()
|
||||||
|
->withErrors($capacityErrors->all())
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
$processed = 0;
|
||||||
|
|
||||||
|
DB::transaction(function () use ($data, &$processed) {
|
||||||
|
foreach ($data['promotions'] as $promotion) {
|
||||||
|
if (($promotion['action'] ?? 'skip') === 'skip') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$student = Student::query()->findOrFail($promotion['student_id']);
|
||||||
|
$action = $promotion['action'];
|
||||||
|
|
||||||
|
if ($action === 'graduate') {
|
||||||
|
$student->update([
|
||||||
|
'status' => 'graduated',
|
||||||
|
]);
|
||||||
|
|
||||||
|
StudentAcademicHistory::query()
|
||||||
|
->where('student_id', $student->id)
|
||||||
|
->where('is_current', true)
|
||||||
|
->update([
|
||||||
|
'status' => 'graduated',
|
||||||
|
'is_current' => false,
|
||||||
|
'end_date' => now()->toDateString(),
|
||||||
|
'notes' => $promotion['notes'] ?? 'Diproses melalui modul promosi siswa.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$processed++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetClass = SchoolClass::query()->findOrFail($promotion['target_class_id']);
|
||||||
|
|
||||||
|
StudentAcademicHistory::query()
|
||||||
|
->where('student_id', $student->id)
|
||||||
|
->where('is_current', true)
|
||||||
|
->update([
|
||||||
|
'is_current' => false,
|
||||||
|
'end_date' => now()->toDateString(),
|
||||||
|
'status' => $action === 'repeat' ? 'repeated' : 'promoted',
|
||||||
|
'notes' => $promotion['notes'] ?? 'Diproses melalui modul promosi siswa.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$student->update([
|
||||||
|
'academic_year_id' => $data['to_academic_year_id'],
|
||||||
|
'department_id' => $targetClass->department_id,
|
||||||
|
'class_id' => $targetClass->id,
|
||||||
|
'status' => 'active',
|
||||||
|
]);
|
||||||
|
|
||||||
|
StudentAcademicHistory::create([
|
||||||
|
'student_id' => $student->id,
|
||||||
|
'academic_year_id' => $data['to_academic_year_id'],
|
||||||
|
'department_id' => $targetClass->department_id,
|
||||||
|
'class_id' => $targetClass->id,
|
||||||
|
'status' => 'active',
|
||||||
|
'start_date' => now()->toDateString(),
|
||||||
|
'end_date' => null,
|
||||||
|
'notes' => $promotion['notes'] ?? 'Hasil proses promosi siswa.',
|
||||||
|
'is_current' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$processed++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Alert::success('Berhasil', $processed . ' siswa berhasil diproses melalui modul promosi.');
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('student-promotions.index', [
|
||||||
|
'from_academic_year_id' => $data['from_academic_year_id'],
|
||||||
|
'to_academic_year_id' => $data['to_academic_year_id'],
|
||||||
|
])
|
||||||
|
->with('success', $processed . ' siswa berhasil diproses melalui modul promosi.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildPromotionRecommendation(Student $student, ?int $toAcademicYearId): array
|
||||||
|
{
|
||||||
|
$currentLevel = strtoupper((string) ($student->classRoom?->level ?? ''));
|
||||||
|
$nextLevel = match ($currentLevel) {
|
||||||
|
'X' => 'XI',
|
||||||
|
'XI' => 'XII',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($currentLevel === 'XII') {
|
||||||
|
return [
|
||||||
|
'action' => 'graduate',
|
||||||
|
'label' => 'Lulus',
|
||||||
|
'target_class_id' => null,
|
||||||
|
'target_class_name' => 'Siswa kelas XII direkomendasikan lulus.',
|
||||||
|
'available_classes' => [
|
||||||
|
'promote' => collect(),
|
||||||
|
'repeat' => collect(),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$promoteClasses = $toAcademicYearId && $nextLevel
|
||||||
|
? $this->findClassesForLevel($student, $toAcademicYearId, $nextLevel)
|
||||||
|
: collect();
|
||||||
|
|
||||||
|
$repeatClasses = $toAcademicYearId && $currentLevel
|
||||||
|
? $this->findClassesForLevel($student, $toAcademicYearId, $currentLevel)
|
||||||
|
: collect();
|
||||||
|
|
||||||
|
$recommendedPromoteClass = $this->pickRecommendedClass($promoteClasses, $student);
|
||||||
|
$recommendedRepeatClass = $this->pickRecommendedClass($repeatClasses, $student);
|
||||||
|
|
||||||
|
$defaultAction = $recommendedPromoteClass ? 'promote' : ($recommendedRepeatClass ? 'repeat' : 'repeat');
|
||||||
|
$defaultClass = $defaultAction === 'promote' ? $recommendedPromoteClass : $recommendedRepeatClass;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'action' => $defaultAction,
|
||||||
|
'label' => $defaultAction === 'promote' ? 'Naik Kelas' : 'Tinggal Kelas',
|
||||||
|
'target_class_id' => $defaultClass?->id,
|
||||||
|
'target_class_name' => $defaultClass?->name,
|
||||||
|
'available_classes' => [
|
||||||
|
'promote' => $this->transformClassOptions($promoteClasses),
|
||||||
|
'repeat' => $this->transformClassOptions($repeatClasses),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function findClassesForLevel(Student $student, int $academicYearId, string $level)
|
||||||
|
{
|
||||||
|
return SchoolClass::query()
|
||||||
|
->where('academic_year_id', $academicYearId)
|
||||||
|
->where('level', $level)
|
||||||
|
->where('is_active', true)
|
||||||
|
->orderByRaw('CASE WHEN department_id = ? THEN 0 ELSE 1 END', [$student->department_id])
|
||||||
|
->orderBy('name')
|
||||||
|
->get()
|
||||||
|
->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function pickRecommendedClass($classes, Student $student): ?SchoolClass
|
||||||
|
{
|
||||||
|
$sameDepartmentClasses = $classes->where('department_id', $student->department_id)->values();
|
||||||
|
|
||||||
|
return $sameDepartmentClasses->first(function (SchoolClass $classRoom) use ($student) {
|
||||||
|
return str_contains(strtolower($classRoom->name), strtolower((string) $student->classRoom?->name));
|
||||||
|
})
|
||||||
|
?? $sameDepartmentClasses->first()
|
||||||
|
?? $classes->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function transformClassOptions(Collection $classes): Collection
|
||||||
|
{
|
||||||
|
return $classes->map(function (SchoolClass $classRoom) {
|
||||||
|
$currentOccupancy = Student::query()
|
||||||
|
->where('academic_year_id', $classRoom->academic_year_id)
|
||||||
|
->where('class_id', $classRoom->id)
|
||||||
|
->where('status', 'active')
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$capacity = $classRoom->capacity;
|
||||||
|
$remainingCapacity = filled($capacity) ? max((int) $capacity - $currentOccupancy, 0) : null;
|
||||||
|
$capacityLabel = filled($capacity)
|
||||||
|
? "Kuota {$currentOccupancy}/{$capacity} • sisa {$remainingCapacity}"
|
||||||
|
: 'Kuota belum diatur';
|
||||||
|
|
||||||
|
return (object) [
|
||||||
|
'id' => $classRoom->id,
|
||||||
|
'name' => $classRoom->name,
|
||||||
|
'department_id' => $classRoom->department_id,
|
||||||
|
'capacity' => $capacity,
|
||||||
|
'current_occupancy' => $currentOccupancy,
|
||||||
|
'remaining_capacity' => $remainingCapacity,
|
||||||
|
'capacity_label' => $capacityLabel,
|
||||||
|
'option_label' => "{$classRoom->name} ({$capacityLabel})",
|
||||||
|
];
|
||||||
|
})->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isTargetClassValidForAction(Student $student, SchoolClass $targetClass, string $action): bool
|
||||||
|
{
|
||||||
|
$currentLevel = strtoupper((string) $student->classRoom?->level);
|
||||||
|
$targetLevel = strtoupper((string) $targetClass->level);
|
||||||
|
|
||||||
|
return match ($action) {
|
||||||
|
'promote' => $targetLevel === match ($currentLevel) {
|
||||||
|
'X' => 'XI',
|
||||||
|
'XI' => 'XII',
|
||||||
|
default => null,
|
||||||
|
},
|
||||||
|
'repeat' => $targetLevel === $currentLevel,
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateTargetClassCapacities(Collection $plannedClassAssignments, Collection $targetClasses): Collection
|
||||||
|
{
|
||||||
|
return $plannedClassAssignments->map(function (int $plannedCount, int|string $classId) use ($targetClasses) {
|
||||||
|
/** @var SchoolClass|null $targetClass */
|
||||||
|
$targetClass = $targetClasses->get($classId);
|
||||||
|
|
||||||
|
if (! $targetClass || blank($targetClass->capacity)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currentOccupancy = Student::query()
|
||||||
|
->where('academic_year_id', $targetClass->academic_year_id)
|
||||||
|
->where('class_id', $targetClass->id)
|
||||||
|
->where('status', 'active')
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$remainingCapacity = (int) $targetClass->capacity - $currentOccupancy;
|
||||||
|
|
||||||
|
if ($plannedCount > $remainingCapacity) {
|
||||||
|
return "Kelas {$targetClass->name} melebihi kapasitas. Sisa kuota {$remainingCapacity}, tetapi alokasi promosi/repeat yang dipilih {$plannedCount}.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
})->filter()->values();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\Student;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class StudentSelfServiceController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
$academicYearId = $request->get('academic_year_id');
|
||||||
|
$classId = $request->get('class_id');
|
||||||
|
$status = $request->get('status');
|
||||||
|
|
||||||
|
$students = Student::query()
|
||||||
|
->with(['academicYear', 'classRoom', 'department'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where(function ($subQuery) use ($search) {
|
||||||
|
$subQuery->where('full_name', 'like', "%{$search}%")
|
||||||
|
->orWhere('student_number', 'like', "%{$search}%")
|
||||||
|
->orWhere('nisn', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($academicYearId, fn ($query) => $query->where('academic_year_id', $academicYearId))
|
||||||
|
->when($classId, fn ($query) => $query->where('class_id', $classId))
|
||||||
|
->when($status, fn ($query) => $query->where('self_service_status', $status))
|
||||||
|
->latest()
|
||||||
|
->paginate(15)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
$summaryBaseQuery = Student::query();
|
||||||
|
|
||||||
|
return view('student-self-service.index', [
|
||||||
|
'students' => $students,
|
||||||
|
'search' => $search,
|
||||||
|
'filters' => [
|
||||||
|
'academic_year_id' => $academicYearId,
|
||||||
|
'class_id' => $classId,
|
||||||
|
'status' => $status,
|
||||||
|
],
|
||||||
|
'academicYears' => AcademicYear::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'classes' => SchoolClass::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'statuses' => [
|
||||||
|
'not_started' => 'Belum Mulai',
|
||||||
|
'draft' => 'Draft',
|
||||||
|
'submitted' => 'Sudah Dikirim',
|
||||||
|
],
|
||||||
|
'summary' => [
|
||||||
|
'total' => (clone $summaryBaseQuery)->count(),
|
||||||
|
'not_started' => (clone $summaryBaseQuery)->where('self_service_status', 'not_started')->count(),
|
||||||
|
'draft' => (clone $summaryBaseQuery)->where('self_service_status', 'draft')->count(),
|
||||||
|
'submitted' => (clone $summaryBaseQuery)->where('self_service_status', 'submitted')->count(),
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\AcademicYear;
|
||||||
|
use App\Models\Department;
|
||||||
|
use App\Models\SchoolClass;
|
||||||
|
use App\Models\StudentTransfer;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class StudentTransferController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->get('search'));
|
||||||
|
$academicYearId = $request->get('academic_year_id');
|
||||||
|
$departmentId = $request->get('department_id');
|
||||||
|
$classId = $request->get('class_id');
|
||||||
|
|
||||||
|
$studentTransfers = StudentTransfer::query()
|
||||||
|
->with(['academicYear', 'department', 'classRoom'])
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where(function ($subQuery) use ($search) {
|
||||||
|
$subQuery->where('full_name', 'like', "%{$search}%")
|
||||||
|
->orWhere('student_number', 'like', "%{$search}%")
|
||||||
|
->orWhere('nisn', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($academicYearId, fn ($query) => $query->where('academic_year_id', $academicYearId))
|
||||||
|
->when($departmentId, fn ($query) => $query->where('department_id', $departmentId))
|
||||||
|
->when($classId, fn ($query) => $query->where('class_id', $classId))
|
||||||
|
->latest('transfer_date')
|
||||||
|
->latest('id')
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('student-transfers.index', [
|
||||||
|
'studentTransfers' => $studentTransfers,
|
||||||
|
'search' => $search,
|
||||||
|
'filters' => [
|
||||||
|
'academic_year_id' => $academicYearId,
|
||||||
|
'department_id' => $departmentId,
|
||||||
|
'class_id' => $classId,
|
||||||
|
],
|
||||||
|
'academicYears' => AcademicYear::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'departments' => Department::orderBy('name')->pluck('name', 'id'),
|
||||||
|
'classes' => SchoolClass::orderBy('name')->pluck('name', 'id'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(StudentTransfer $studentTransfer): View
|
||||||
|
{
|
||||||
|
$studentTransfer->load(['academicYear', 'department', 'classRoom']);
|
||||||
|
|
||||||
|
return view('student-transfers.show', [
|
||||||
|
'studentTransfer' => $studentTransfer,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, StudentTransfer $studentTransfer): RedirectResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'transfer_date' => ['nullable', 'date'],
|
||||||
|
'transfer_reason' => ['nullable', 'string'],
|
||||||
|
'transfer_letter' => ['nullable', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:2048'],
|
||||||
|
], [
|
||||||
|
'transfer_letter.mimes' => 'Surat pindah harus berupa file PDF, JPG, JPEG, atau PNG.',
|
||||||
|
'transfer_letter.max' => 'Ukuran surat pindah maksimal 2 MB.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$studentTransfer->transfer_date = $validated['transfer_date'] ?? $studentTransfer->transfer_date;
|
||||||
|
$studentTransfer->transfer_reason = $validated['transfer_reason'] ?? $studentTransfer->transfer_reason;
|
||||||
|
|
||||||
|
if ($request->hasFile('transfer_letter')) {
|
||||||
|
if ($studentTransfer->transfer_letter_file_path && Storage::disk('public')->exists($studentTransfer->transfer_letter_file_path)) {
|
||||||
|
Storage::disk('public')->delete($studentTransfer->transfer_letter_file_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $request->file('transfer_letter');
|
||||||
|
$path = $file->store("student-transfer-letters/{$studentTransfer->student_id}", 'public');
|
||||||
|
|
||||||
|
$studentTransfer->transfer_letter_file_name = $file->getClientOriginalName();
|
||||||
|
$studentTransfer->transfer_letter_file_path = $path;
|
||||||
|
$studentTransfer->transfer_letter_mime_type = $file->getMimeType();
|
||||||
|
$studentTransfer->transfer_letter_file_size = $file->getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
$studentTransfer->save();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Arsip siswa mutasi berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('student-transfers.show', $studentTransfer)->with('success', 'Arsip siswa mutasi berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function previewLetter(StudentTransfer $studentTransfer): View
|
||||||
|
{
|
||||||
|
abort_unless($studentTransfer->transfer_letter_file_path && Storage::disk('public')->exists($studentTransfer->transfer_letter_file_path), 404);
|
||||||
|
|
||||||
|
$mimeType = $studentTransfer->transfer_letter_mime_type ?: Storage::disk('public')->mimeType($studentTransfer->transfer_letter_file_path);
|
||||||
|
$fileUrl = asset('storage/' . $studentTransfer->transfer_letter_file_path);
|
||||||
|
$isImage = str_starts_with((string) $mimeType, 'image/');
|
||||||
|
$isPdf = $mimeType === 'application/pdf';
|
||||||
|
|
||||||
|
return view('student-transfers.preview-letter', [
|
||||||
|
'studentTransfer' => $studentTransfer,
|
||||||
|
'fileUrl' => $fileUrl,
|
||||||
|
'mimeType' => $mimeType,
|
||||||
|
'isImage' => $isImage,
|
||||||
|
'isPdf' => $isPdf,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use RealRashid\SweetAlert\Facades\Alert;
|
||||||
|
|
||||||
|
class UserManagementController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request): View
|
||||||
|
{
|
||||||
|
$search = trim((string) $request->string('search'));
|
||||||
|
|
||||||
|
$users = User::query()
|
||||||
|
->when($search !== '', function ($query) use ($search) {
|
||||||
|
$query->where(function ($subQuery) use ($search) {
|
||||||
|
$subQuery->where('name', 'like', "%{$search}%")
|
||||||
|
->orWhere('email', 'like', "%{$search}%");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('name')
|
||||||
|
->paginate(10)
|
||||||
|
->withQueryString();
|
||||||
|
|
||||||
|
return view('users.index', [
|
||||||
|
'users' => $users,
|
||||||
|
'search' => $search,
|
||||||
|
'roleOptions' => $this->roleOptions(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(): View
|
||||||
|
{
|
||||||
|
return view('users.create', [
|
||||||
|
'roleOptions' => $this->roleOptions(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $this->validateUser($request);
|
||||||
|
|
||||||
|
User::create($data);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Akun pengguna berhasil ditambahkan.');
|
||||||
|
|
||||||
|
return redirect()->route('settings.users.index')->with('success', 'Akun pengguna berhasil ditambahkan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(User $user): View
|
||||||
|
{
|
||||||
|
return view('users.edit', [
|
||||||
|
'user' => $user,
|
||||||
|
'roleOptions' => $this->roleOptions(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, User $user): RedirectResponse
|
||||||
|
{
|
||||||
|
$data = $this->validateUser($request, $user);
|
||||||
|
|
||||||
|
if (blank($data['password'] ?? null)) {
|
||||||
|
unset($data['password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update($data);
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Akun pengguna berhasil diperbarui.');
|
||||||
|
|
||||||
|
return redirect()->route('settings.users.index')->with('success', 'Akun pengguna berhasil diperbarui.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(Request $request, User $user): RedirectResponse
|
||||||
|
{
|
||||||
|
if ((int) $request->user()->id === (int) $user->id) {
|
||||||
|
return back()->withErrors(['user' => 'Akun yang sedang dipakai login tidak bisa dihapus.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (User::query()->where('role', 'admin')->count() <= 1 && $user->role === 'admin') {
|
||||||
|
return back()->withErrors(['user' => 'Minimal harus ada satu akun admin aktif di sistem.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
Alert::success('Berhasil', 'Akun pengguna berhasil dihapus.');
|
||||||
|
|
||||||
|
return redirect()->route('settings.users.index')->with('success', 'Akun pengguna berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function validateUser(Request $request, ?User $user = null): array
|
||||||
|
{
|
||||||
|
$passwordRules = $user
|
||||||
|
? ['nullable', 'string', 'min:8', 'confirmed']
|
||||||
|
: ['required', 'string', 'min:8', 'confirmed'];
|
||||||
|
|
||||||
|
return $request->validate([
|
||||||
|
'name' => ['required', 'string', 'max:100'],
|
||||||
|
'email' => ['required', 'email', 'max:150', Rule::unique('users', 'email')->ignore($user?->id)],
|
||||||
|
'role' => ['required', Rule::in(array_keys($this->roleOptions()))],
|
||||||
|
'password' => $passwordRules,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function roleOptions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'admin' => 'Administrator',
|
||||||
|
'staff' => 'Staff',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class EnsureUserHasRole
|
||||||
|
{
|
||||||
|
public function handle(Request $request, Closure $next, string ...$roles): Response
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (! $user || ! in_array($user->role, $roles, true)) {
|
||||||
|
abort(403, 'Anda tidak memiliki akses ke halaman ini.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Auth;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Lockout;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class LoginRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email' => ['required', 'string', 'email'],
|
||||||
|
'password' => ['required', 'string'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to authenticate the request's credentials.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function authenticate(): void
|
||||||
|
{
|
||||||
|
$this->ensureIsNotRateLimited();
|
||||||
|
|
||||||
|
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||||
|
RateLimiter::hit($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.failed'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::clear($this->throttleKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the login request is not rate limited.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function ensureIsNotRateLimited(): void
|
||||||
|
{
|
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event(new Lockout($this));
|
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => trans('auth.throttle', [
|
||||||
|
'seconds' => $seconds,
|
||||||
|
'minutes' => ceil($seconds / 60),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the rate limiting throttle key for the request.
|
||||||
|
*/
|
||||||
|
public function throttleKey(): string
|
||||||
|
{
|
||||||
|
return Str::transliterate(Str::lower($this->string('email')).'|'.$this->ip());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ProfileUpdateRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'lowercase',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique(User::class)->ignore($this->user()->id),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class AcademicYear extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'start_year',
|
||||||
|
'end_year',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classes(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(SchoolClass::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function students(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Student::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class AppSetting extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'key',
|
||||||
|
'value',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function getValue(string $key, mixed $default = null): mixed
|
||||||
|
{
|
||||||
|
return static::query()->where('key', $key)->value('value') ?? $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setValue(string $key, mixed $value): void
|
||||||
|
{
|
||||||
|
static::query()->updateOrCreate(
|
||||||
|
['key' => $key],
|
||||||
|
['value' => $value]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function brandingDefaults(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'app_name' => 'Database Kesiswaan',
|
||||||
|
'app_short_name' => 'DK',
|
||||||
|
'app_logo' => null,
|
||||||
|
'app_favicon' => null,
|
||||||
|
'public_portal_logo' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function branding(): array
|
||||||
|
{
|
||||||
|
$defaults = static::brandingDefaults();
|
||||||
|
|
||||||
|
foreach (array_keys($defaults) as $key) {
|
||||||
|
$defaults[$key] = static::getValue($key, $defaults[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $defaults;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Department extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classes(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(SchoolClass::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function students(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Student::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class District extends Model
|
||||||
|
{
|
||||||
|
public $incrementing = false;
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
protected $fillable = ['id', 'regency_id', 'name'];
|
||||||
|
|
||||||
|
public function regency(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Regency::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function villages(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Village::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class DocumentType extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'code',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'max_file_size_kb',
|
||||||
|
'allowed_extensions',
|
||||||
|
'is_required',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'max_file_size_kb' => 'integer',
|
||||||
|
'is_required' => 'boolean',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function studentDocuments(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(StudentDocument::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Province extends Model
|
||||||
|
{
|
||||||
|
public $incrementing = false;
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
protected $fillable = ['id', 'name'];
|
||||||
|
|
||||||
|
public function regencies(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Regency::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Regency extends Model
|
||||||
|
{
|
||||||
|
public $incrementing = false;
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
protected $fillable = ['id', 'province_id', 'name'];
|
||||||
|
|
||||||
|
public function province(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Province::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function districts(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(District::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class SchoolClass extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'classes';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'academic_year_id',
|
||||||
|
'department_id',
|
||||||
|
'name',
|
||||||
|
'level',
|
||||||
|
'homeroom_teacher',
|
||||||
|
'capacity',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'capacity' => 'integer',
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicYear(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(AcademicYear::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function students(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Student::class, 'class_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicHistories(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(StudentAcademicHistory::class, 'class_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class Student extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected static function booted(): void
|
||||||
|
{
|
||||||
|
static::deleting(function (Student $student) {
|
||||||
|
if ($student->isForceDeleting()) {
|
||||||
|
$student->documents()->withTrashed()->get()->each->forceDelete();
|
||||||
|
$student->parents()->delete();
|
||||||
|
$student->academicHistories()->delete();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$student->documents()->get()->each->delete();
|
||||||
|
$student->parents()->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
static::restoring(function (Student $student) {
|
||||||
|
$student->documents()->onlyTrashed()->restore();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_number',
|
||||||
|
'nisn',
|
||||||
|
'full_name',
|
||||||
|
'gender',
|
||||||
|
'place_of_birth',
|
||||||
|
'date_of_birth',
|
||||||
|
'religion',
|
||||||
|
'nationality',
|
||||||
|
'family_card_number',
|
||||||
|
'child_order',
|
||||||
|
'number_of_siblings',
|
||||||
|
'phone_number',
|
||||||
|
'email',
|
||||||
|
'address',
|
||||||
|
'province_id',
|
||||||
|
'regency_id',
|
||||||
|
'district_id',
|
||||||
|
'village_id',
|
||||||
|
'village',
|
||||||
|
'district',
|
||||||
|
'city',
|
||||||
|
'province',
|
||||||
|
'postal_code',
|
||||||
|
'academic_year_id',
|
||||||
|
'department_id',
|
||||||
|
'class_id',
|
||||||
|
'entry_date',
|
||||||
|
'status',
|
||||||
|
'self_service_status',
|
||||||
|
'self_service_last_access_at',
|
||||||
|
'self_service_submitted_at',
|
||||||
|
'self_service_access_code',
|
||||||
|
'self_service_code_generated_at',
|
||||||
|
'photo_path',
|
||||||
|
'notes',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'date_of_birth' => 'date',
|
||||||
|
'entry_date' => 'date',
|
||||||
|
'self_service_last_access_at' => 'datetime',
|
||||||
|
'self_service_submitted_at' => 'datetime',
|
||||||
|
'self_service_code_generated_at' => 'datetime',
|
||||||
|
'child_order' => 'integer',
|
||||||
|
'number_of_siblings' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicYear(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(AcademicYear::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classRoom(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provinceRef(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Province::class, 'province_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function regencyRef(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Regency::class, 'regency_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function districtRef(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(District::class, 'district_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function villageRef(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Village::class, 'village_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parents(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(StudentParent::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function documents(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(StudentDocument::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicHistories(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(StudentAcademicHistory::class)->latest('academic_year_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exitRecord(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(StudentExit::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transferRecord(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(StudentTransfer::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class StudentAcademicHistory extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_id',
|
||||||
|
'academic_year_id',
|
||||||
|
'department_id',
|
||||||
|
'class_id',
|
||||||
|
'status',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
|
'notes',
|
||||||
|
'is_current',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'start_date' => 'date',
|
||||||
|
'end_date' => 'date',
|
||||||
|
'is_current' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicYear(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(AcademicYear::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classRoom(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class StudentDocument extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_id',
|
||||||
|
'document_type_id',
|
||||||
|
'file_name',
|
||||||
|
'file_path',
|
||||||
|
'file_extension',
|
||||||
|
'mime_type',
|
||||||
|
'file_size',
|
||||||
|
'document_number',
|
||||||
|
'issued_date',
|
||||||
|
'expired_date',
|
||||||
|
'description',
|
||||||
|
'verification_status',
|
||||||
|
'verification_note',
|
||||||
|
'uploaded_by',
|
||||||
|
'verified_by',
|
||||||
|
'verified_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'file_size' => 'integer',
|
||||||
|
'issued_date' => 'date',
|
||||||
|
'expired_date' => 'date',
|
||||||
|
'verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function documentType(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(DocumentType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uploadedBy(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'uploaded_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifiedBy(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'verified_by');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class StudentExit extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_id',
|
||||||
|
'student_number',
|
||||||
|
'nisn',
|
||||||
|
'full_name',
|
||||||
|
'academic_year_id',
|
||||||
|
'department_id',
|
||||||
|
'class_id',
|
||||||
|
'entry_date',
|
||||||
|
'exit_date',
|
||||||
|
'exit_reason',
|
||||||
|
'exit_letter_file_name',
|
||||||
|
'exit_letter_file_path',
|
||||||
|
'exit_letter_mime_type',
|
||||||
|
'exit_letter_file_size',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'entry_date' => 'date',
|
||||||
|
'exit_date' => 'date',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicYear(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(AcademicYear::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classRoom(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class StudentParent extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_id',
|
||||||
|
'relation_type',
|
||||||
|
'name',
|
||||||
|
'nik',
|
||||||
|
'birth_year',
|
||||||
|
'education',
|
||||||
|
'occupation',
|
||||||
|
'phone_number',
|
||||||
|
'address',
|
||||||
|
'is_alive',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'birth_year' => 'integer',
|
||||||
|
'is_alive' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class StudentTransfer extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'student_id',
|
||||||
|
'student_number',
|
||||||
|
'nisn',
|
||||||
|
'full_name',
|
||||||
|
'academic_year_id',
|
||||||
|
'department_id',
|
||||||
|
'class_id',
|
||||||
|
'entry_date',
|
||||||
|
'transfer_date',
|
||||||
|
'transfer_reason',
|
||||||
|
'transfer_letter_file_name',
|
||||||
|
'transfer_letter_file_path',
|
||||||
|
'transfer_letter_mime_type',
|
||||||
|
'transfer_letter_file_size',
|
||||||
|
'status',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'entry_date' => 'date',
|
||||||
|
'transfer_date' => 'date',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function student(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Student::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function academicYear(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(AcademicYear::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function classRoom(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Database\Factories\UserFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||||
|
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
|
#[Fillable(['name', 'email', 'role', 'password'])]
|
||||||
|
#[Hidden(['password', 'remember_token'])]
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
/** @use HasFactory<UserFactory> */
|
||||||
|
use HasFactory, Notifiable;
|
||||||
|
|
||||||
|
public function isAdmin(): bool
|
||||||
|
{
|
||||||
|
return $this->role === 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
'password' => 'hashed',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class Village extends Model
|
||||||
|
{
|
||||||
|
public $incrementing = false;
|
||||||
|
protected $keyType = 'string';
|
||||||
|
|
||||||
|
protected $fillable = ['id', 'district_id', 'name'];
|
||||||
|
|
||||||
|
public function district(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(District::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*/
|
||||||
|
public function register(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*/
|
||||||
|
public function boot(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class AppLayout extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represents the component.
|
||||||
|
*/
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('layouts.app');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\View\Components;
|
||||||
|
|
||||||
|
use Illuminate\View\Component;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class GuestLayout extends Component
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the view / contents that represents the component.
|
||||||
|
*/
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('layouts.guest');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
// Register the Composer autoloader...
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
// Bootstrap Laravel and handle the command...
|
||||||
|
/** @var Application $app */
|
||||||
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
$status = $app->handleCommand(new ArgvInput);
|
||||||
|
|
||||||
|
exit($status);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
|
|
||||||
|
return Application::configure(basePath: dirname(__DIR__))
|
||||||
|
->withRouting(
|
||||||
|
web: __DIR__.'/../routes/web.php',
|
||||||
|
commands: __DIR__.'/../routes/console.php',
|
||||||
|
health: '/up',
|
||||||
|
)
|
||||||
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
|
$middleware->alias([
|
||||||
|
'role' => \App\Http\Middleware\EnsureUserHasRole::class,
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
->withExceptions(function (Exceptions $exceptions): void {
|
||||||
|
//
|
||||||
|
})->create();
|
||||||
Executable
+2
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Providers\AppServiceProvider;
|
||||||
|
|
||||||
|
return [
|
||||||
|
AppServiceProvider::class,
|
||||||
|
];
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://getcomposer.org/schema.json",
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The skeleton application for the Laravel framework.",
|
||||||
|
"keywords": ["laravel", "framework"],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.3",
|
||||||
|
"laravel/framework": "^13.0",
|
||||||
|
"laravel/tinker": "^3.0",
|
||||||
|
"phpoffice/phpspreadsheet": "^2.1",
|
||||||
|
"realrashid/sweet-alert": "^7.3"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.23",
|
||||||
|
"laravel/breeze": "^2.4",
|
||||||
|
"laravel/pail": "^1.2.5",
|
||||||
|
"laravel/pint": "^1.27",
|
||||||
|
"mockery/mockery": "^1.6",
|
||||||
|
"nunomaduro/collision": "^8.6",
|
||||||
|
"phpunit/phpunit": "^12.5.12"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"setup": [
|
||||||
|
"composer install",
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||||
|
"@php artisan key:generate",
|
||||||
|
"@php artisan migrate --force",
|
||||||
|
"npm install --ignore-scripts",
|
||||||
|
"npm run build"
|
||||||
|
],
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||||
|
],
|
||||||
|
"test": [
|
||||||
|
"@php artisan config:clear --ansi",
|
||||||
|
"@php artisan test"
|
||||||
|
],
|
||||||
|
"post-autoload-dump": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
|
"@php artisan package:discover --ansi"
|
||||||
|
],
|
||||||
|
"post-update-cmd": [
|
||||||
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||||
|
],
|
||||||
|
"post-root-package-install": [
|
||||||
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
],
|
||||||
|
"post-create-project-cmd": [
|
||||||
|
"@php artisan key:generate --ansi",
|
||||||
|
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||||
|
"@php artisan migrate --graceful --ansi"
|
||||||
|
],
|
||||||
|
"pre-package-uninstall": [
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true,
|
||||||
|
"allow-plugins": {
|
||||||
|
"pestphp/pest-plugin": true,
|
||||||
|
"php-http/discovery": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
||||||
Generated
+8675
File diff suppressed because it is too large
Load Diff
+126
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the name of your application, which will be used when the
|
||||||
|
| framework needs to place the application's name in a notification or
|
||||||
|
| other UI elements where an application name needs to be displayed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'name' => env('APP_NAME', 'Laravel'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Environment
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the "environment" your application is currently
|
||||||
|
| running in. This may determine how you prefer to configure various
|
||||||
|
| services the application utilizes. Set this in your ".env" file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'env' => env('APP_ENV', 'production'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Debug Mode
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When your application is in debug mode, detailed error messages with
|
||||||
|
| stack traces will be shown on every error that occurs within your
|
||||||
|
| application. If disabled, a simple generic error page is shown.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'debug' => (bool) env('APP_DEBUG', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application URL
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This URL is used by the console to properly generate URLs when using
|
||||||
|
| the Artisan command line tool. You should set this to the root of
|
||||||
|
| the application so that it's available within Artisan commands.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default timezone for your application, which
|
||||||
|
| will be used by the PHP date and date-time functions. The timezone
|
||||||
|
| is set to "UTC" by default as it is suitable for most use cases.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'UTC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The application locale determines the default locale that will be used
|
||||||
|
| by Laravel's translation / localization methods. This option can be
|
||||||
|
| set to any locale for which you plan to have translation strings.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => env('APP_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||||
|
|
||||||
|
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This key is utilized by Laravel's encryption services and should be set
|
||||||
|
| to a random, 32 character string to ensure that all encrypted values
|
||||||
|
| are secure. You should do this prior to deploying the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'previous_keys' => [
|
||||||
|
...array_filter(
|
||||||
|
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||||
|
),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maintenance Mode Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options determine the driver used to determine and
|
||||||
|
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||||
|
| allow maintenance mode to be controlled across multiple machines.
|
||||||
|
|
|
||||||
|
| Supported drivers: "file", "cache"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'maintenance' => [
|
||||||
|
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||||
|
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
+117
@@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Defaults
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default authentication "guard" and password
|
||||||
|
| reset "broker" for your application. You may change these values
|
||||||
|
| as required, but they're a perfect start for most applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'defaults' => [
|
||||||
|
'guard' => env('AUTH_GUARD', 'web'),
|
||||||
|
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, you may define every authentication guard for your application.
|
||||||
|
| Of course, a great default configuration has been defined for you
|
||||||
|
| which utilizes session storage plus the Eloquent user provider.
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| Supported: "session"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guards' => [
|
||||||
|
'web' => [
|
||||||
|
'driver' => 'session',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All authentication guards have a user provider, which defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| system used by the application. Typically, Eloquent is utilized.
|
||||||
|
|
|
||||||
|
| If you have multiple user tables or models you may configure multiple
|
||||||
|
| providers to represent the model / table. These providers may then
|
||||||
|
| be assigned to any extra authentication guards you have defined.
|
||||||
|
|
|
||||||
|
| Supported: "database", "eloquent"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
'users' => [
|
||||||
|
'driver' => 'eloquent',
|
||||||
|
'model' => env('AUTH_MODEL', User::class),
|
||||||
|
],
|
||||||
|
|
||||||
|
// 'users' => [
|
||||||
|
// 'driver' => 'database',
|
||||||
|
// 'table' => 'users',
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Resetting Passwords
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These configuration options specify the behavior of Laravel's password
|
||||||
|
| reset functionality, including the table utilized for token storage
|
||||||
|
| and the user provider that is invoked to actually retrieve users.
|
||||||
|
|
|
||||||
|
| The expiry time is the number of minutes that each reset token will be
|
||||||
|
| considered valid. This security feature keeps tokens short-lived so
|
||||||
|
| they have less time to be guessed. You may change this as needed.
|
||||||
|
|
|
||||||
|
| The throttle setting is the number of seconds a user must wait before
|
||||||
|
| generating more password reset tokens. This prevents the user from
|
||||||
|
| quickly generating a very large amount of password reset tokens.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'passwords' => [
|
||||||
|
'users' => [
|
||||||
|
'provider' => 'users',
|
||||||
|
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||||
|
'expire' => 60,
|
||||||
|
'throttle' => 60,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Confirmation Timeout
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define the number of seconds before a password confirmation
|
||||||
|
| window expires and users are asked to re-enter their password via the
|
||||||
|
| confirmation screen. By default, the timeout lasts for three hours.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default cache store that will be used by the
|
||||||
|
| framework. This connection is utilized if another isn't explicitly
|
||||||
|
| specified when running a cache operation inside the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('CACHE_STORE', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Stores
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define all of the cache "stores" for your application as
|
||||||
|
| well as their drivers. You may even define multiple stores for the
|
||||||
|
| same cache driver to group types of items stored in your caches.
|
||||||
|
|
|
||||||
|
| Supported drivers: "array", "database", "file", "memcached",
|
||||||
|
| "redis", "dynamodb", "octane",
|
||||||
|
| "failover", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stores' => [
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'driver' => 'array',
|
||||||
|
'serialize' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_CACHE_CONNECTION'),
|
||||||
|
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||||
|
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||||
|
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'file' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
'path' => storage_path('framework/cache/data'),
|
||||||
|
'lock_path' => storage_path('framework/cache/data'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'memcached' => [
|
||||||
|
'driver' => 'memcached',
|
||||||
|
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||||
|
'sasl' => [
|
||||||
|
env('MEMCACHED_USERNAME'),
|
||||||
|
env('MEMCACHED_PASSWORD'),
|
||||||
|
],
|
||||||
|
'options' => [
|
||||||
|
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||||
|
],
|
||||||
|
'servers' => [
|
||||||
|
[
|
||||||
|
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MEMCACHED_PORT', 11211),
|
||||||
|
'weight' => 100,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||||
|
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'dynamodb' => [
|
||||||
|
'driver' => 'dynamodb',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||||
|
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'octane' => [
|
||||||
|
'driver' => 'octane',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'driver' => 'failover',
|
||||||
|
'stores' => [
|
||||||
|
'database',
|
||||||
|
'array',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Key Prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||||
|
| stores, there might be other applications using the same cache. For
|
||||||
|
| that reason, you may prefix every cache key to avoid collisions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Serializable Classes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the classes that can be unserialized from cache
|
||||||
|
| storage. By default, no PHP classes will be unserialized from your
|
||||||
|
| cache to prevent gadget chain attacks if your APP_KEY is leaked.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'serializable_classes' => false,
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Pdo\Mysql;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Database Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which of the database connections below you wish
|
||||||
|
| to use as your default connection for database operations. This is
|
||||||
|
| the connection which will be utilized unless another connection
|
||||||
|
| is explicitly specified when you execute a query / statement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Database Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below are all of the database connections defined for your application.
|
||||||
|
| An example configuration is provided for each database system which
|
||||||
|
| is supported by Laravel. You're free to add / remove connections.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sqlite' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||||
|
'prefix' => '',
|
||||||
|
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||||
|
'busy_timeout' => null,
|
||||||
|
'journal_mode' => null,
|
||||||
|
'synchronous' => null,
|
||||||
|
'transaction_mode' => 'DEFERRED',
|
||||||
|
],
|
||||||
|
|
||||||
|
'mysql' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'mariadb' => [
|
||||||
|
'driver' => 'mariadb',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||||
|
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'pgsql' => [
|
||||||
|
'driver' => 'pgsql',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '5432'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'search_path' => 'public',
|
||||||
|
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqlsrv' => [
|
||||||
|
'driver' => 'sqlsrv',
|
||||||
|
'url' => env('DB_URL'),
|
||||||
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
|
'port' => env('DB_PORT', '1433'),
|
||||||
|
'database' => env('DB_DATABASE', 'laravel'),
|
||||||
|
'username' => env('DB_USERNAME', 'root'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => env('DB_CHARSET', 'utf8'),
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||||
|
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migration Repository Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This table keeps track of all the migrations that have already run for
|
||||||
|
| your application. Using this information, we can determine which of
|
||||||
|
| the migrations on disk haven't actually been run on the database.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'migrations' => [
|
||||||
|
'table' => 'migrations',
|
||||||
|
'update_date_on_publish' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Redis Databases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Redis is an open source, fast, and advanced key-value store that also
|
||||||
|
| provides a richer body of commands than a typical key-value system
|
||||||
|
| such as Memcached. You may define your connection settings here.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
|
||||||
|
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
|
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||||
|
'persistent' => env('REDIS_PERSISTENT', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
'default' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_DB', '0'),
|
||||||
|
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||||
|
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||||
|
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||||
|
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'username' => env('REDIS_USERNAME'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_CACHE_DB', '1'),
|
||||||
|
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||||
|
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||||
|
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||||
|
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Filesystem Disk
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default filesystem disk that should be used
|
||||||
|
| by the framework. The "local" disk, as well as a variety of cloud
|
||||||
|
| based disks are available to your application for file storage.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filesystem Disks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Below you may configure as many filesystem disks as necessary, and you
|
||||||
|
| may even configure multiple disks for the same driver. Examples for
|
||||||
|
| most supported storage drivers are configured here for reference.
|
||||||
|
|
|
||||||
|
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disks' => [
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/private'),
|
||||||
|
'serve' => true,
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'public' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public'),
|
||||||
|
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
's3' => [
|
||||||
|
'driver' => 's3',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION'),
|
||||||
|
'bucket' => env('AWS_BUCKET'),
|
||||||
|
'url' => env('AWS_URL'),
|
||||||
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
|
'throw' => false,
|
||||||
|
'report' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Symbolic Links
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the symbolic links that will be created when the
|
||||||
|
| `storage:link` Artisan command is executed. The array keys should be
|
||||||
|
| the locations of the links and the values should be their targets.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'links' => [
|
||||||
|
public_path('storage') => storage_path('app/public'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Monolog\Handler\NullHandler;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\SyslogUdpHandler;
|
||||||
|
use Monolog\Processor\PsrLogMessageProcessor;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default log channel that is utilized to write
|
||||||
|
| messages to your logs. The value provided here should match one of
|
||||||
|
| the channels present in the list of "channels" configured below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('LOG_CHANNEL', 'stack'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Deprecations Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the log channel that should be used to log warnings
|
||||||
|
| regarding deprecated PHP and library features. This allows you to get
|
||||||
|
| your application ready for upcoming major versions of dependencies.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'deprecations' => [
|
||||||
|
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||||
|
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log Channels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the log channels for your application. Laravel
|
||||||
|
| utilizes the Monolog PHP logging library, which includes a variety
|
||||||
|
| of powerful log handlers and formatters that you're free to use.
|
||||||
|
|
|
||||||
|
| Available drivers: "single", "daily", "slack", "syslog",
|
||||||
|
| "errorlog", "monolog", "custom", "stack"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'channels' => [
|
||||||
|
|
||||||
|
'stack' => [
|
||||||
|
'driver' => 'stack',
|
||||||
|
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||||
|
'ignore_exceptions' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'single' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'daily' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'days' => env('LOG_DAILY_DAYS', 14),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'driver' => 'slack',
|
||||||
|
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||||
|
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
|
||||||
|
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||||
|
'level' => env('LOG_LEVEL', 'critical'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'papertrail' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||||
|
'handler_with' => [
|
||||||
|
'host' => env('PAPERTRAIL_URL'),
|
||||||
|
'port' => env('PAPERTRAIL_PORT'),
|
||||||
|
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||||
|
],
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'stderr' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => StreamHandler::class,
|
||||||
|
'handler_with' => [
|
||||||
|
'stream' => 'php://stderr',
|
||||||
|
],
|
||||||
|
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||||
|
'processors' => [PsrLogMessageProcessor::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'syslog' => [
|
||||||
|
'driver' => 'syslog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'errorlog' => [
|
||||||
|
'driver' => 'errorlog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'replace_placeholders' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'handler' => NullHandler::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'emergency' => [
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
+118
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Mailer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default mailer that is used to send all email
|
||||||
|
| messages unless another mailer is explicitly specified when sending
|
||||||
|
| the message. All additional mailers can be configured within the
|
||||||
|
| "mailers" array. Examples of each type of mailer are provided.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('MAIL_MAILER', 'log'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Mailer Configurations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure all of the mailers used by your application plus
|
||||||
|
| their respective settings. Several examples have been configured for
|
||||||
|
| you and you are free to add your own as your application requires.
|
||||||
|
|
|
||||||
|
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||||
|
| when delivering an email. You may specify which one you're using for
|
||||||
|
| your mailers below. You may also add additional mailers if needed.
|
||||||
|
|
|
||||||
|
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||||
|
| "postmark", "resend", "log", "array",
|
||||||
|
| "failover", "roundrobin"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailers' => [
|
||||||
|
|
||||||
|
'smtp' => [
|
||||||
|
'transport' => 'smtp',
|
||||||
|
'scheme' => env('MAIL_SCHEME'),
|
||||||
|
'url' => env('MAIL_URL'),
|
||||||
|
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('MAIL_PORT', 2525),
|
||||||
|
'username' => env('MAIL_USERNAME'),
|
||||||
|
'password' => env('MAIL_PASSWORD'),
|
||||||
|
'timeout' => null,
|
||||||
|
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'transport' => 'ses',
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'transport' => 'postmark',
|
||||||
|
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||||
|
// 'client' => [
|
||||||
|
// 'timeout' => 5,
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'transport' => 'resend',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sendmail' => [
|
||||||
|
'transport' => 'sendmail',
|
||||||
|
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'transport' => 'log',
|
||||||
|
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'transport' => 'array',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'transport' => 'failover',
|
||||||
|
'mailers' => [
|
||||||
|
'smtp',
|
||||||
|
'log',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
'roundrobin' => [
|
||||||
|
'transport' => 'roundrobin',
|
||||||
|
'mailers' => [
|
||||||
|
'ses',
|
||||||
|
'postmark',
|
||||||
|
],
|
||||||
|
'retry_after' => 60,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global "From" Address
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You may wish for all emails sent by your application to be sent from
|
||||||
|
| the same address. Here you may specify a name and address that is
|
||||||
|
| used globally for all emails that are sent by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'from' => [
|
||||||
|
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||||
|
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Queue Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Laravel's queue supports a variety of backends via a single, unified
|
||||||
|
| API, giving you convenient access to each backend using identical
|
||||||
|
| syntax for each. The default queue connection is defined below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queue Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the connection options for every queue backend
|
||||||
|
| used by your application. An example configuration is provided for
|
||||||
|
| each backend supported by Laravel. You're also free to add more.
|
||||||
|
|
|
||||||
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||||
|
| "deferred", "background", "failover", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sync' => [
|
||||||
|
'driver' => 'sync',
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||||
|
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||||
|
'queue' => env('DB_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'beanstalkd' => [
|
||||||
|
'driver' => 'beanstalkd',
|
||||||
|
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||||
|
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => 0,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqs' => [
|
||||||
|
'driver' => 'sqs',
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||||
|
'queue' => env('SQS_QUEUE', 'default'),
|
||||||
|
'suffix' => env('SQS_SUFFIX'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||||
|
'queue' => env('REDIS_QUEUE', 'default'),
|
||||||
|
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||||
|
'block_for' => null,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'deferred' => [
|
||||||
|
'driver' => 'deferred',
|
||||||
|
],
|
||||||
|
|
||||||
|
'background' => [
|
||||||
|
'driver' => 'background',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'driver' => 'failover',
|
||||||
|
'connections' => [
|
||||||
|
'database',
|
||||||
|
'deferred',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Job Batching
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The following options configure the database and table that store job
|
||||||
|
| batching information. These options can be updated to any database
|
||||||
|
| connection and table which has been defined by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'batching' => [
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'job_batches',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Failed Queue Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These options configure the behavior of failed queue job logging so you
|
||||||
|
| can control how and where failed jobs are stored. Laravel ships with
|
||||||
|
| support for storing failed jobs in a simple file or in a database.
|
||||||
|
|
|
||||||
|
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => [
|
||||||
|
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||||
|
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||||
|
'table' => 'failed_jobs',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Third Party Services
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This file is for storing the credentials for third party services such
|
||||||
|
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||||
|
| location for this type of information, allowing packages to have
|
||||||
|
| a conventional file to locate the various service credentials.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'key' => env('POSTMARK_API_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'resend' => [
|
||||||
|
'key' => env('RESEND_API_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'notifications' => [
|
||||||
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1,233 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Session Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines the default session driver that is utilized for
|
||||||
|
| incoming requests. Laravel supports a variety of storage options to
|
||||||
|
| persist session data. Database storage is a great default choice.
|
||||||
|
|
|
||||||
|
| Supported: "file", "cookie", "database", "memcached",
|
||||||
|
| "redis", "dynamodb", "array"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('SESSION_DRIVER', 'database'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Lifetime
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the number of minutes that you wish the session
|
||||||
|
| to be allowed to remain idle before it expires. If you want them
|
||||||
|
| to expire immediately when the browser is closed then you may
|
||||||
|
| indicate that via the expire_on_close configuration option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
|
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Encryption
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option allows you to easily specify that all of your session data
|
||||||
|
| should be encrypted before it's stored. All encryption is performed
|
||||||
|
| automatically by Laravel and you may use the session like normal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session File Location
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing the "file" session driver, the session files are placed
|
||||||
|
| on disk. The default storage location is defined here; however, you
|
||||||
|
| are free to provide another location where they should be stored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'files' => storage_path('framework/sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Connection
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" or "redis" session drivers, you may specify a
|
||||||
|
| connection that should be used to manage these sessions. This should
|
||||||
|
| correspond to a connection in your database configuration options.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connection' => env('SESSION_CONNECTION'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Database Table
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the "database" session driver, you may specify the table to
|
||||||
|
| be used to store sessions. Of course, a sensible default is defined
|
||||||
|
| for you; however, you're welcome to change this to another table.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'table' => env('SESSION_TABLE', 'sessions'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using one of the framework's cache driven session backends, you may
|
||||||
|
| define the cache store which should be used to store the session data
|
||||||
|
| between requests. This must match one of your defined cache stores.
|
||||||
|
|
|
||||||
|
| Affects: "dynamodb", "memcached", "redis"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'store' => env('SESSION_STORE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Sweeping Lottery
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Some session drivers must manually sweep their storage location to get
|
||||||
|
| rid of old sessions from storage. Here are the chances that it will
|
||||||
|
| happen on a given request. By default, the odds are 2 out of 100.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lottery' => [2, 100],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the name of the session cookie that is created by
|
||||||
|
| the framework. Typically, you should not need to change this value
|
||||||
|
| since doing so does not grant a meaningful security improvement.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cookie' => env(
|
||||||
|
'SESSION_COOKIE',
|
||||||
|
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||||
|
),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The session cookie path determines the path for which the cookie will
|
||||||
|
| be regarded as available. Typically, this will be the root path of
|
||||||
|
| your application, but you're free to change this when necessary.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => env('SESSION_PATH', '/'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value determines the domain and subdomains the session cookie is
|
||||||
|
| available to. By default, the cookie will be available to the root
|
||||||
|
| domain without subdomains. Typically, this shouldn't be changed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'domain' => env('SESSION_DOMAIN'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTPS Only Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By setting this option to true, session cookies will only be sent back
|
||||||
|
| to the server if the browser has a HTTPS connection. This will keep
|
||||||
|
| the cookie from being sent to you when it can't be done securely.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTTP Access Only
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will prevent JavaScript from accessing the
|
||||||
|
| value of the cookie and the cookie will only be accessible through
|
||||||
|
| the HTTP protocol. It's unlikely you should disable this option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Same-Site Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines how your cookies behave when cross-site requests
|
||||||
|
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||||
|
| will set this value to "lax" to permit secure cross-site requests.
|
||||||
|
|
|
||||||
|
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||||
|
|
|
||||||
|
| Supported: "lax", "strict", "none", null
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Partitioned Cookies
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Setting this value to true will tie the cookie to the top-level site for
|
||||||
|
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||||
|
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Serialization
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value controls the serialization strategy for session data, which
|
||||||
|
| is JSON by default. Setting this to "php" allows the storage of PHP
|
||||||
|
| objects in the session but can make an application vulnerable to
|
||||||
|
| "gadget chain" serialization attacks if the APP_KEY is leaked.
|
||||||
|
|
|
||||||
|
| Supported: "json", "php"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'serialization' => 'json',
|
||||||
|
|
||||||
|
];
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
*.sqlite*
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<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,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?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('name');
|
||||||
|
$table->string('email')->unique();
|
||||||
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
|
$table->string('password');
|
||||||
|
$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->bigInteger('expiration')->index();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('cache_locks', function (Blueprint $table) {
|
||||||
|
$table->string('key')->primary();
|
||||||
|
$table->string('owner');
|
||||||
|
$table->bigInteger('expiration')->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,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('academic_years', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name', 50)->unique();
|
||||||
|
$table->unsignedSmallInteger('start_year');
|
||||||
|
$table->unsignedSmallInteger('end_year');
|
||||||
|
$table->boolean('is_active')->default(false);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('academic_years');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('departments', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('code', 20)->unique();
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('departments');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('classes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('academic_year_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->foreignId('department_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->string('level', 10);
|
||||||
|
$table->string('homeroom_teacher', 100)->nullable();
|
||||||
|
$table->unsignedInteger('capacity')->nullable();
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['academic_year_id', 'name']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('classes');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('document_types', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('code', 50)->unique();
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->boolean('is_required')->default(false);
|
||||||
|
$table->boolean('is_active')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('document_types');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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('students', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('student_number', 30)->nullable()->unique();
|
||||||
|
$table->string('nisn', 30)->nullable()->unique();
|
||||||
|
$table->string('full_name', 150);
|
||||||
|
$table->enum('gender', ['L', 'P']);
|
||||||
|
$table->string('place_of_birth', 100)->nullable();
|
||||||
|
$table->date('date_of_birth')->nullable();
|
||||||
|
$table->string('religion', 50)->nullable();
|
||||||
|
$table->string('nationality', 50)->default('Indonesia');
|
||||||
|
$table->string('family_card_number', 30)->nullable();
|
||||||
|
$table->unsignedTinyInteger('child_order')->nullable();
|
||||||
|
$table->unsignedTinyInteger('number_of_siblings')->nullable();
|
||||||
|
$table->string('phone_number', 30)->nullable();
|
||||||
|
$table->string('email', 100)->nullable();
|
||||||
|
$table->text('address')->nullable();
|
||||||
|
$table->string('village', 100)->nullable();
|
||||||
|
$table->string('district', 100)->nullable();
|
||||||
|
$table->string('city', 100)->nullable();
|
||||||
|
$table->string('province', 100)->nullable();
|
||||||
|
$table->string('postal_code', 10)->nullable();
|
||||||
|
$table->foreignId('academic_year_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->foreignId('department_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->foreignId('class_id')->constrained('classes')->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->date('entry_date')->nullable();
|
||||||
|
$table->enum('status', ['active', 'graduated', 'transferred', 'dropped', 'inactive'])->default('active');
|
||||||
|
$table->string('photo_path')->nullable();
|
||||||
|
$table->text('notes')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->index(['academic_year_id', 'department_id', 'class_id']);
|
||||||
|
$table->index('status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('students');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?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('student_parents', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->enum('relation_type', ['father', 'mother', 'guardian']);
|
||||||
|
$table->string('name', 150);
|
||||||
|
$table->string('nik', 30)->nullable();
|
||||||
|
$table->unsignedSmallInteger('birth_year')->nullable();
|
||||||
|
$table->string('education', 100)->nullable();
|
||||||
|
$table->string('occupation', 100)->nullable();
|
||||||
|
$table->string('phone_number', 30)->nullable();
|
||||||
|
$table->text('address')->nullable();
|
||||||
|
$table->boolean('is_alive')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['student_id', 'relation_type']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('student_parents');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?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('student_documents', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->foreignId('document_type_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->string('file_name');
|
||||||
|
$table->string('file_path');
|
||||||
|
$table->string('file_extension', 20)->nullable();
|
||||||
|
$table->string('mime_type', 100)->nullable();
|
||||||
|
$table->unsignedBigInteger('file_size')->nullable();
|
||||||
|
$table->string('document_number', 100)->nullable();
|
||||||
|
$table->date('issued_date')->nullable();
|
||||||
|
$table->date('expired_date')->nullable();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->enum('verification_status', ['pending', 'valid', 'invalid', 'revision'])->default('pending');
|
||||||
|
$table->foreignId('uploaded_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->foreignId('verified_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->timestamp('verified_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
|
||||||
|
$table->index(['student_id', 'document_type_id']);
|
||||||
|
$table->index('verification_status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('student_documents');
|
||||||
|
}
|
||||||
|
};
|
||||||
+28
@@ -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('document_types', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('max_file_size_kb')->nullable()->after('description');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('document_types', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('max_file_size_kb');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
+28
@@ -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('document_types', function (Blueprint $table) {
|
||||||
|
$table->string('allowed_extensions', 255)->nullable()->after('max_file_size_kb');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('document_types', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('allowed_extensions');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
+28
@@ -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('student_documents', function (Blueprint $table) {
|
||||||
|
$table->text('verification_note')->nullable()->after('verification_status');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('student_documents', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('verification_note');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?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('student_academic_histories', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->constrained()->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->foreignId('academic_year_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->foreignId('department_id')->constrained()->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->foreignId('class_id')->constrained('classes')->cascadeOnUpdate()->restrictOnDelete();
|
||||||
|
$table->string('status', 30)->default('active');
|
||||||
|
$table->date('start_date')->nullable();
|
||||||
|
$table->date('end_date')->nullable();
|
||||||
|
$table->text('notes')->nullable();
|
||||||
|
$table->boolean('is_current')->default(true);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(['student_id', 'is_current']);
|
||||||
|
$table->unique(['student_id', 'academic_year_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('student_academic_histories');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('role', 30)->default('staff')->after('email');
|
||||||
|
});
|
||||||
|
|
||||||
|
DB::table('users')->update(['role' => 'admin']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('role');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('student_exits', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->unique()->constrained('students')->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->string('student_number', 30)->nullable();
|
||||||
|
$table->string('nisn', 30)->nullable();
|
||||||
|
$table->string('full_name', 150);
|
||||||
|
$table->foreignId('academic_year_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreignId('department_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreignId('class_id')->nullable()->constrained('classes')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->date('entry_date')->nullable();
|
||||||
|
$table->date('exit_date')->nullable();
|
||||||
|
$table->text('exit_reason')->nullable();
|
||||||
|
$table->string('status', 30)->default('dropped');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->index('status');
|
||||||
|
$table->index('exit_date');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('student_exits');
|
||||||
|
}
|
||||||
|
};
|
||||||
+30
@@ -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
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('student_exits', function (Blueprint $table) {
|
||||||
|
$table->string('exit_letter_file_name')->nullable()->after('exit_reason');
|
||||||
|
$table->string('exit_letter_file_path')->nullable()->after('exit_letter_file_name');
|
||||||
|
$table->string('exit_letter_mime_type')->nullable()->after('exit_letter_file_path');
|
||||||
|
$table->unsignedBigInteger('exit_letter_file_size')->nullable()->after('exit_letter_mime_type');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('student_exits', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'exit_letter_file_name',
|
||||||
|
'exit_letter_file_path',
|
||||||
|
'exit_letter_mime_type',
|
||||||
|
'exit_letter_file_size',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('student_transfers', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('student_id')->unique()->constrained('students')->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->string('student_number', 30)->nullable();
|
||||||
|
$table->string('nisn', 30)->nullable();
|
||||||
|
$table->string('full_name', 150);
|
||||||
|
$table->foreignId('academic_year_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreignId('department_id')->nullable()->constrained()->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreignId('class_id')->nullable()->constrained('classes')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->date('entry_date')->nullable();
|
||||||
|
$table->date('transfer_date')->nullable();
|
||||||
|
$table->text('transfer_reason')->nullable();
|
||||||
|
$table->string('transfer_letter_file_name')->nullable();
|
||||||
|
$table->string('transfer_letter_file_path')->nullable();
|
||||||
|
$table->string('transfer_letter_mime_type')->nullable();
|
||||||
|
$table->unsignedBigInteger('transfer_letter_file_size')->nullable();
|
||||||
|
$table->string('status', 30)->default('transferred');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index('status');
|
||||||
|
$table->index('transfer_date');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('student_transfers');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('provinces', function (Blueprint $table) {
|
||||||
|
$table->string('id', 20)->primary();
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('regencies', function (Blueprint $table) {
|
||||||
|
$table->string('id', 20)->primary();
|
||||||
|
$table->string('province_id', 20);
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('province_id')->references('id')->on('provinces')->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->index('province_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('districts', function (Blueprint $table) {
|
||||||
|
$table->string('id', 20)->primary();
|
||||||
|
$table->string('regency_id', 20);
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('regency_id')->references('id')->on('regencies')->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->index('regency_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('villages', function (Blueprint $table) {
|
||||||
|
$table->string('id', 20)->primary();
|
||||||
|
$table->string('district_id', 20);
|
||||||
|
$table->string('name', 100);
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->foreign('district_id')->references('id')->on('districts')->cascadeOnUpdate()->cascadeOnDelete();
|
||||||
|
$table->index('district_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('students', function (Blueprint $table) {
|
||||||
|
$table->string('province_id', 20)->nullable()->after('address');
|
||||||
|
$table->string('regency_id', 20)->nullable()->after('province_id');
|
||||||
|
$table->string('district_id', 20)->nullable()->after('regency_id');
|
||||||
|
$table->string('village_id', 20)->nullable()->after('district_id');
|
||||||
|
|
||||||
|
$table->foreign('province_id')->references('id')->on('provinces')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreign('regency_id')->references('id')->on('regencies')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreign('district_id')->references('id')->on('districts')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
$table->foreign('village_id')->references('id')->on('villages')->nullOnDelete()->cascadeOnUpdate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('students', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['province_id']);
|
||||||
|
$table->dropForeign(['regency_id']);
|
||||||
|
$table->dropForeign(['district_id']);
|
||||||
|
$table->dropForeign(['village_id']);
|
||||||
|
$table->dropColumn(['province_id', 'regency_id', 'district_id', 'village_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::dropIfExists('villages');
|
||||||
|
Schema::dropIfExists('districts');
|
||||||
|
Schema::dropIfExists('regencies');
|
||||||
|
Schema::dropIfExists('provinces');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?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('students', function (Blueprint $table) {
|
||||||
|
$table->enum('self_service_status', ['not_started', 'draft', 'submitted'])
|
||||||
|
->default('not_started')
|
||||||
|
->after('status');
|
||||||
|
$table->timestamp('self_service_last_access_at')
|
||||||
|
->nullable()
|
||||||
|
->after('self_service_status');
|
||||||
|
$table->timestamp('self_service_submitted_at')
|
||||||
|
->nullable()
|
||||||
|
->after('self_service_last_access_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('students', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'self_service_status',
|
||||||
|
'self_service_last_access_at',
|
||||||
|
'self_service_submitted_at',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
+33
@@ -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
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('students', function (Blueprint $table) {
|
||||||
|
$table->string('self_service_access_code', 20)
|
||||||
|
->nullable()
|
||||||
|
->after('self_service_submitted_at');
|
||||||
|
$table->timestamp('self_service_code_generated_at')
|
||||||
|
->nullable()
|
||||||
|
->after('self_service_access_code');
|
||||||
|
|
||||||
|
$table->index('self_service_access_code');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('students', function (Blueprint $table) {
|
||||||
|
$table->dropIndex(['self_service_access_code']);
|
||||||
|
$table->dropColumn([
|
||||||
|
'self_service_access_code',
|
||||||
|
'self_service_code_generated_at',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('app_settings', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('key')->unique();
|
||||||
|
$table->text('value')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('app_settings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class AdminUserSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
User::updateOrCreate(
|
||||||
|
['email' => 'admin@kesiswaan.local'],
|
||||||
|
[
|
||||||
|
'name' => 'Administrator',
|
||||||
|
'password' => Hash::make('Admin123!'),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class DatabaseSeeder extends Seeder
|
||||||
|
{
|
||||||
|
use WithoutModelEvents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seed the application's database.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->call([
|
||||||
|
AdminUserSeeder::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user