first commit
This commit is contained in:
commit
5cb6e00261
|
@ -0,0 +1,18 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
|
@ -0,0 +1,52 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=smtp
|
||||||
|
MAIL_HOST=mailhog
|
||||||
|
MAIL_PORT=1025
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS=null
|
||||||
|
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
|
||||||
|
|
||||||
|
PUSHER_APP_ID=
|
||||||
|
PUSHER_APP_KEY=
|
||||||
|
PUSHER_APP_SECRET=
|
||||||
|
PUSHER_APP_CLUSTER=mt1
|
||||||
|
|
||||||
|
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||||
|
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
|
@ -0,0 +1,10 @@
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
|
@ -0,0 +1,15 @@
|
||||||
|
/node_modules
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/vendor
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.phpunit.result.cache
|
||||||
|
docker-compose.override.yml
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
/.idea
|
||||||
|
/.vscode
|
|
@ -0,0 +1,13 @@
|
||||||
|
php:
|
||||||
|
preset: laravel
|
||||||
|
version: 8
|
||||||
|
disabled:
|
||||||
|
- no_unused_imports
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- index.php
|
||||||
|
js:
|
||||||
|
finder:
|
||||||
|
not-name:
|
||||||
|
- webpack.mix.js
|
||||||
|
css: true
|
|
@ -0,0 +1,132 @@
|
||||||
|
# Sistem Pendukung Keputusan Penerima Bantuan Sosial Metode SAW
|
||||||
|
|
||||||
|
Ini merupakan aplikasi web sederhana untuk mencari warga yang berhak menerima bantuan menggunakan metode SAW, Web ini menggunakan Laravel 9 sebagai backend framework dan Bootsrap 5 sebagai frontend.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Menetukan warga yang paling berhak mendapat bantuan sosial menggunakan metode SAW yang memungkinkan perhitungan secara akurat.
|
||||||
|
- Mencetak hasil laporan dalam format file PDF.
|
||||||
|
- Menggunakan Laravel 9 sebagai backend.
|
||||||
|
- Menggunakan Bootsrap 5 sebagai frontend yang responsive dan modern.
|
||||||
|
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- PHP >= 8.1
|
||||||
|
- Composer
|
||||||
|
- MySQL
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. git clone https://github.com/capcay464/laravel9-SPK
|
||||||
|
2. cd laravel9-SPK
|
||||||
|
3. composer install
|
||||||
|
4. copy .env.example .env || cp .env.example .env
|
||||||
|
4. php artisan key:generate
|
||||||
|
5. php artisan migrate
|
||||||
|
7. php artisan db:seed
|
||||||
|
8. php artisan serve
|
||||||
|
9. Buka di http://127.0.0.1:8000/
|
||||||
|
|
||||||
|
## Access Login Page
|
||||||
|
1. Admin :
|
||||||
|
Username : admin@admin.com
|
||||||
|
Password : admin12345
|
||||||
|
|
||||||
|
|
||||||
|
## Login Page
|
||||||
|

|
||||||
|
|
||||||
|
## Dashboard Page
|
||||||
|

|
||||||
|
|
||||||
|
## Kriteria Page
|
||||||
|

|
||||||
|
|
||||||
|
## Crips Page
|
||||||
|

|
||||||
|
|
||||||
|
## Data Warga Page
|
||||||
|

|
||||||
|
|
||||||
|
## Penilaian Page
|
||||||
|

|
||||||
|
|
||||||
|
## Perhitungan SAW Page
|
||||||
|

|
||||||
|
|
||||||
|
## Users Page
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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"></a></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.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.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 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.
|
||||||
|
|
||||||
|
## Laravel Sponsors
|
||||||
|
|
||||||
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||||
|
|
||||||
|
### Premium Partners
|
||||||
|
|
||||||
|
- **[Vehikl](https://vehikl.com/)**
|
||||||
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||||
|
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||||
|
- **[Many](https://www.many.co.uk)**
|
||||||
|
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||||
|
- **[DevSquad](https://devsquad.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||||
|
- **[OP.GG](https://op.gg)**
|
||||||
|
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
|
||||||
|
- **[Lendio](https://lendio.com)**
|
||||||
|
|
||||||
|
## 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,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
// $schedule->command('inspire')->hourly();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__.'/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string<Throwable>>
|
||||||
|
*/
|
||||||
|
protected $dontReport = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed for validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the exception handling callbacks for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->reportable(function (Throwable $e) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render($request, Throwable $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
return parent::render($request, $e);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class SawCalculationException extends Exception
|
||||||
|
{
|
||||||
|
protected $message = 'Terjadi kesalahan dalam perhitungan SAW';
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports;
|
||||||
|
|
||||||
|
use App\Models\HasilPenilaian;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
|
|
||||||
|
class HasilPerhitunganPdf implements FromView
|
||||||
|
{
|
||||||
|
protected $results;
|
||||||
|
|
||||||
|
public function __construct($results)
|
||||||
|
{
|
||||||
|
$this->results = $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view(): View
|
||||||
|
{
|
||||||
|
return view('exports.hasil-penilaian-pdf', [
|
||||||
|
'results' => $this->results,
|
||||||
|
'tanggal' => now()->format('d F Y')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menandai menu sebagai aktif jika rute cocok.
|
||||||
|
*
|
||||||
|
* @param array|string $routes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function set_active($routes)
|
||||||
|
{
|
||||||
|
foreach ((array) $routes as $route) {
|
||||||
|
if (request()->routeIs($route)) {
|
||||||
|
return 'active';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Menandai menu dropdown sebagai terbuka jika rute cocok.
|
||||||
|
*
|
||||||
|
* @param array|string $routes
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function set_open($routes)
|
||||||
|
{
|
||||||
|
foreach ((array) $routes as $route) {
|
||||||
|
if (request()->routeIs($route)) {
|
||||||
|
return 'menu-open';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
|
@ -0,0 +1,527 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\PengajuanDetail;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Form;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Notifications\PengajuanValidNotification;
|
||||||
|
use App\Notifications\PengajuanDitolakNotification;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Models\RankingFile;
|
||||||
|
|
||||||
|
class AdminPengajuanController extends Controller
|
||||||
|
{
|
||||||
|
// Status mapping for consistent status values
|
||||||
|
const STATUS_MAPPING = [
|
||||||
|
'diterima' => 'valid',
|
||||||
|
'menunggu' => 'menunggu',
|
||||||
|
'ditolak' => 'tidak valid'
|
||||||
|
];
|
||||||
|
|
||||||
|
const REJECTION_REASONS_BY_CRITERIA = [
|
||||||
|
'Pekerjaan Orang Tua' => [
|
||||||
|
'Surat keterangan kerja tidak valid',
|
||||||
|
'Tidak ada bukti usaha (untuk wiraswasta)',
|
||||||
|
'Dokumen kadaluarsa',
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Penghasilan Orang Tua' => [
|
||||||
|
'Jumlah gaji tidak sesuai',
|
||||||
|
'Slip gaji tidak terbaca',
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Status Orang Tua' => [
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'Dokumen tidak terbaca',
|
||||||
|
'Tidak ada bukti surat perceraian',
|
||||||
|
'Tidak ada bukti surat keterangan kematian',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Tanggungan Orang Tua' => [
|
||||||
|
'Kartu Keluarga tidak terbaca',
|
||||||
|
'Jumlah tanggungan tidak sesuai',
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Hunian' => [
|
||||||
|
'Bukti kepemilikan tidak valid',
|
||||||
|
'Dokumen tidak terbaca',
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Kendaraan' => [
|
||||||
|
'Dokumen tidak sesuai',
|
||||||
|
'STNK tidak valid',
|
||||||
|
'STNK tidak terbaca',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'IPK' => [
|
||||||
|
'KHS tidak valid',
|
||||||
|
'KHS tidak terbaca',
|
||||||
|
'IPK tidak sesuai dengan sistem',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Semester' => [
|
||||||
|
'KHS tidak valid',
|
||||||
|
'KHS tidak terbaca',
|
||||||
|
'Semester tidak sesuai dengan sistem',
|
||||||
|
'Lainnya'
|
||||||
|
],
|
||||||
|
'Slip Pembayaran UKT' => [
|
||||||
|
'Dokumen tidak terbaca',
|
||||||
|
'Nominal tidak sesuai',
|
||||||
|
'Slip pembayaran tidak sesuai',
|
||||||
|
'Lainnya'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display list of UKT submissions with filtering
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$statusFilter = $this->mapStatusFilter(request('status'));
|
||||||
|
|
||||||
|
$query = PengajuanUkt::with(['mahasiswa.user:id,name','form'])
|
||||||
|
->withCount('details');
|
||||||
|
|
||||||
|
if (request()->has('status_form_id') && request('status_form_id') != '') {
|
||||||
|
$query->where('status_form_id', request('status_form_id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter by jenis form
|
||||||
|
if (request()->has('jenis_form') && request('jenis_form') != '') {
|
||||||
|
$query->whereHas('form', function($q) {
|
||||||
|
$q->where('jenis_form', request('jenis_form'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($statusFilter) {
|
||||||
|
$query->where('status_validasi', $statusFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pengajuan = $query->latest()->paginate(10);
|
||||||
|
|
||||||
|
$forms = Form::select('id', 'nama_form')
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$stats = [
|
||||||
|
'totalPengajuan' => PengajuanUkt::count(),
|
||||||
|
'valid' => PengajuanUkt::valid()->count(),
|
||||||
|
'menunggu' => PengajuanUkt::menunggu()->count(),
|
||||||
|
'tidak valid' => PengajuanUkt::tidakValid()->count()
|
||||||
|
];
|
||||||
|
|
||||||
|
return view('admin.pengajuan.index', compact('pengajuan', 'stats', 'forms'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map status filter to consistent values
|
||||||
|
*/
|
||||||
|
protected function mapStatusFilter($status)
|
||||||
|
{
|
||||||
|
return self::STATUS_MAPPING[$status] ?? $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detail($id)
|
||||||
|
{
|
||||||
|
$pengajuan = PengajuanUkt::with([
|
||||||
|
'details' => function($query) {
|
||||||
|
$query->select([
|
||||||
|
'id',
|
||||||
|
'pengajuan_ukt_id',
|
||||||
|
'kriteria',
|
||||||
|
'subkriteria_text',
|
||||||
|
'file_dokumen',
|
||||||
|
'verified',
|
||||||
|
'rejection_reason',
|
||||||
|
'verified_by',
|
||||||
|
'verified_at'
|
||||||
|
])->with(['verifier:id,name']);
|
||||||
|
},
|
||||||
|
'mahasiswa.user:id,name'
|
||||||
|
])->select([
|
||||||
|
'id',
|
||||||
|
'mahasiswa_id',
|
||||||
|
'jenis_pengajuan',
|
||||||
|
'alasan_pengajuan',
|
||||||
|
'ukt_saat_ini',
|
||||||
|
'status_validasi',
|
||||||
|
'created_at',
|
||||||
|
'updated_at'
|
||||||
|
])->findOrFail($id);
|
||||||
|
|
||||||
|
return view('admin.pengajuan.detail', [
|
||||||
|
'pengajuan' => $pengajuan,
|
||||||
|
'rejectionReasonsByCriteria' => self::REJECTION_REASONS_BY_CRITERIA
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bulkVerify(Request $request, $id)
|
||||||
|
{
|
||||||
|
if (auth()->user()->role !== 'karyawan') {
|
||||||
|
abort(403, 'Hanya karyawan yang dapat melakukan verifikasi');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $request->all();
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'valid' => 'required|array',
|
||||||
|
'valid.*' => 'in:0,1',
|
||||||
|
'alasan' => 'nullable|array',
|
||||||
|
'alasan_lainnya' => 'nullable|array',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($data['valid'] as $detailId => $value) {
|
||||||
|
if ((string) $value === '0') {
|
||||||
|
$rules["alasan.$detailId"] = 'required|string';
|
||||||
|
if (isset($data['alasan'][$detailId]) && $data['alasan'][$detailId] === 'Lainnya') {
|
||||||
|
$rules["alasan_lainnya.$detailId"] = 'required|string';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = Validator::make($data, $rules);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Validasi gagal',
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pengajuan = PengajuanUkt::with(['details', 'mahasiswa.user'])->findOrFail($id);
|
||||||
|
|
||||||
|
foreach ($pengajuan->details as $detail) {
|
||||||
|
$isValid = $request->input("valid.{$detail->id}") == '1';
|
||||||
|
$alasan = $request->input("alasan.{$detail->id}");
|
||||||
|
$alasanLainnya = $request->input("alasan_lainnya.{$detail->id}");
|
||||||
|
|
||||||
|
$rejectionReason = $this->processRejectionReason($alasan, $alasanLainnya);
|
||||||
|
|
||||||
|
$detail->update([
|
||||||
|
'verified' => $isValid,
|
||||||
|
'verified_by' => auth()->id(),
|
||||||
|
'verified_at' => now(),
|
||||||
|
'rejection_reason' => $isValid ? null : $rejectionReason,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = $this->updatePengajuanStatus($pengajuan);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Validasi dokumen berhasil disimpan! Status: ' . ($status === 'valid' ? 'Valid' : 'Tidak Valid'),
|
||||||
|
'redirect' => route('admin.pengajuan.detail', $id)
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal memvalidasi pengajuan: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revalidate(Request $request, $id)
|
||||||
|
{
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'valid' => 'required|array',
|
||||||
|
'valid.*' => 'in:0,1',
|
||||||
|
'alasan' => 'required_without:valid.*|array',
|
||||||
|
'alasan_lainnya' => 'required_if:alasan.*,Lainnya|array'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Validasi gagal',
|
||||||
|
'errors' => $validator->errors()
|
||||||
|
], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pengajuan = PengajuanUkt::with('details')->findOrFail($id);
|
||||||
|
$changesMade = false;
|
||||||
|
|
||||||
|
foreach ($request->input('valid') as $detailId => $isValid) {
|
||||||
|
$detail = $pengajuan->details->firstWhere('id', $detailId);
|
||||||
|
if (!$detail) continue;
|
||||||
|
|
||||||
|
$alasan = $request->input("alasan.{$detailId}");
|
||||||
|
$alasanLainnya = $request->input("alasan_lainnya.{$detailId}");
|
||||||
|
$rejectionReason = $isValid ? null : $this->processRejectionReason($alasan, $alasanLainnya);
|
||||||
|
|
||||||
|
// Check if changes are needed
|
||||||
|
if ($detail->verified != $isValid || $detail->rejection_reason != $rejectionReason) {
|
||||||
|
$detail->verified = $isValid;
|
||||||
|
$detail->rejection_reason = $rejectionReason;
|
||||||
|
$detail->verified_by = auth()->id();
|
||||||
|
$detail->verified_at = now();
|
||||||
|
$detail->save();
|
||||||
|
$changesMade = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($changesMade) {
|
||||||
|
$status = $this->updatePengajuanStatus($pengajuan);
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Revalidasi berhasil disimpan',
|
||||||
|
'redirect' => route('admin.pengajuan.detail', $id)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Tidak ada perubahan yang dilakukan',
|
||||||
|
'redirect' => route('admin.pengajuan.detail', $id)
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menyimpan revalidasi: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyUkt(Request $request, $id)
|
||||||
|
{
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'valid_ukt' => 'required|boolean',
|
||||||
|
'alasan_ukt' => 'required_if:valid_ukt,0|nullable|string',
|
||||||
|
'alasan_lainnya_ukt' => 'required_if:alasan_ukt,Lainnya|nullable|string'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return back()
|
||||||
|
->withErrors($validator)
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pengajuan = PengajuanUkt::with(['details', 'mahasiswa.user'])
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
$alasanUkt = $this->processRejectionReason(
|
||||||
|
$request->alasan_ukt,
|
||||||
|
$request->alasan_lainnya_ukt
|
||||||
|
);
|
||||||
|
|
||||||
|
$pengajuan->update([
|
||||||
|
'file_ukt_valid' => $request->valid_ukt,
|
||||||
|
'file_ukt_alasan' => $request->valid_ukt ? null : $alasanUkt,
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->updatePengajuanStatus($pengajuan);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('admin.pengajuan.detail', $id)
|
||||||
|
->with('success', 'Verifikasi Slip UKT berhasil disimpan');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return back()
|
||||||
|
->withInput()
|
||||||
|
->with('error', 'Gagal memverifikasi Slip UKT: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function processRejectionReason($alasan, $alasanLainnya)
|
||||||
|
{
|
||||||
|
if ($alasan === 'Lainnya') {
|
||||||
|
return 'Lainnya: ' . $alasanLainnya;
|
||||||
|
}
|
||||||
|
return $alasan;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updatePengajuanStatus($pengajuan)
|
||||||
|
{
|
||||||
|
$invalidCount = $pengajuan->details()
|
||||||
|
->where('verified', false)
|
||||||
|
->orWhereNotNull('rejection_reason')
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$status = $invalidCount === 0 ? 'valid' : 'tidak valid';
|
||||||
|
|
||||||
|
$pengajuan->update([
|
||||||
|
'status_validasi' => $status,
|
||||||
|
'updated_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->sendNotification($pengajuan, $status);
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sendNotification($pengajuan, $status)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($status === 'valid') {
|
||||||
|
$pengajuan->mahasiswa->user->notify(new PengajuanValidNotification($pengajuan));
|
||||||
|
} else {
|
||||||
|
$reasons = $pengajuan->details()
|
||||||
|
->whereNotNull('rejection_reason')
|
||||||
|
->pluck('rejection_reason', 'kriteria')
|
||||||
|
->map(function($reason, $kriteria) {
|
||||||
|
return "$kriteria: " . (strpos($reason, 'Lainnya:') === 0 ? substr($reason, 8) : $reason);
|
||||||
|
})
|
||||||
|
->implode("\n");
|
||||||
|
|
||||||
|
$pengajuan->mahasiswa->user->notify(
|
||||||
|
new PengajuanDitolakNotification($pengajuan, $reasons)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Silent fail for notifications
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$pengajuan = PengajuanUkt::with(['details', 'hasilPenilaian'])->findOrFail($id);
|
||||||
|
|
||||||
|
foreach ($pengajuan->details as $detail) {
|
||||||
|
if ($detail->file_dokumen) {
|
||||||
|
$filePath = 'public/' . ltrim($detail->file_dokumen, '/');
|
||||||
|
if (Storage::exists($filePath)) {
|
||||||
|
Storage::delete($filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pengajuan->hasilPenilaian()->delete();
|
||||||
|
$pengajuan->details()->delete();
|
||||||
|
$pengajuan->delete();
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()->route('admin.pengajuan')
|
||||||
|
->with('success', 'Pengajuan berhasil dihapus');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return back()->with('error', 'Gagal menghapus pengajuan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeRankingReport(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'ranking_file' => 'required|file|mimes:pdf|max:10240'
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$existingFile = RankingFile::first();
|
||||||
|
if ($existingFile) {
|
||||||
|
Storage::delete('public/' . $existingFile->path);
|
||||||
|
$existingFile->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $request->file('ranking_file');
|
||||||
|
$path = $file->store('public/ranking_files');
|
||||||
|
|
||||||
|
RankingFile::create([
|
||||||
|
'path' => str_replace('public/', '', $path),
|
||||||
|
'uploaded_by' => auth()->id()
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()->route('admin.pengajuan')
|
||||||
|
->with('report_status', [
|
||||||
|
'type' => 'success',
|
||||||
|
'message' => 'Laporan ranking berhasil dikirim ke mahasiswa!'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return back()->with('report_status', [
|
||||||
|
'type' => 'danger',
|
||||||
|
'message' => 'Gagal mengunggah laporan ranking: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteRankingReport()
|
||||||
|
{
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$rankingFile = RankingFile::first();
|
||||||
|
|
||||||
|
if ($rankingFile) {
|
||||||
|
Storage::delete('public/' . $rankingFile->path);
|
||||||
|
$rankingFile->delete();
|
||||||
|
|
||||||
|
$message = 'Laporan ranking berhasil dibatalkan!';
|
||||||
|
$type = 'warning';
|
||||||
|
} else {
|
||||||
|
$message = 'Tidak ada laporan ranking aktif';
|
||||||
|
$type = 'info';
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return redirect()->route('admin.pengajuan')
|
||||||
|
->with('report_status', [
|
||||||
|
'type' => $type,
|
||||||
|
'message' => $message
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
return back()->with('report_status', [
|
||||||
|
'type' => 'danger',
|
||||||
|
'message' => 'Gagal membatalkan laporan ranking: ' . $e->getMessage()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewRankingReport($id)
|
||||||
|
{
|
||||||
|
$rankingFile = RankingFile::findOrFail($id);
|
||||||
|
|
||||||
|
$filePath = storage_path('app/public/' . $rankingFile->path);
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
abort(404, 'File laporan tidak ditemukan');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->download(
|
||||||
|
$filePath,
|
||||||
|
'Laporan-UKT-'.$rankingFile->created_at->format('Y-m-d').'.pdf'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ConfirmsPasswords;
|
||||||
|
|
||||||
|
class ConfirmPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Confirm Password Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password confirmations and
|
||||||
|
| uses a simple trait to include the behavior. You're free to explore
|
||||||
|
| this trait and override any functions that require customization.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ConfirmsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users when the intended url fails.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||||
|
|
||||||
|
class ForgotPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset emails and
|
||||||
|
| includes a trait which assists in sending these notifications from
|
||||||
|
| your application to your users. Feel free to explore this trait.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use SendsPasswordResetEmails;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
public function showLoginForm()
|
||||||
|
{
|
||||||
|
// Jika sudah login, redirect ke dashboard sesuai role
|
||||||
|
if (Auth::check()) {
|
||||||
|
return $this->redirectByRole();
|
||||||
|
}
|
||||||
|
return view('auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
$credentials = $request->validate([
|
||||||
|
'email' => 'required|email',
|
||||||
|
'password' => 'required',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (Auth::attempt($credentials)) {
|
||||||
|
$request->session()->regenerate();
|
||||||
|
return $this->redirectByRole();
|
||||||
|
}
|
||||||
|
|
||||||
|
return back()->withErrors([
|
||||||
|
'email' => 'Email atau password salah',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redirectByRole()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
// Tolong perhatika setiaprole yang ada apakah sungguh ada di database
|
||||||
|
// dan apakah sudah sesuai dengan route yang ada
|
||||||
|
// Jika ada role yang tidak sesuai, logout user
|
||||||
|
// dan redirect ke halaman login dengan pesan error
|
||||||
|
switch ($user->role) {
|
||||||
|
case 'admin':
|
||||||
|
return redirect()->route('home');
|
||||||
|
case 'karyawan':
|
||||||
|
return redirect()->route('dashboard.karyawan');
|
||||||
|
case 'mahasiswa':
|
||||||
|
return redirect()->route('dashboard.mahasiswa');
|
||||||
|
default:
|
||||||
|
Auth::logout();
|
||||||
|
return redirect('/login')->with('error', 'Role tidak valid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function logout(Request $request)
|
||||||
|
{
|
||||||
|
Auth::logout();
|
||||||
|
$request->session()->invalidate();
|
||||||
|
$request->session()->regenerateToken();
|
||||||
|
return redirect('/login');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller handles the registration of new users as well as their
|
||||||
|
| validation and creation. By default this controller uses a trait to
|
||||||
|
| provide this functionality without requiring any additional code.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use RegistersUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after registration.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = '/user';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
'alamat' => 'required|string',
|
||||||
|
'telepon' => 'required|string',
|
||||||
|
'keterangan' => 'required|string',
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @return \App\Models\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
return User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'password' => Hash::make($data['password']),
|
||||||
|
'alamat' => $data['alamat'],
|
||||||
|
'telepon' => $data['telepon'],
|
||||||
|
'keterangan' => $data['keterangan'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request){
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user->name = $request->name;
|
||||||
|
$user->email = $request->email;
|
||||||
|
$user->password = Hash::make($request->password);
|
||||||
|
$user->alamat = $request->alamat;
|
||||||
|
$user->telepon = $request->telepon;
|
||||||
|
$user->keterangan = $request->keterangan;
|
||||||
|
$user->save();
|
||||||
|
return back()->with('msg','Berhasil Menambahkan Data');
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\Log::emergency("File:" . $e->getFile(). "Line:" . $e->getLine(). "Message:" . $e->getMessage());
|
||||||
|
die("Gagal");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id){
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$user->delete();
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\Log::emergency("File:" . $e->getFile(). "Line:" . $e->getLine(). "Message:" . $e->getMessage());
|
||||||
|
die("Gagal");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadPDF() {
|
||||||
|
setlocale(LC_ALL, 'IND');
|
||||||
|
$tanggal = Carbon::now()->formatLocalized('%A, %d %B %Y');
|
||||||
|
$user = User::get();
|
||||||
|
|
||||||
|
$pdf = PDF::loadView('admin.user.user-pdf',compact('user','tanggal'));
|
||||||
|
$pdf->setPaper('A3', 'potrait');
|
||||||
|
return $pdf->stream('user.pdf');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Reset Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling password reset requests
|
||||||
|
| and uses a simple trait to include this behavior. You're free to
|
||||||
|
| explore this trait and override any methods you wish to tweak.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after resetting their password.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||||
|
|
||||||
|
class VerificationController extends Controller
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Email Verification Controller
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This controller is responsible for handling email verification for any
|
||||||
|
| user that recently registered with the application. Emails may also
|
||||||
|
| be re-sent if the user didn't receive the original email message.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
use VerifiesEmails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after verification.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $redirectTo = RouteServiceProvider::HOME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('signed')->only('verify');
|
||||||
|
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||||
|
}
|
|
@ -0,0 +1,200 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Models\Form;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class FormController extends Controller
|
||||||
|
{
|
||||||
|
public function pendaftaran()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (auth()->user()->role == 'karyawan' || auth()->user()->role == 'admin') {
|
||||||
|
$forms = Form::latest()->paginate(10);
|
||||||
|
} else {
|
||||||
|
$forms = Form::where('status', 'Dibuka')->latest()->paginate(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('form', compact('forms'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('form.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'nama_form' => 'required|string|max:255',
|
||||||
|
'jenis_form' => 'required|in:penurunan,pengangsuran',
|
||||||
|
'semester' => 'required|in:Ganjil,Genap',
|
||||||
|
'tahun' => 'required|digits:4|integer|min:2018|max:' . (date('Y') + 1),
|
||||||
|
'tanggal_pembukaan' => 'required|date',
|
||||||
|
'tanggal_penutupan' => 'required|date|after:tanggal_pembukaan',
|
||||||
|
'tanggal_verifikasi' => 'required|date|after:tanggal_penutupan',
|
||||||
|
'tanggal_pengumuman' => 'required|date|after:tanggal_verifikasi'
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'nama_form' => $request->nama_form,
|
||||||
|
'jenis_form' => $request->jenis_form,
|
||||||
|
'semester' => $request->semester,
|
||||||
|
'tahun' => $request->tahun,
|
||||||
|
'tanggal_pembuatan' => now(),
|
||||||
|
'status' => $request->has('status') ? 'Dibuka' : 'Ditutup',
|
||||||
|
'tanggal_pembukaan' => $request->tanggal_pembukaan,
|
||||||
|
'tanggal_penutupan' => $request->tanggal_penutupan,
|
||||||
|
'tanggal_verifikasi' => $request->tanggal_verifikasi,
|
||||||
|
'tanggal_pengumuman' => $request->tanggal_pengumuman
|
||||||
|
];
|
||||||
|
|
||||||
|
// Jika admin, tambahkan validasi kuota
|
||||||
|
if (auth()->user()->role == 'admin') {
|
||||||
|
$rules['kuota'] = 'required|integer|min:0';
|
||||||
|
$data['kuota'] = $request->kuota;
|
||||||
|
|
||||||
|
// Set the specific kuota based on jenis_form
|
||||||
|
if ($request->jenis_form === 'pengangsuran') {
|
||||||
|
$data['kuota_pengangsuran'] = $request->kuota;
|
||||||
|
$data['kuota_penurunan'] = 0;
|
||||||
|
} else {
|
||||||
|
$data['kuota_penurunan'] = $request->kuota;
|
||||||
|
$data['kuota_pengangsuran'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate($rules);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Form::create($data);
|
||||||
|
|
||||||
|
return redirect()->route('form.pendaftaran')
|
||||||
|
->with('success', 'Form berhasil dibuat!');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect()->back()
|
||||||
|
->withInput()
|
||||||
|
->with('error', 'Gagal menyimpan form: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$form = Form::findOrFail($id);
|
||||||
|
return view('form.edit', compact('form'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$form = Form::findOrFail($id);
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'nama_form' => 'required|string|max:255',
|
||||||
|
'jenis_form' => 'required|in:penurunan,pengangsuran',
|
||||||
|
'semester' => 'required|in:Ganjil,Genap',
|
||||||
|
'tahun' => 'required|digits:4|integer|min:2018|max:' . (date('Y') + 1),
|
||||||
|
'tanggal_pembukaan' => 'required|date',
|
||||||
|
'tanggal_penutupan' => 'required|date|after:tanggal_pembukaan',
|
||||||
|
'tanggal_verifikasi' => 'required|date|after:tanggal_penutupan',
|
||||||
|
'tanggal_pengumuman' => 'required|date|after:tanggal_verifikasi'
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'nama_form' => $request->nama_form,
|
||||||
|
'jenis_form' => $request->jenis_form,
|
||||||
|
'semester' => $request->semester,
|
||||||
|
'tahun' => $request->tahun,
|
||||||
|
'tanggal_pembukaan' => $request->tanggal_pembukaan,
|
||||||
|
'tanggal_penutupan' => $request->tanggal_penutupan,
|
||||||
|
'tanggal_verifikasi' => $request->tanggal_verifikasi,
|
||||||
|
'tanggal_pengumuman' => $request->tanggal_pengumuman,
|
||||||
|
'status' => $request->has('status') ? 'Dibuka' : 'Ditutup' // Handle checkbox
|
||||||
|
];
|
||||||
|
|
||||||
|
if (auth()->user()->role == 'admin') {
|
||||||
|
$rules['kuota'] = 'required|integer|min:0';
|
||||||
|
$data['kuota'] = $request->kuota;
|
||||||
|
|
||||||
|
// Set the specific kuota based on jenis_form
|
||||||
|
if ($request->jenis_form === 'pengangsuran') {
|
||||||
|
$data['kuota_pengangsuran'] = $request->kuota;
|
||||||
|
$data['kuota_penurunan'] = 0;
|
||||||
|
} else {
|
||||||
|
$data['kuota_penurunan'] = $request->kuota;
|
||||||
|
$data['kuota_pengangsuran'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$request->validate($rules);
|
||||||
|
|
||||||
|
$form->update($data);
|
||||||
|
|
||||||
|
return redirect()->route('form.pendaftaran')
|
||||||
|
->with('success', 'Formulir berhasil diperbarui.');
|
||||||
|
} catch (\Illuminate\Validation\ValidationException $e) {
|
||||||
|
return redirect()->back()
|
||||||
|
->withErrors($e->errors())
|
||||||
|
->withInput();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->withInput()
|
||||||
|
->with('error', 'Gagal memperbarui formulir: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function toggleStatus($id)
|
||||||
|
{
|
||||||
|
$form = Form::findOrFail($id);
|
||||||
|
$form->status = ($form->status == 'Dibuka') ? 'Ditutup' : 'Dibuka';
|
||||||
|
$form->save();
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', 'Status form berhasil diubah.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$form = Form::findOrFail($id);
|
||||||
|
$form->delete();
|
||||||
|
return redirect()->route('form.pendaftaran')->with('success', 'Form berhasil dihapus.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showReductionForm()
|
||||||
|
{
|
||||||
|
return view('form.penurunan');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showInstallmentForm()
|
||||||
|
{
|
||||||
|
return view('form.pengangsuran');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateQuota(Request $request, Form $form)
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'kuota_pengangsuran' => 'nullable|integer|min:0|max:1000',
|
||||||
|
'kuota_penurunan' => 'nullable|integer|min:0|max:1000'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Only update the fields that were provided
|
||||||
|
if ($request->has('kuota_pengangsuran')) {
|
||||||
|
$form->kuota_pengangsuran = $request->kuota_pengangsuran;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('kuota_penurunan')) {
|
||||||
|
$form->kuota_penurunan = $request->kuota_penurunan;
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->save();
|
||||||
|
|
||||||
|
return back()->with('success', 'Kuota berhasil diperbarui');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->with('error', 'Gagal memperbarui kuota: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\SubKriteria;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
|
||||||
|
class HomeController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showAdminDashboard()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$data = [
|
||||||
|
'totalMahasiswa' => User::where('role', 'mahasiswa')->count(),
|
||||||
|
'totalKriteria' => Kriteria::count(),
|
||||||
|
'totalSubkriteria' => SubKriteria::count(),
|
||||||
|
'totalPengajuan' => PengajuanUkt::count(),
|
||||||
|
'penurunanUKT' => PengajuanUkt::where('jenis_pengajuan', 'penurunan')->count(),
|
||||||
|
'pengangsuranUKT' => PengajuanUkt::where('jenis_pengajuan', 'pengangsuran')->count(),
|
||||||
|
];
|
||||||
|
|
||||||
|
// @dd($data);
|
||||||
|
|
||||||
|
return view('admin.home', $data);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Log the error for debugging
|
||||||
|
\Log::error('Dashboard Error: '.$e->getMessage());
|
||||||
|
|
||||||
|
return redirect()->back()->with('error', "Gagal memuat dashboard. Silakan coba lagi.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,169 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Crips;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Validator;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class KriteriaController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->middleware('admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$kriteria = Kriteria::orderBy('id','ASC')->paginate(10);
|
||||||
|
$totalBobot = round(Kriteria::sum('bobot'), 2);
|
||||||
|
|
||||||
|
return view('admin.kriteria.index', compact('kriteria' , 'totalBobot'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Validasi input
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'nama_kriteria' => 'required|string|unique:kriteria,nama_kriteria|max:255',
|
||||||
|
'attribut' => 'required|in:cost,benefit',
|
||||||
|
'bobot' => 'required|numeric|min:0|max:1'
|
||||||
|
], [
|
||||||
|
'nama_kriteria.required' => 'Nama kriteria wajib diisi',
|
||||||
|
'nama_kriteria.unique' => 'Nama kriteria sudah digunakan',
|
||||||
|
'nama_kriteria.max' => 'Nama kriteria maksimal 255 karakter',
|
||||||
|
'attribut.required' => 'Attribut wajib dipilih',
|
||||||
|
'attribut.in' => 'Attribut harus benefit atau cost',
|
||||||
|
'bobot.required' => 'Bobot wajib diisi',
|
||||||
|
'bobot.numeric' => 'Bobot harus berupa angka',
|
||||||
|
'bobot.min' => 'Bobot minimal 0',
|
||||||
|
'bobot.max' => 'Bobot maksimal 1'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Jika validasi gagal
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return redirect()->back()->withErrors($validator)->withInput()
|
||||||
|
->with('error', 'Terdapat kesalahan dalam pengisian form. Data tidak disimpan.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total bobot yang sudah ada
|
||||||
|
$currentTotal = Kriteria::sum('bobot');
|
||||||
|
$newTotal = round($currentTotal + $request->bobot, 4);
|
||||||
|
|
||||||
|
// Format untuk tampilan angka
|
||||||
|
$formattedNewTotal = number_format($newTotal, 2);
|
||||||
|
|
||||||
|
// Periksa konfirmasi dari user
|
||||||
|
$isConfirmed = $request->confirmed == '1';
|
||||||
|
|
||||||
|
// Jika total bobot tidak sama dengan 1 dan belum ada konfirmasi
|
||||||
|
if (($newTotal > 1 || $newTotal < 1) && !$isConfirmed) {
|
||||||
|
return redirect()->back()
|
||||||
|
->withInput()
|
||||||
|
->with('warning', 'Total bobot akan menjadi ' . $formattedNewTotal . ' (tidak sama dengan 1). Konfirmasi terlebih dahulu.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simpan data kriteria ke database
|
||||||
|
Kriteria::create([
|
||||||
|
'nama_kriteria' => $request->nama_kriteria,
|
||||||
|
'attribut' => $request->attribut,
|
||||||
|
'bobot' => $request->bobot
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('kriteria.index')->with('success', 'Kriteria berhasil ditambahkan.');
|
||||||
|
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
// Tangani error tak terduga
|
||||||
|
return redirect()->back()->withInput()->with('error', 'Terjadi kesalahan saat menyimpan data: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$kriteria = Kriteria::findOrFail($id);
|
||||||
|
return view('admin.kriteria.edit', compact('kriteria'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$kriteria = Kriteria::findOrFail($id);
|
||||||
|
$currentBobot = $kriteria->bobot;
|
||||||
|
|
||||||
|
// Validasi input
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'nama_kriteria' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('kriteria')->ignore($kriteria->id)
|
||||||
|
],
|
||||||
|
'attribut' => 'required|in:cost,benefit',
|
||||||
|
'bobot' => 'required|numeric|min:0|max:1'
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return back()->withErrors($validator)->withInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hitung total bobot setelah update
|
||||||
|
$totalBobot = round(Kriteria::sum('bobot') - $currentBobot + $request->bobot, 4);
|
||||||
|
$formattedTotal = number_format($totalBobot, 2);
|
||||||
|
|
||||||
|
// Jika melebihi 1, warning tapi tetap update
|
||||||
|
$kriteria->update([
|
||||||
|
'nama_kriteria' => $request->nama_kriteria,
|
||||||
|
'attribut' => $request->attribut,
|
||||||
|
'bobot' => $request->bobot
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($totalBobot == 1) {
|
||||||
|
return redirect()->route('kriteria.index')
|
||||||
|
->with('success', 'Kriteria berhasil diperbarui. Total bobot sekarang adalah 1.');
|
||||||
|
} elseif ($totalBobot > 1) {
|
||||||
|
return redirect()->route('kriteria.index')
|
||||||
|
->with('warning', 'Kriteria berhasil diperbarui. Total bobot sekarang adalah ' . $formattedTotal . ' (melebihi 1).');
|
||||||
|
} else {
|
||||||
|
return redirect()->route('kriteria.index')
|
||||||
|
->with('warning', 'Kriteria berhasil diperbarui. Total bobot sekarang adalah ' . $formattedTotal . ' (kurang dari 1).');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$kriteria = Kriteria::findOrFail($id);
|
||||||
|
$kriteria->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Kriteria berhasil dihapus'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menghapus kriteria: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadPDF()
|
||||||
|
{
|
||||||
|
setlocale(LC_ALL, 'IND');
|
||||||
|
$tanggal = Carbon::now()->formatLocalized('%A, %d %B %Y');
|
||||||
|
$kriteria = Kriteria::all();
|
||||||
|
|
||||||
|
$pdf = PDF::loadView('admin.kriteria.kriteria-pdf', compact('kriteria', 'tanggal'));
|
||||||
|
$pdf->setPaper('A3', 'portrait');
|
||||||
|
return $pdf->stream('kriteria.pdf');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\Form;
|
||||||
|
use App\Models\RankingFile;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class MahasiswaController extends Controller
|
||||||
|
{
|
||||||
|
public function dashboard()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$user = Auth::user();
|
||||||
|
$today = now();
|
||||||
|
|
||||||
|
// Get latest forms
|
||||||
|
$formPenurunan = Form::where('jenis_form', 'penurunan')
|
||||||
|
->orderByDesc('tahun')
|
||||||
|
->orderByDesc('semester')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$formPengangsuran = Form::where('jenis_form', 'pengangsuran')
|
||||||
|
->orderByDesc('tahun')
|
||||||
|
->orderByDesc('semester')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// Get all pengajuan for this user
|
||||||
|
$pengajuan = PengajuanUkt::with(['form', 'details' => function($query) {
|
||||||
|
$query->whereNotNull('rejection_reason');
|
||||||
|
}])
|
||||||
|
->where('mahasiswa_id', $user->id)
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Get latest ranking file
|
||||||
|
$rankingFile = RankingFile::whereNotNull('path')->latest()->first();
|
||||||
|
|
||||||
|
// Penurunan setup
|
||||||
|
$penurunanSubmission = null;
|
||||||
|
$submissionStatusPenurunan = null;
|
||||||
|
$canSubmitPenurunan = true;
|
||||||
|
$showAnnouncementPenurunan = false;
|
||||||
|
$tanggal_pengumuman_penurunan = null;
|
||||||
|
|
||||||
|
if ($formPenurunan) {
|
||||||
|
$tanggal_pengumuman_penurunan = $formPenurunan->tanggal_pengumuman;
|
||||||
|
$showAnnouncementPenurunan = $tanggal_pengumuman_penurunan && $today >= $tanggal_pengumuman_penurunan;
|
||||||
|
|
||||||
|
$penurunanSubmission = $pengajuan->first(function($item) use ($formPenurunan) {
|
||||||
|
return $item->form &&
|
||||||
|
$item->form->jenis_form === 'penurunan' &&
|
||||||
|
$item->form->semester === $formPenurunan->semester &&
|
||||||
|
$item->form->tahun === $formPenurunan->tahun;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($penurunanSubmission) {
|
||||||
|
$submissionStatusPenurunan = $penurunanSubmission->status_validasi;
|
||||||
|
$canSubmitPenurunan = $submissionStatusPenurunan === 'tidak valid';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pengangsuran setup
|
||||||
|
$pengangsuranSubmission = null;
|
||||||
|
$submissionStatusPengangsuran = null;
|
||||||
|
$canSubmitPengangsuran = true;
|
||||||
|
$showAnnouncementPengangsuran = false;
|
||||||
|
$tanggal_pengumuman_pengangsuran = null;
|
||||||
|
|
||||||
|
if ($formPengangsuran) {
|
||||||
|
$tanggal_pengumuman_pengangsuran = $formPengangsuran->tanggal_pengumuman;
|
||||||
|
$showAnnouncementPengangsuran = $tanggal_pengumuman_pengangsuran && $today >= $tanggal_pengumuman_pengangsuran;
|
||||||
|
|
||||||
|
$pengangsuranSubmission = $pengajuan->first(function($item) use ($formPengangsuran) {
|
||||||
|
return $item->form &&
|
||||||
|
$item->form->jenis_form === 'pengangsuran' &&
|
||||||
|
$item->form->semester === $formPengangsuran->semester &&
|
||||||
|
$item->form->tahun === $formPengangsuran->tahun;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($pengangsuranSubmission) {
|
||||||
|
$submissionStatusPengangsuran = $pengangsuranSubmission->status_validasi;
|
||||||
|
$canSubmitPengangsuran = $submissionStatusPengangsuran === 'tidak valid';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('mahasiswa.dashboard', [
|
||||||
|
'user' => $user,
|
||||||
|
'today' => $today,
|
||||||
|
'pengajuan' => $pengajuan,
|
||||||
|
'formPenurunan' => $formPenurunan,
|
||||||
|
'formPengangsuran' => $formPengangsuran,
|
||||||
|
'rankingFile' => $rankingFile,
|
||||||
|
|
||||||
|
'submissionStatusPenurunan' => $submissionStatusPenurunan,
|
||||||
|
'canSubmitPenurunan' => $canSubmitPenurunan,
|
||||||
|
'showAnnouncementPenurunan' => $showAnnouncementPenurunan,
|
||||||
|
|
||||||
|
'submissionStatusPengangsuran' => $submissionStatusPengangsuran,
|
||||||
|
'canSubmitPengangsuran' => $canSubmitPengangsuran,
|
||||||
|
'showAnnouncementPengangsuran' => $showAnnouncementPengangsuran,
|
||||||
|
|
||||||
|
'tanggal_pengumuman' => max(
|
||||||
|
$tanggal_pengumuman_penurunan ?? now()->subCentury(),
|
||||||
|
$tanggal_pengumuman_pengangsuran ?? now()->subCentury()
|
||||||
|
),
|
||||||
|
'showAnnouncement' => ($showAnnouncementPenurunan || $showAnnouncementPengangsuran),
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Dashboard error: ".$e->getMessage());
|
||||||
|
return response()->view('errors.simple', [
|
||||||
|
'message' => 'Terjadi kesalahan saat memuat dashboard'
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadRanking($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$rankingFile = RankingFile::findOrFail($id);
|
||||||
|
$filePath = storage_path('app/public/' . $rankingFile->path);
|
||||||
|
|
||||||
|
if (!file_exists($filePath)) {
|
||||||
|
throw new \Exception("File laporan tidak ditemukan");
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = 'Laporan-UKT-' . $rankingFile->created_at->format('Y-m-d') . '.pdf';
|
||||||
|
|
||||||
|
return response()->download($filePath, $filename, [
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'attachment; filename="' . $filename . '"'
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error("Download error - User: " . Auth::id() . " - Error: " . $e->getMessage());
|
||||||
|
return redirect()->route('mahasiswa.dashboard')
|
||||||
|
->with('error', 'Gagal mengunduh laporan: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,358 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\SubKriteria;
|
||||||
|
use App\Models\PengajuanDetail;
|
||||||
|
use App\Models\Penilaian;
|
||||||
|
use App\Models\Form;
|
||||||
|
use App\Models\Mahasiswa;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use App\Notifications\PengajuanDitolakNotification;
|
||||||
|
use App\Notifications\PengajuanDiterimaNotification;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class PengajuanController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
// Get active forms
|
||||||
|
$formPenurunan = Form::where('jenis_form', 'penurunan')
|
||||||
|
->where('status', 'Dibuka')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$formPengangsuran = Form::where('jenis_form', 'pengangsuran')
|
||||||
|
->where('status', 'Dibuka')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$pengajuan = PengajuanUkt::with(['hasilPenilaian', 'dokumen', 'mahasiswa'])
|
||||||
|
->where('mahasiswa_id', Auth::id())
|
||||||
|
->latest()
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
|
$stats = $this->getPengajuanStats(Auth::id());
|
||||||
|
|
||||||
|
return view('mahasiswa.dashboard', compact(
|
||||||
|
'formPenurunan',
|
||||||
|
'formPengangsuran',
|
||||||
|
'pengajuan',
|
||||||
|
'stats'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create($jenis)
|
||||||
|
{
|
||||||
|
if (!in_array($jenis, ['penurunan', 'pengangsuran'])) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$formSetting = Form::where('jenis_form', $jenis)
|
||||||
|
->where('status', 'Dibuka')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$formSetting) {
|
||||||
|
return redirect()->route('pengajuan.index')
|
||||||
|
->with('error', 'Form pengajuan '.$jenis.' UKT saat ini tidak tersedia');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cek apakah mahasiswa sudah melakukan pengajuan jenis apapun (penurunan/pengangsuran) di semester ini
|
||||||
|
$existingSubmission = PengajuanUkt::where('mahasiswa_id', Auth::id())
|
||||||
|
->whereHas('form', function($query) use ($formSetting) {
|
||||||
|
$query->where('semester', $formSetting->semester)
|
||||||
|
->where('tahun', $formSetting->tahun);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// Hanya izinkan buat ulang jika status sebelumnya 'tidak valid'
|
||||||
|
if ($existingSubmission && $existingSubmission->status_validasi !== 'tidak valid') {
|
||||||
|
$message = match($existingSubmission->status_validasi) {
|
||||||
|
'menunggu' => 'Anda sudah mengajukan '.$existingSubmission->jenis_pengajuan.' UKT untuk semester '.$formSetting->semester.' '.$formSetting->tahun.' dan masih dalam proses verifikasi',
|
||||||
|
'valid' => 'Pengajuan '.$existingSubmission->jenis_pengajuan.' UKT Anda untuk semester '.$formSetting->semester.' '.$formSetting->tahun.' sudah divalidasi',
|
||||||
|
default => 'Anda tidak dapat mengajukan form ini'
|
||||||
|
};
|
||||||
|
|
||||||
|
return redirect()->route('pengajuan.index')->with('error', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$kriteria = Kriteria::with('subKriteria')->get();
|
||||||
|
$mahasiswa = Auth::user()->mahasiswa;
|
||||||
|
|
||||||
|
return view('form.'.$jenis, compact('jenis', 'kriteria', 'mahasiswa', 'formSetting'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request, $jenis)
|
||||||
|
{
|
||||||
|
if (!in_array($jenis, ['penurunan', 'pengangsuran'])) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Auth::user();
|
||||||
|
if (!$user->mahasiswa) {
|
||||||
|
return back()->with('error', 'Anda tidak terdaftar sebagai mahasiswa.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$mahasiswa = $user->mahasiswa;
|
||||||
|
|
||||||
|
$form = Form::where('jenis_form', $jenis)
|
||||||
|
->where('status', 'Dibuka')
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$existingSubmission = PengajuanUkt::where('mahasiswa_id', $mahasiswa->user_id)
|
||||||
|
->whereHas('form', function($query) use ($form) {
|
||||||
|
$query->where('semester', $form->semester)
|
||||||
|
->where('tahun', $form->tahun);
|
||||||
|
})
|
||||||
|
->whereIn('status_validasi', ['menunggu', 'valid'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existingSubmission && $existingSubmission->status_validasi !== 'tidak valid') {
|
||||||
|
return back()->with('error', 'Anda sudah pernah mengajukan '.$existingSubmission->jenis_pengajuan.' UKT untuk semester '.$form->semester.' '.$form->tahun.'. Anda hanya bisa mengajukan satu form per semester.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'ukt_saat_ini' => 'required|numeric|min:500000',
|
||||||
|
'alasan_pengajuan' => 'required|string|min:20|max:500',
|
||||||
|
'penghasilan' => 'required|in:< 2 juta,2 - 3 juta,3 - 4 juta,> 5 juta',
|
||||||
|
'file_penghasilan' => 'required|mimes:pdf|max:1536',
|
||||||
|
'pekerjaan' => 'required|in:Bekerja Tetap,Bekerja Tidak Tetap,Tidak Bekerja',
|
||||||
|
'file_pekerjaan' => 'required|mimes:pdf|max:1536',
|
||||||
|
'tanggungan' => 'required|in:1 Orang,2 - 4 Orang,> 4 Orang',
|
||||||
|
'file_tanggungan' => 'required|mimes:pdf|max:1536',
|
||||||
|
'status_ortu' => 'required|in:Lengkap,Cerai/Yatim/Piatu,Yatim Piatu',
|
||||||
|
'file_status_ortu' => 'required|mimes:pdf|max:1536',
|
||||||
|
'hunian' => 'required|in:Milik Sendiri,Sewa/Kontrak,Menumpang',
|
||||||
|
'file_hunian' => 'required|mimes:pdf|max:1536',
|
||||||
|
'kendaraan' => 'required|in:Tidak Punya,Motor,Mobil,Motor dan Mobil',
|
||||||
|
'file_kendaraan' => ($request->kendaraan !== 'Tidak Punya' ? 'required|' : '') . 'mimes:pdf|max:1536',
|
||||||
|
'semester' => 'required|in:1,2,3,4,5,>6',
|
||||||
|
'ipk' => 'required|in:< 2.75,2.75 - 3.00,3.00 - 3.50,> 3.50',
|
||||||
|
'file_khs' => 'required|file|mimes:pdf|max:1536',
|
||||||
|
'file_ukt' => 'required|mimes:pdf|max:1536',
|
||||||
|
'file_pendukung' => 'nullable|mimes:pdf|max:1536'
|
||||||
|
], [
|
||||||
|
'ukt_saat_ini.required' => 'Nominal UKT saat ini wajib diisi',
|
||||||
|
'file_ukt' => 'required|mimes:pdf|max:1536',
|
||||||
|
'required' => 'Field :attribute wajib diisi',
|
||||||
|
'file_khs.required' => 'File bukti khs wajib diupload',
|
||||||
|
'in' => 'Pilihan :attribute tidak valid',
|
||||||
|
'mimes' => 'File harus berupa PDF',
|
||||||
|
'max' => 'Ukuran file maksimal 1.5MB',
|
||||||
|
'alasan_pengajuan.required' => 'Harap jelaskan alasan pengajuan Anda',
|
||||||
|
]);
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
try {
|
||||||
|
$cleanUktValue = (int) str_replace('.', '', $request->ukt_saat_ini);
|
||||||
|
|
||||||
|
// Store UKT file
|
||||||
|
$fileUktPath = $request->file('file_ukt')->store('pengajuan/dokumen', 'public');
|
||||||
|
|
||||||
|
// Store KHS file (will be used for both IPK and Semester)
|
||||||
|
$fileKhsPath = $request->file('file_khs')->store('pengajuan/dokumen', 'public');
|
||||||
|
|
||||||
|
|
||||||
|
$pengajuan = PengajuanUkt::create([
|
||||||
|
'mahasiswa_id' => $mahasiswa->user_id,
|
||||||
|
'jenis_pengajuan' => $jenis,
|
||||||
|
'status_validasi' => 'menunggu',
|
||||||
|
'status_form_id' => $form->id,
|
||||||
|
'alasan_penolakan' => '',
|
||||||
|
'ukt_saat_ini' => $cleanUktValue,
|
||||||
|
'alasan_pengajuan' => $request->input('alasan_pengajuan', ''),
|
||||||
|
'file_ukt' => $fileUktPath
|
||||||
|
]);
|
||||||
|
|
||||||
|
PengajuanDetail::create([
|
||||||
|
'pengajuan_ukt_id' => $pengajuan->id,
|
||||||
|
'kriteria' => 'Slip Pembayaran UKT',
|
||||||
|
'kriteria_id' => null,
|
||||||
|
'sub_kriteria_id' => null,
|
||||||
|
'subkriteria_text' => 'Nominal: Rp '.number_format($cleanUktValue, 0, ',', '.'),
|
||||||
|
'file_dokumen' => $fileUktPath,
|
||||||
|
'verified' => false
|
||||||
|
]);
|
||||||
|
|
||||||
|
$kriteriaMap = [
|
||||||
|
'penghasilan' => 'Penghasilan Orang Tua',
|
||||||
|
'pekerjaan' => 'Pekerjaan Orang Tua',
|
||||||
|
'tanggungan' => 'Tanggungan Orang Tua',
|
||||||
|
'status_ortu' => 'Status Orang Tua',
|
||||||
|
'hunian' => 'Hunian',
|
||||||
|
'kendaraan' => 'Kendaraan',
|
||||||
|
'semester' => 'Semester',
|
||||||
|
'ipk' => 'IPK'
|
||||||
|
];
|
||||||
|
|
||||||
|
$allKriteria = Kriteria::whereIn('nama_kriteria', array_values($kriteriaMap))->get();
|
||||||
|
if ($allKriteria->count() !== count($kriteriaMap)) {
|
||||||
|
throw new \Exception("Beberapa kriteria tidak ditemukan dalam database");
|
||||||
|
}
|
||||||
|
|
||||||
|
$allSubKriteria = SubKriteria::whereIn('kriteria_id', $allKriteria->pluck('id'))->get()->groupBy('kriteria_id');
|
||||||
|
|
||||||
|
$detailsToInsert = [];
|
||||||
|
|
||||||
|
// Process all criteria except IPK and Semester
|
||||||
|
foreach ($kriteriaMap as $inputName => $kriteriaName) {
|
||||||
|
if (in_array($inputName, ['semester', 'ipk'])) continue;
|
||||||
|
|
||||||
|
$kriteria = $allKriteria->firstWhere('nama_kriteria', $kriteriaName);
|
||||||
|
$subkriteriaValue = $request->$inputName;
|
||||||
|
|
||||||
|
$subKriteria = isset($allSubKriteria[$kriteria->id])
|
||||||
|
? $allSubKriteria[$kriteria->id]->firstWhere('nama_subkriteria', $subkriteriaValue)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
// Handle file upload
|
||||||
|
$fileInputName = 'file_' . $inputName;
|
||||||
|
$filePath = null;
|
||||||
|
|
||||||
|
if ($request->hasFile($fileInputName)) {
|
||||||
|
$filePath = $request->file($fileInputName)->store('pengajuan/dokumen', 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special handling for Kendaraan
|
||||||
|
if ($kriteriaName === 'Kendaraan' && $subkriteriaValue === 'Tidak Punya') {
|
||||||
|
$filePath = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$detailsToInsert[] = [
|
||||||
|
'pengajuan_ukt_id' => $pengajuan->id,
|
||||||
|
'kriteria' => $kriteriaName,
|
||||||
|
'kriteria_id' => $kriteria->id,
|
||||||
|
'sub_kriteria_id' => $subKriteria ? $subKriteria->id : null,
|
||||||
|
'subkriteria_text' => $subkriteriaValue,
|
||||||
|
'file_dokumen' => $filePath,
|
||||||
|
'verified' => false,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Semester criteria with KHS file
|
||||||
|
$semesterKriteria = $allKriteria->firstWhere('nama_kriteria', 'Semester');
|
||||||
|
$semesterSubKriteria = $allSubKriteria[$semesterKriteria->id]
|
||||||
|
->firstWhere('nama_subkriteria', $request->semester);
|
||||||
|
|
||||||
|
$detailsToInsert[] = [
|
||||||
|
'pengajuan_ukt_id' => $pengajuan->id,
|
||||||
|
'kriteria' => 'Semester',
|
||||||
|
'kriteria_id' => $semesterKriteria->id,
|
||||||
|
'sub_kriteria_id' => $semesterSubKriteria->id,
|
||||||
|
'subkriteria_text' => $request->semester,
|
||||||
|
'file_dokumen' => $fileKhsPath,
|
||||||
|
'verified' => false,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
];
|
||||||
|
|
||||||
|
// Add IPK criteria with same KHS file
|
||||||
|
$ipkKriteria = $allKriteria->firstWhere('nama_kriteria', 'IPK');
|
||||||
|
$ipkSubKriteria = $allSubKriteria[$ipkKriteria->id]
|
||||||
|
->firstWhere('nama_subkriteria', $request->ipk);
|
||||||
|
|
||||||
|
$detailsToInsert[] = [
|
||||||
|
'pengajuan_ukt_id' => $pengajuan->id,
|
||||||
|
'kriteria' => 'IPK',
|
||||||
|
'kriteria_id' => $ipkKriteria->id,
|
||||||
|
'sub_kriteria_id' => $ipkSubKriteria->id,
|
||||||
|
'subkriteria_text' => $request->ipk,
|
||||||
|
'file_dokumen' => $fileKhsPath,
|
||||||
|
'verified' => false,
|
||||||
|
'created_at' => now(),
|
||||||
|
'updated_at' => now()
|
||||||
|
];
|
||||||
|
|
||||||
|
// Insert all details at once
|
||||||
|
PengajuanDetail::insert($detailsToInsert);
|
||||||
|
|
||||||
|
// Handle optional supporting document
|
||||||
|
if ($request->hasFile('file_pendukung')) {
|
||||||
|
$filePendukungPath = $request->file('file_pendukung')->store('pengajuan/dokumen', 'public');
|
||||||
|
$pengajuan->update(['file_pendukung' => $filePendukungPath]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Pengajuan berhasil dikirim',
|
||||||
|
'redirect' => route('pengajuan.index')
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
Log::error('Pengajuan error: '.$e->getMessage());
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal mengirim pengajuan: '.$e->getMessage(),
|
||||||
|
'errors' => $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDefaultBobot($kriteriaName)
|
||||||
|
{
|
||||||
|
$totalKriteria = 8;
|
||||||
|
return round(1 / $totalKriteria, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(PengajuanUkt $pengajuan)
|
||||||
|
{
|
||||||
|
if ($pengajuan->mahasiswa_id != auth()->id()) {
|
||||||
|
abort(403);
|
||||||
|
}
|
||||||
|
return redirect()->route('dashboard.mahasiswa')->with('success', 'Pengajuan berhasil diproses');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewDocument($pengajuanId, $docType)
|
||||||
|
{
|
||||||
|
if (!in_array(auth()->user()->role, ['admin', 'karyawan'])) {
|
||||||
|
abort(403, 'Akses ditolak!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pengajuan = PengajuanUkt::findOrFail($pengajuanId);
|
||||||
|
$docType = str_replace('-', ' ', $docType);
|
||||||
|
|
||||||
|
$detail = $pengajuan->details()
|
||||||
|
->where('kriteria', $docType)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
if (!$detail->file_dokumen) {
|
||||||
|
abort(404, 'File tidak ditemukan');
|
||||||
|
}
|
||||||
|
|
||||||
|
$fullPath = storage_path('app/public/'.$detail->file_dokumen);
|
||||||
|
|
||||||
|
if (!file_exists($fullPath)) {
|
||||||
|
abort(404, 'File tidak ditemukan di storage');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->file($fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cleanFileName($name)
|
||||||
|
{
|
||||||
|
return preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '_', $name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPengajuanStats($mahasiswaId)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'total' => PengajuanUkt::where('mahasiswa_id', $mahasiswaId)->count(),
|
||||||
|
'diterima' => PengajuanUkt::where('mahasiswa_id', $mahasiswaId)
|
||||||
|
->where('status_validasi', 'valid')->count(),
|
||||||
|
'ditolak' => PengajuanUkt::where('mahasiswa_id', $mahasiswaId)
|
||||||
|
->where('status_validasi', 'tidak valid')->count(),
|
||||||
|
'menunggu' => PengajuanUkt::where('mahasiswa_id', $mahasiswaId)
|
||||||
|
->where('status_validasi', 'menunggu')->count()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Form;
|
||||||
|
use App\Services\SawCalculationService;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class PenilaianController extends Controller
|
||||||
|
{
|
||||||
|
protected $sawService;
|
||||||
|
|
||||||
|
public function __construct(SawCalculationService $sawService)
|
||||||
|
{
|
||||||
|
$this->sawService = $sawService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$query = PengajuanUkt::with(['mahasiswa.user', 'hasilPenilaian'])
|
||||||
|
->where('status_validasi', 'valid');
|
||||||
|
|
||||||
|
if ($request->has('status_form_id') && $request->status_form_id != '') {
|
||||||
|
$query->where('status_form_id', $request->status_form_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$validPengajuans = $query->orderByDesc('created_at')
|
||||||
|
->paginate(10)
|
||||||
|
->appends($request->query());
|
||||||
|
|
||||||
|
$forms = Form::orderBy('nama_form')->get();
|
||||||
|
|
||||||
|
return view('admin.penilaian.index', compact('validPengajuans', 'forms'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calculateAll()
|
||||||
|
{
|
||||||
|
$validIds = PengajuanUkt::where('status_validasi', 'valid')
|
||||||
|
->pluck('id')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
// Proses langsung tanpa queue untuk local
|
||||||
|
$result = $this->sawService->processBatch($validIds);
|
||||||
|
|
||||||
|
return redirect()->route('admin.ranking.index')
|
||||||
|
->with('success', 'Berhasil memproses '.$result['success_count'].' dari '.count($validIds).' pengajuan');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calculate($id)
|
||||||
|
{
|
||||||
|
$pengajuan = PengajuanUkt::with('details')->findOrFail($id);
|
||||||
|
|
||||||
|
$hasil = $this->sawService->calculate($pengajuan);
|
||||||
|
|
||||||
|
$kriterias = Kriteria::whereIn('id', array_keys($hasil['decision_matrix']))
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
|
||||||
|
return view('admin.penilaian.result', compact('pengajuan', 'hasil', 'kriterias'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processBatch(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'limit' => 'required|integer|min:1|max:100'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pengajuanIds = PengajuanUkt::where('status_validasi', 'valid')
|
||||||
|
->whereDoesntHave('hasilPenilaian')
|
||||||
|
->limit($request->limit)
|
||||||
|
->pluck('id')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
if (empty($pengajuanIds)) {
|
||||||
|
return redirect()->back()
|
||||||
|
->with('info', 'Semua pengajuan valid sudah diproses');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->sawService->processBatch($pengajuanIds);
|
||||||
|
|
||||||
|
return redirect()->route('admin.penilaian.index')
|
||||||
|
->with('success', 'Berhasil memproses '.$result['success_count'].' data pengajuan!');
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', 'Gagal memproses: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function result($id)
|
||||||
|
{
|
||||||
|
$pengajuan = PengajuanUkt::with(['mahasiswa.user', 'details.subKriteria', 'hasilPenilaian'])
|
||||||
|
->findOrFail($id);
|
||||||
|
|
||||||
|
if (!$pengajuan->hasilPenilaian) {
|
||||||
|
return redirect()->route('admin.penilaian.index')
|
||||||
|
->with('error', 'Data ini belum diproses');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Get full calculation details from service
|
||||||
|
$hasil = $this->sawService->getCalculationDetails($pengajuan->id);
|
||||||
|
|
||||||
|
// Get all kriterias with their subkriteria
|
||||||
|
$kriterias = Kriteria::with('subKriteria')->get()->keyBy('id');
|
||||||
|
|
||||||
|
return view('admin.penilaian.result', [
|
||||||
|
'pengajuan' => $pengajuan,
|
||||||
|
'hasil' => $hasil,
|
||||||
|
'kriterias' => $kriterias
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', 'Gagal menampilkan hasil: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}}
|
|
@ -0,0 +1,354 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Exports\HasilPerhitunganPdf;
|
||||||
|
use App\Models\HasilPenilaian;
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\Form;
|
||||||
|
use App\Services\SawCalculationService;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class RankingController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$forms = Form::orderBy('tahun', 'desc')
|
||||||
|
->orderBy('semester', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
// Get active form (either from request or first active form)
|
||||||
|
$activeForm = $request->filled('status_form_id')
|
||||||
|
? $forms->where('id', $request->status_form_id)->first()
|
||||||
|
: $forms->where('status', 'Dibuka')->first();
|
||||||
|
|
||||||
|
$baseQuery = HasilPenilaian::with(['pengajuan.mahasiswa.user', 'pengajuan.form'])
|
||||||
|
->whereHas('pengajuan', function ($q) use ($request) {
|
||||||
|
$q->where('status_validasi', 'valid');
|
||||||
|
|
||||||
|
if ($request->filled('status_form_id')) {
|
||||||
|
$q->where('status_form_id', $request->status_form_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('jenis_form')) {
|
||||||
|
$q->whereHas('form', function ($formQuery) use ($request) {
|
||||||
|
$formQuery->where('jenis_form', $request->jenis_form);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->orderBy('nilai_preferensi', 'desc');
|
||||||
|
|
||||||
|
// Get all results first to determine ranking and quota status
|
||||||
|
$allResults = $baseQuery->get();
|
||||||
|
|
||||||
|
$selectedFormId = $activeForm->id ?? null;
|
||||||
|
$form = $activeForm;
|
||||||
|
$quota = $activeForm->kuota ?? 0;
|
||||||
|
$withinQuotaIds = [];
|
||||||
|
|
||||||
|
// Calculate global ranking and quota status for all results
|
||||||
|
if ($request->filled('status_form_id')) {
|
||||||
|
$selectedFormId = $request->status_form_id;
|
||||||
|
$form = Form::find($selectedFormId);
|
||||||
|
$quota = $form->kuota ?? 0;
|
||||||
|
|
||||||
|
// Get rankings for this specific form
|
||||||
|
$formResults = $allResults->filter(function ($item) use ($selectedFormId) {
|
||||||
|
return optional($item->pengajuan)->status_form_id == $selectedFormId;
|
||||||
|
})->sortByDesc('nilai_preferensi')->values();
|
||||||
|
|
||||||
|
// Determine which results are within quota
|
||||||
|
$withinQuotaIds = $formResults->take($quota)->pluck('id')->toArray();
|
||||||
|
|
||||||
|
// Add quota status to all results
|
||||||
|
foreach ($allResults as $result) {
|
||||||
|
if (optional($result->pengajuan)->status_form_id == $selectedFormId) {
|
||||||
|
$rank = $formResults->search(function ($item) use ($result) {
|
||||||
|
return $item->id === $result->id;
|
||||||
|
}) + 1;
|
||||||
|
|
||||||
|
$result->current_rank = $rank;
|
||||||
|
$result->is_beyond_quota = $rank > $quota && $quota > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply quota filter if requested
|
||||||
|
if ($request->filled('kuota_filter') && $request->filled('status_form_id')) {
|
||||||
|
if ($request->kuota_filter == 'available') {
|
||||||
|
$baseQuery->whereIn('id', $withinQuotaIds);
|
||||||
|
} elseif ($request->kuota_filter == 'exceeded') {
|
||||||
|
$baseQuery->whereNotIn('id', $withinQuotaIds)
|
||||||
|
->whereHas('pengajuan', function($q) use ($selectedFormId) {
|
||||||
|
$q->where('status_form_id', $selectedFormId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get paginated results
|
||||||
|
$rankings = $baseQuery->paginate(20);
|
||||||
|
|
||||||
|
// Mark which results are beyond quota for display
|
||||||
|
foreach ($rankings as $ranking) {
|
||||||
|
if ($selectedFormId && optional($ranking->pengajuan)->status_form_id == $selectedFormId) {
|
||||||
|
$ranking->is_beyond_quota = !in_array($ranking->id, $withinQuotaIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize semester reports
|
||||||
|
$semesterReports = [];
|
||||||
|
|
||||||
|
// Group forms by unique semester-year combinations
|
||||||
|
$uniqueSemesters = $forms->unique(function ($item) {
|
||||||
|
return $item->semester.$item->tahun;
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($uniqueSemesters as $form) {
|
||||||
|
$key = $form->semester.'_'.$form->tahun;
|
||||||
|
|
||||||
|
$semesterReports[$key] = [
|
||||||
|
'semester' => $form->semester,
|
||||||
|
'tahun' => $form->tahun,
|
||||||
|
'forms' => [],
|
||||||
|
'total_ukt_saat_ini' => 0,
|
||||||
|
'total_ukt_penyesuaian' => 0,
|
||||||
|
'total_mahasiswa' => 0,
|
||||||
|
'kuota_total' => 0,
|
||||||
|
'kuota_terpakai' => 0,
|
||||||
|
'total_average' => 0,
|
||||||
|
'total_selisih' => 0,
|
||||||
|
'persentase_terpakai' => 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate statistics for each semester
|
||||||
|
foreach ($semesterReports as $key => &$report) {
|
||||||
|
$formsInSemester = $forms->where('semester', $report['semester'])
|
||||||
|
->where('tahun', $report['tahun']);
|
||||||
|
|
||||||
|
foreach ($formsInSemester as $form) {
|
||||||
|
$formResults = $allResults->filter(function ($item) use ($form) {
|
||||||
|
return optional($item->pengajuan)->form_id == $form->id;
|
||||||
|
});
|
||||||
|
|
||||||
|
$formData = [
|
||||||
|
'id' => $form->id,
|
||||||
|
'nama_form' => $form->nama_form,
|
||||||
|
'jenis_form' => $form->jenis_form,
|
||||||
|
'ukt_saat_ini' => $formResults->sum(function ($item) {
|
||||||
|
return optional($item->pengajuan)->ukt_saat_ini ?? 0;
|
||||||
|
}),
|
||||||
|
'ukt_penyesuaian' => $formResults->sum(function ($item) {
|
||||||
|
return $item->ukt_penyesuaian ?? 0;
|
||||||
|
}),
|
||||||
|
'jumlah_mahasiswa' => $formResults->count(),
|
||||||
|
'kuota' => $form->kuota,
|
||||||
|
'kuota_terpakai' => $formResults->count(),
|
||||||
|
'average' => 0,
|
||||||
|
'selisih' => 0
|
||||||
|
];
|
||||||
|
|
||||||
|
// Calculate averages and differences
|
||||||
|
if ($formData['jumlah_mahasiswa'] > 0) {
|
||||||
|
$formData['average'] = $formData['ukt_penyesuaian'] / $formData['jumlah_mahasiswa'];
|
||||||
|
}
|
||||||
|
$formData['selisih'] = $formData['ukt_saat_ini'] - $formData['ukt_penyesuaian'];
|
||||||
|
|
||||||
|
$report['forms'][] = $formData;
|
||||||
|
|
||||||
|
// Aggregate semester totals
|
||||||
|
$report['total_ukt_saat_ini'] += $formData['ukt_saat_ini'];
|
||||||
|
$report['total_ukt_penyesuaian'] += $formData['ukt_penyesuaian'];
|
||||||
|
$report['total_mahasiswa'] += $formData['jumlah_mahasiswa'];
|
||||||
|
$report['kuota_total'] += $formData['kuota'];
|
||||||
|
$report['kuota_terpakai'] += $formData['kuota_terpakai'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate semester-level metrics
|
||||||
|
$report['total_average'] = $report['total_mahasiswa'] > 0
|
||||||
|
? $report['total_ukt_penyesuaian'] / $report['total_mahasiswa']
|
||||||
|
: 0;
|
||||||
|
$report['total_selisih'] = $report['total_ukt_saat_ini'] - $report['total_ukt_penyesuaian'];
|
||||||
|
$report['persentase_terpakai'] = $report['kuota_total'] > 0
|
||||||
|
? ($report['kuota_terpakai'] / $report['kuota_total']) * 100
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert associative array to indexed array and sort
|
||||||
|
$semesterReports = array_values($semesterReports);
|
||||||
|
|
||||||
|
// Sort semester reports by year (descending) and semester (Ganjil first)
|
||||||
|
usort($semesterReports, function ($a, $b) {
|
||||||
|
if ($a['tahun'] == $b['tahun']) {
|
||||||
|
return $a['semester'] == 'Ganjil' ? -1 : 1;
|
||||||
|
}
|
||||||
|
return $b['tahun'] - $a['tahun'];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Overall statistics
|
||||||
|
$totalUktSaatIni = $allResults->sum(function($item) {
|
||||||
|
return optional($item->pengajuan)->ukt_saat_ini ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
$totalUktPenyesuaian = $allResults->sum(function($item) {
|
||||||
|
return $item->ukt_penyesuaian ?? 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
$averageUktPenyesuaian = $allResults->count() > 0
|
||||||
|
? $totalUktPenyesuaian / $allResults->count()
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
$selisihUkt = $totalUktSaatIni - $totalUktPenyesuaian;
|
||||||
|
$countMahasiswa = $allResults->count();
|
||||||
|
|
||||||
|
// Budget calculations
|
||||||
|
$budget = HasilPenilaian::getCurrentBudget();
|
||||||
|
$budgetDifference = $budget - $totalUktPenyesuaian;
|
||||||
|
|
||||||
|
return view('admin.ranking.index', compact(
|
||||||
|
'rankings',
|
||||||
|
'forms',
|
||||||
|
'semesterReports',
|
||||||
|
'totalUktSaatIni',
|
||||||
|
'totalUktPenyesuaian',
|
||||||
|
'averageUktPenyesuaian',
|
||||||
|
'selisihUkt',
|
||||||
|
'countMahasiswa',
|
||||||
|
'budget',
|
||||||
|
'budgetDifference'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBudget(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'budget' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$budget = str_replace('.', '', $request->budget);
|
||||||
|
HasilPenilaian::updateBudget((int)$budget);
|
||||||
|
return back()->with('success', 'Budget berhasil disimpan!');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->with('error', 'Gagal menyimpan budget: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setActiveBudget(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'status_form_id' => 'required|exists:forms,id',
|
||||||
|
'budget' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$budget = str_replace('.', '', $request->budget);
|
||||||
|
$form = Form::findOrFail($request->status_form_id);
|
||||||
|
|
||||||
|
// Update budget in keterangan column for all results of this form
|
||||||
|
HasilPenilaian::whereHas('pengajuan', function($q) use ($request) {
|
||||||
|
$q->where('status_form_id', $request->status_form_id);
|
||||||
|
})->update(['keterangan' => $budget]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Budget untuk form aktif berhasil disimpan!');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->with('error', 'Gagal menyimpan budget: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$request->validate([
|
||||||
|
'status_form_id' => 'required|exists:forms,id'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$form = Form::findOrFail($request->status_form_id);
|
||||||
|
|
||||||
|
$rankings = HasilPenilaian::with([
|
||||||
|
'pengajuan:id,mahasiswa_id,form_id,ukt_saat_ini,status_validasi',
|
||||||
|
'pengajuan.mahasiswa:id,user_id,nim,program_studi',
|
||||||
|
'pengajuan.mahasiswa.user:id,name'
|
||||||
|
])
|
||||||
|
->whereHas('pengajuan', function($q) use ($request) {
|
||||||
|
$q->where('status_validasi', 'valid')
|
||||||
|
->where('status_form_id', $request->status_form_id);
|
||||||
|
})
|
||||||
|
->orderBy('nilai_preferensi', 'desc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($rankings->isEmpty()) {
|
||||||
|
return back()->with('error', 'Tidak ada data yang dapat diexport untuk form ini');
|
||||||
|
}
|
||||||
|
|
||||||
|
$judul = strtoupper($form->jenis_form) . ' UKT MAHASISWA ' .
|
||||||
|
$form->semester . ' POLITEKNIK NEGERI JEMBER TAHUN AKADEMIK ' . $form->tahun;
|
||||||
|
|
||||||
|
// Debug: Check if view exists
|
||||||
|
if (!view()->exists('admin.ranking.export')) {
|
||||||
|
throw new \Exception("View 'admin.ranking.export' not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf = PDF::loadView('admin.ranking.export', [
|
||||||
|
'judul' => $judul,
|
||||||
|
'form' => $form,
|
||||||
|
'mahasiswa' => $rankings
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $pdf->download('ranking-ukt-' . strtolower($form->jenis_form) . '-' .
|
||||||
|
$form->semester . '-' . $form->tahun . '.pdf');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::error('PDF Export Error', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'trace' => $e->getTraceAsString(),
|
||||||
|
'request' => $request->all()
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('error', 'Gagal export PDF: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function recalculateAll(SawCalculationService $sawService)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validIds = PengajuanUkt::where('status_validasi', 'valid')
|
||||||
|
->pluck('id')
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$result = $sawService->processBatch($validIds);
|
||||||
|
|
||||||
|
return back()->with([
|
||||||
|
'status' => $result['status'],
|
||||||
|
'message' => $result['message']
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->with('error', 'Gagal memproses: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateUkt(Request $request, $id)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'ukt_penyesuaian' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Remove formatting and convert to integer
|
||||||
|
$uktValue = str_replace('.', '', $request->ukt_penyesuaian);
|
||||||
|
$uktValue = (int)$uktValue;
|
||||||
|
|
||||||
|
$ranking = HasilPenilaian::findOrFail($id);
|
||||||
|
$ranking->update([
|
||||||
|
'ukt_penyesuaian' => $uktValue,
|
||||||
|
'status_penyesuaian' => 'sudah dilakukan penyesuaian'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'UKT Penyesuaian berhasil diperbarui!');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->with('error', 'Gagal memperbarui UKT: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}}
|
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Services\SawCalculationService;
|
||||||
|
use App\Exceptions\SawCalculationException;
|
||||||
|
use App\Models\HasilPenilaian;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use App\Exports\HasilPerhitunganExport;
|
||||||
|
|
||||||
|
class SawController extends Controller
|
||||||
|
{
|
||||||
|
protected $sawService;
|
||||||
|
|
||||||
|
public function __construct(SawCalculationService $sawService)
|
||||||
|
{
|
||||||
|
$this->sawService = $sawService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle request untuk perhitungan SAW
|
||||||
|
*/
|
||||||
|
public function hitungSAW(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'jenis_pengajuan' => 'required|in:penurunan,pengangsuran'
|
||||||
|
]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$result = $this->sawService->prosesPerhitunganLengkap($request->jenis_pengajuan);
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->route('admin.hasil-perhitungan')
|
||||||
|
->with([
|
||||||
|
'success' => $result['message'],
|
||||||
|
'result' => $result
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (SawCalculationException $e) {
|
||||||
|
return back()
|
||||||
|
->withInput()
|
||||||
|
->with('error', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tampilkan hasil perhitungan
|
||||||
|
*/
|
||||||
|
public function showHasil()
|
||||||
|
{
|
||||||
|
$results = HasilPenilaian::with(['pengajuan.mahasiswa.user'])
|
||||||
|
->orderBy('nilai_preferensi', 'desc')
|
||||||
|
->paginate(10);
|
||||||
|
|
||||||
|
return view('admin.hasil-perhitungan', compact('results'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download hasil perhitungan
|
||||||
|
*/
|
||||||
|
public function downloadHasil(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'jenis' => 'required|in:pdf,excel',
|
||||||
|
'limit' => 'nullable|integer|min:1|max:1000'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$results = HasilPenilaian::with(['pengajuan.mahasiswa.user'])
|
||||||
|
->orderBy('nilai_preferensi', 'desc')
|
||||||
|
->limit($request->limit ?? 100)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if ($request->jenis == 'pdf') {
|
||||||
|
return $this->generatePDF($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->generateExcel($results);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generatePDF($data)
|
||||||
|
{
|
||||||
|
return Pdf::loadView('admin.exports.hasil-pdf', ['results' => $data])
|
||||||
|
->setPaper('a4', 'landscape')
|
||||||
|
->stream('hasil-saw-'.now()->format('Ymd').'.pdf');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateExcel($data)
|
||||||
|
{
|
||||||
|
return Excel::download(new HasilPerhitunganExport($data),
|
||||||
|
'hasil-saw-'.now()->format('Ymd').'.xlsx');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class StatusFormController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,194 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\SubKriteria;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Penilaian;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class SubkriteriaController extends Controller
|
||||||
|
{
|
||||||
|
public function index(Request $request, $kriteria = null)
|
||||||
|
{
|
||||||
|
if ($kriteria) {
|
||||||
|
$kriteria = Kriteria::findOrFail($kriteria);
|
||||||
|
$order = $kriteria->attribut == 'benefit' ? 'desc' : 'asc';
|
||||||
|
$subkriterias = $kriteria->subkriteria()->orderBy('nilai', $order)->get();
|
||||||
|
} else {
|
||||||
|
// Gunakan chunk atau cursor jika data sangat besar
|
||||||
|
$subkriterias = SubKriteria::with('kriteria')
|
||||||
|
->get()
|
||||||
|
->groupBy('kriteria_id')
|
||||||
|
->map(function ($items) {
|
||||||
|
$order = $items->first()->kriteria->attribut == 'benefit' ? 'desc' : 'asc';
|
||||||
|
return $order == 'desc'
|
||||||
|
? $items->sortByDesc('nilai')
|
||||||
|
: $items->sortBy('nilai');
|
||||||
|
})
|
||||||
|
->flatten();
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.subkriteria.index', compact('kriteria', 'subkriterias'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function indexByKriteria(Kriteria $kriteria)
|
||||||
|
{
|
||||||
|
$order = ($kriteria->attribut == 'benefit') ? 'desc' : 'asc';
|
||||||
|
$subkriterias = $kriteria->subkriteria()
|
||||||
|
->orderBy('nilai', $order)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('admin.subkriteria.index', [
|
||||||
|
'kriteria' => $kriteria,
|
||||||
|
'subkriterias' => $subkriterias
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(Request $request)
|
||||||
|
{
|
||||||
|
$kriteria = Kriteria::all();
|
||||||
|
$selectedKriteria = $request->query('kriteria_id');
|
||||||
|
|
||||||
|
// Validate if kriteria exists if provided
|
||||||
|
if ($selectedKriteria && !Kriteria::find($selectedKriteria)) {
|
||||||
|
abort(404, 'Kriteria tidak ditemukan');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.subkriteria.create', [
|
||||||
|
'kriterias' => $kriteria,
|
||||||
|
'selectedKriteria' => $selectedKriteria
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$validated = $request->validate([
|
||||||
|
'kriteria_id' => 'required|exists:kriteria,id',
|
||||||
|
'nama_subkriteria' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('sub_kriterias')->where(function ($query) use ($request) {
|
||||||
|
return $query->where('kriteria_id', $request->kriteria_id);
|
||||||
|
})
|
||||||
|
],
|
||||||
|
'nilai' => 'required|integer|min:0|max:100'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$subkriteria = SubKriteria::create($validated);
|
||||||
|
|
||||||
|
return redirect()->route('subkriteria.index', $subkriteria->kriteria)
|
||||||
|
->with('success', 'Sub kriteria berhasil ditambahkan');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error creating subkriteria: ' . $e->getMessage());
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', 'Gagal menambahkan sub kriteria: ' . $e->getMessage())
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$subkriteria = SubKriteria::with('kriteria')->findOrFail($id);
|
||||||
|
|
||||||
|
return view('admin.subkriteria.edit', [
|
||||||
|
'subkriteria' => $subkriteria,
|
||||||
|
'kriteria' => $subkriteria->kriteria
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$subkriteria = SubKriteria::findOrFail($id);
|
||||||
|
|
||||||
|
$validated = $request->validate([
|
||||||
|
'nama_subkriteria' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'max:255',
|
||||||
|
Rule::unique('sub_kriterias')
|
||||||
|
->where('kriteria_id', $subkriteria->kriteria_id)
|
||||||
|
->ignore($subkriteria->id)
|
||||||
|
],
|
||||||
|
'nilai' => 'required|integer|min:0|max:100'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$subkriteria->update($validated);
|
||||||
|
|
||||||
|
return redirect()->route('subkriteria.index', $subkriteria->kriteria_id)
|
||||||
|
->with('success', 'Sub kriteria berhasil diperbarui');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Error updating subkriteria: ' . $e->getMessage());
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', 'Gagal memperbarui sub kriteria: ' . $e->getMessage())
|
||||||
|
->withInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$subkriteria = SubKriteria::findOrFail($id);
|
||||||
|
$kriteriaId = $subkriteria->kriteria_id;
|
||||||
|
$subkriteria->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Sub kriteria berhasil dihapus',
|
||||||
|
'redirect' => route('subkriteria.index', ['kriteria' => $kriteriaId])
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Gagal menghapus sub kriteria: ' . $e->getMessage()
|
||||||
|
], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadPDF($kriteria_id = null)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
if ($kriteria_id) {
|
||||||
|
$kriteria = Kriteria::findOrFail($kriteria_id);
|
||||||
|
$subkriterias = $kriteria->subkriteria()
|
||||||
|
->orderBy('nilai', $kriteria->attribut == 'benefit' ? 'desc' : 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data['kriteria'] = $kriteria;
|
||||||
|
$data['subkriterias'] = $subkriterias;
|
||||||
|
} else {
|
||||||
|
$allKriteria = Kriteria::with('subkriteria')->get();
|
||||||
|
$grouped = [];
|
||||||
|
|
||||||
|
foreach ($allKriteria as $krit) {
|
||||||
|
$subs = $krit->subkriteria->sortBy(function ($sub) use ($krit) {
|
||||||
|
return $krit->attribut == 'benefit' ? -$sub->nilai : $sub->nilai;
|
||||||
|
})->values();
|
||||||
|
|
||||||
|
$grouped[] = [
|
||||||
|
'kriteria' => $krit,
|
||||||
|
'subkriterias' => $subs
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['kriteria'] = null;
|
||||||
|
$data['grouped_subkriterias'] = $grouped;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf = PDF::loadView('admin.subkriteria.subkriteria-pdf', $data);
|
||||||
|
$filename = $kriteria_id
|
||||||
|
? "Subkriteria-{$data['kriteria']->nama_kriteria}.pdf"
|
||||||
|
: "Semua-Subkriteria.pdf";
|
||||||
|
|
||||||
|
return $pdf->stream($filename);
|
||||||
|
}}
|
|
@ -0,0 +1,335 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Models\Mahasiswa;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Http\Requests\StoreUserRequest;
|
||||||
|
use App\Http\Requests\UpdateUserRequest;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
|
||||||
|
class UserController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$users = User::select('id', 'name', 'email', 'role', 'created_at')
|
||||||
|
->with(['mahasiswa' => function($query) {
|
||||||
|
$query->select('user_id', 'nim', 'program_studi');
|
||||||
|
}])
|
||||||
|
->orderBy('created_at', 'desc')
|
||||||
|
->paginate(20); // Reduced from 20 to 10-15 if possible
|
||||||
|
|
||||||
|
return view('admin.user.index', compact('users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function create(Request $request)
|
||||||
|
// {
|
||||||
|
// $defaultRole = $request->has('force_mahasiswa') ? 'mahasiswa' : 'mahasiswa';
|
||||||
|
|
||||||
|
// return view('admin.user.create', [
|
||||||
|
// 'defaultRole' => $defaultRole,
|
||||||
|
// 'force_mahasiswa' => $request->has('force_mahasiswa')
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function store(StoreUserRequest $request)
|
||||||
|
{
|
||||||
|
$role = $request->has('force_mahasiswa') ? 'mahasiswa' : $request->role;
|
||||||
|
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'role' => $role,
|
||||||
|
'alamat' => $request->alamat ?? 'Belum diisi',
|
||||||
|
'telepon' => $request->telepon ?? 'Belum diisi',
|
||||||
|
'keterangan' => $role === 'mahasiswa' ? 'Mahasiswa' : $request->keterangan
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($role === 'mahasiswa') {
|
||||||
|
Mahasiswa::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->has('force_mahasiswa')) {
|
||||||
|
return redirect()->route('login')->with('success', 'Registrasi berhasil! Silakan login.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('user.index')->with('success', 'User berhasil dibuat');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateUserRequest $request, $id)
|
||||||
|
{
|
||||||
|
$user = User::with('mahasiswa')->findOrFail($id);
|
||||||
|
|
||||||
|
DB::transaction(function () use ($request, $user) {
|
||||||
|
$previousRole = $user->role;
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'alamat' => $request->alamat,
|
||||||
|
'telepon' => $request->telepon,
|
||||||
|
'keterangan' => $request->keterangan,
|
||||||
|
'role' => $request->role
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Handle perubahan role
|
||||||
|
if ($previousRole !== $request->role) {
|
||||||
|
if ($request->role === 'mahasiswa') {
|
||||||
|
$request->validate([
|
||||||
|
'nim' => 'required|unique:mahasiswas,nim,'.$user->id.',user_id',
|
||||||
|
'program_studi' => 'required|string',
|
||||||
|
'jurusan' => 'required|string',
|
||||||
|
'no_hp' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Buat atau update data mahasiswa
|
||||||
|
$mahasiswaData = [
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($user->mahasiswa) {
|
||||||
|
$user->mahasiswa()->update($mahasiswaData);
|
||||||
|
} else {
|
||||||
|
$user->mahasiswa()->create($mahasiswaData);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($user->mahasiswa) {
|
||||||
|
$user->mahasiswa()->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($request->role === 'mahasiswa') {
|
||||||
|
$request->validate([
|
||||||
|
'nim' => 'required|unique:mahasiswas,nim,'.$user->id.',user_id',
|
||||||
|
'program_studi' => 'required|string',
|
||||||
|
'jurusan' => 'required|string',
|
||||||
|
'no_hp' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->mahasiswa()->updateOrCreate(
|
||||||
|
['user_id' => $user->id],
|
||||||
|
[
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return redirect()->route('user.index')->with('success', 'User berhasil diperbarui');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
DB::transaction(function () use ($id) {
|
||||||
|
$user = User::with('mahasiswa')->findOrFail($id);
|
||||||
|
|
||||||
|
if ($user->mahasiswa) {
|
||||||
|
$user->mahasiswa()->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->delete();
|
||||||
|
});
|
||||||
|
|
||||||
|
return redirect()->route('user.index')
|
||||||
|
->with('success', 'User berhasil dihapus');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', 'Gagal menghapus user: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createMahasiswaData(User $user, Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'nim' => 'required|unique:mahasiswas,nim',
|
||||||
|
'program_studi' => 'required|string',
|
||||||
|
'jurusan' => 'required|string',
|
||||||
|
'no_hp' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $user->mahasiswa()->create([
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function handleMahasiswaData(User $user, Request $request)
|
||||||
|
{
|
||||||
|
if ($request->role === 'mahasiswa') {
|
||||||
|
$mahasiswaData = $request->only('nim', 'program_studi', 'jurusan', 'no_hp');
|
||||||
|
|
||||||
|
if ($user->mahasiswa) {
|
||||||
|
$user->mahasiswa()->update($mahasiswaData);
|
||||||
|
} else {
|
||||||
|
$this->createMahasiswaData($user, $request);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($user->mahasiswa) {
|
||||||
|
$user->mahasiswa()->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function completeData($id)
|
||||||
|
{
|
||||||
|
$user = User::with('mahasiswa')->findOrFail($id);
|
||||||
|
|
||||||
|
if ($user->role === 'mahasiswa' && !$user->mahasiswa) {
|
||||||
|
return view('admin.user.complete-mahasiswa', compact('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->with('error', 'User tidak memerlukan pelengkapan data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function storeCompleteData(Request $request, $id)
|
||||||
|
{
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'nim' => 'required|unique:mahasiswas,nim',
|
||||||
|
'program_studi' => 'required|string',
|
||||||
|
'jurusan' => 'required|string',
|
||||||
|
'no_hp' => 'required'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->mahasiswa()->create([
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('user.index')->with('success', 'Data mahasiswa berhasil dilengkapi');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showMahasiswaRegistrationForm()
|
||||||
|
{
|
||||||
|
return view('auth.register-mahasiswa', [
|
||||||
|
'hideAdminFields' => true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerMahasiswa(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Custom validation rules
|
||||||
|
$validator = Validator::make($request->all(), [
|
||||||
|
'name' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'regex:/^[A-Za-z\s]+$/',
|
||||||
|
'max:255',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if (preg_match('/[0-9]/', $value)) {
|
||||||
|
$fail('Nama tidak boleh mengandung angka.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'email',
|
||||||
|
'max:255',
|
||||||
|
'unique:users',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if (!preg_match('/@student\.polije\.ac\.id$/', $value)) {
|
||||||
|
$fail('Hanya email @student.polije.ac.id yang diperbolehkan.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
'nim' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'size:9',
|
||||||
|
'unique:mahasiswas',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if (!preg_match('/^[A-Z][0-9]{8}$/', $value)) {
|
||||||
|
$fail('Format NIM tidak valid. Harus diawali huruf kapital diikuti 8 angka (contoh: E12345678).');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'program_studi' => 'required|string',
|
||||||
|
'jurusan' => 'required|string',
|
||||||
|
'no_hp' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if (!preg_match('/^[0-9]+$/', $value)) {
|
||||||
|
$fail('Nomor HP hanya boleh mengandung angka.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($validator->fails()) {
|
||||||
|
return redirect()->back()
|
||||||
|
->withErrors($validator)
|
||||||
|
->withInput()
|
||||||
|
->with([
|
||||||
|
'alert_type' => 'error',
|
||||||
|
'alert_message' => 'Terdapat kesalahan dalam pengisian form. Silakan periksa kembali data Anda.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($request) {
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $request->name,
|
||||||
|
'email' => $request->email,
|
||||||
|
'password' => Hash::make($request->password),
|
||||||
|
'role' => 'mahasiswa',
|
||||||
|
'alamat' => $request->alamat ?? 'Belum diisi',
|
||||||
|
'telepon' => $request->telepon ?? 'Belum diisi',
|
||||||
|
'keterangan' => 'Mahasiswa'
|
||||||
|
]);
|
||||||
|
|
||||||
|
Mahasiswa::create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'nim' => $request->nim,
|
||||||
|
'program_studi' => $request->program_studi,
|
||||||
|
'jurusan' => $request->jurusan,
|
||||||
|
'no_hp' => $request->no_hp
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return redirect()->route('login')
|
||||||
|
->with('register_status', 'success')
|
||||||
|
->with('register_message', 'Registrasi berhasil! Silakan login dengan email dan password Anda');
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return back()->withInput()
|
||||||
|
->with('register_status', 'error')
|
||||||
|
->with('register_message', 'Registrasi gagal: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateProfile(Request $request)
|
||||||
|
{
|
||||||
|
Auth::user()->update($request->only('alamat'));
|
||||||
|
|
||||||
|
return response()->json(['message' => 'Profile updated successfully']);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
// \App\Http\Middleware\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Fruitcake\Cors\HandleCors::class,
|
||||||
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\SystemCheck::class,
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, class-string|string>>
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
// \Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
|
'throttle:api',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $routeMiddleware = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'admin' => \App\Http\Middleware\AdminMiddleware::class,
|
||||||
|
'karyawan' => \App\Http\Middleware\KaryawanMiddleware::class,
|
||||||
|
'mahasiswa' => \App\Http\Middleware\MahasiswaMiddleware::class,
|
||||||
|
'admin.karyawan' => \App\Http\Middleware\AdminAtauKaryawan::class,
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AdminAtauKaryawan
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
if (!$user || !in_array($user->role, ['admin', 'karyawan'])) {
|
||||||
|
abort(403, 'Unauthorized');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class AdminMiddleware
|
||||||
|
{
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if (!Auth::check()) {
|
||||||
|
return redirect()->route('login')->with('error', 'Silakan login terlebih dahulu');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Auth::user()->role !== 'admin') {
|
||||||
|
// Redirect ke halaman sesuai role atau home umum
|
||||||
|
return redirect()->route('dashboard.'.Auth::user()->role)
|
||||||
|
->with('error', 'Akses hanya untuk admin');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
|
||||||
|
class Authenticate extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
protected function redirectTo($request)
|
||||||
|
{
|
||||||
|
if (! $request->expectsJson()) {
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
|
||||||
|
class EncryptCookies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the cookies that should not be encrypted.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class KaryawanMiddleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if (Auth::check() && Auth::user()->role === 'karyawan') {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
abort(403, 'Unauthorized');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class MahasiswaMiddleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
$memoryStart = memory_get_usage();
|
||||||
|
|
||||||
|
if (!Auth::check()) {
|
||||||
|
abort(403, 'Unauthorized');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Auth::user()->role !== 'mahasiswa') {
|
||||||
|
abort(403, 'Unauthorized');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $next($request);
|
||||||
|
|
||||||
|
// Log memory usage
|
||||||
|
$memoryUsed = (memory_get_usage() - $memoryStart)/1024/1024;
|
||||||
|
if ($memoryUsed > 50) { // Jika > 50MB
|
||||||
|
\Log::warning("High memory usage in MahasiswaMiddleware: {$memoryUsed}MB");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||||
|
|
||||||
|
class PreventRequestsDuringMaintenance extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Providers\RouteServiceProvider;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @param string|null ...$guards
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next, ...$guards)
|
||||||
|
{
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (Auth::guard($guard)->check()) {
|
||||||
|
// Skip untuk API request
|
||||||
|
if ($request->expectsJson()) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Biarkan user mengakses halaman register meski sudah login
|
||||||
|
if ($request->is('register*')) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/home');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class SystemCheck
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||||
|
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if (!$request->hasSession()) {
|
||||||
|
abort(500, 'Session not initialized');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cek memory usage
|
||||||
|
if (memory_get_usage() > 1500 * 1024 * 1024) {
|
||||||
|
abort(503, 'System overload');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
|
||||||
|
class TrimStrings extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the attributes that should not be trimmed.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||||
|
|
||||||
|
class TrustHosts extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the host patterns that should be trusted.
|
||||||
|
*
|
||||||
|
* @return array<int, string|null>
|
||||||
|
*/
|
||||||
|
public function hosts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array<int, string>|string|null
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
use Illuminate\Session\TokenMismatchException;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
protected $except = [];
|
||||||
|
|
||||||
|
protected function tokensMatch($request)
|
||||||
|
{
|
||||||
|
$token = $this->getTokenFromRequest($request);
|
||||||
|
|
||||||
|
if (!is_string($request->session()->token())) {
|
||||||
|
throw new TokenMismatchException('CSRF session token missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_string($token)) {
|
||||||
|
throw new TokenMismatchException('CSRF request token missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
return hash_equals($request->session()->token(), $token);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTokenFromRequest($request)
|
||||||
|
{
|
||||||
|
$token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN');
|
||||||
|
|
||||||
|
if (!$token && $header = $request->header('X-XSRF-TOKEN')) {
|
||||||
|
try {
|
||||||
|
$token = $this->encrypter->decrypt($header);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $token;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreUserRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|email|max:255|unique:users',
|
||||||
|
'password' => 'required|string|min:8|confirmed',
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->isMahasiswa()) {
|
||||||
|
$rules = array_merge($rules, [
|
||||||
|
'nim' => 'required|string|max:20|unique:mahasiswas,nim',
|
||||||
|
'program_studi' => 'required|string|max:100',
|
||||||
|
'jurusan' => 'required|string|max:100',
|
||||||
|
'no_hp' => 'required|string|max:15|regex:/^[0-9]+$/',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'required' => ':attribute wajib diisi',
|
||||||
|
'email' => 'Format email tidak valid',
|
||||||
|
'unique' => ':attribute sudah terdaftar',
|
||||||
|
'min' => ':attribute minimal :min karakter',
|
||||||
|
'confirmed' => 'Konfirmasi password tidak cocok',
|
||||||
|
'no_hp.regex' => 'Nomor HP hanya boleh berisi angka',
|
||||||
|
|
||||||
|
// Specific field messages
|
||||||
|
'nim.required' => 'NIM wajib diisi',
|
||||||
|
'nim.unique' => 'NIM sudah terdaftar',
|
||||||
|
'program_studi.required' => 'Program studi wajib diisi',
|
||||||
|
'jurusan.required' => 'Jurusan wajib diisi',
|
||||||
|
'no_hp.required' => 'Nomor HP wajib diisi',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'Nama lengkap',
|
||||||
|
'email' => 'Alamat email',
|
||||||
|
'password' => 'Password',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function isMahasiswa()
|
||||||
|
{
|
||||||
|
return $this->input('force_mahasiswa') || $this->input('role') === 'mahasiswa';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class UpdateUserRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$userId = $this->route('user'); // Get user ID from route parameter
|
||||||
|
$rules = [
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'email' => 'required|email|max:255|unique:users,email,'.$userId,
|
||||||
|
'alamat' => 'required|string|max:255',
|
||||||
|
'telepon' => 'required|string|max:20',
|
||||||
|
'keterangan' => 'required|string|max:255',
|
||||||
|
'role' => 'required|in:admin,mahasiswa,karyawan'
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->role === 'mahasiswa') {
|
||||||
|
$user = User::with('mahasiswa')->find($userId);
|
||||||
|
$mahasiswaId = $user->mahasiswa ? $user->mahasiswa->user_id : 'NULL';
|
||||||
|
|
||||||
|
$rules += [
|
||||||
|
'nim' => 'required|string|max:20|unique:mahasiswas,nim,'.$mahasiswaId.',user_id',
|
||||||
|
'program_studi' => 'required|string|max:100',
|
||||||
|
'jurusan' => 'required|string|max:100',
|
||||||
|
'no_hp' => 'required|string|max:15|regex:/^[0-9]+$/',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function messages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'required' => ':attribute wajib diisi',
|
||||||
|
'email' => 'Format email tidak valid',
|
||||||
|
'unique' => ':attribute sudah terdaftar',
|
||||||
|
'in' => ':attribute tidak valid',
|
||||||
|
'no_hp.regex' => 'Nomor HP hanya boleh berisi angka',
|
||||||
|
|
||||||
|
// Specific field messages
|
||||||
|
'nim.required' => 'NIM wajib diisi',
|
||||||
|
'program_studi.required' => 'Program studi wajib diisi',
|
||||||
|
'jurusan.required' => 'Jurusan wajib diisi',
|
||||||
|
'no_hp.required' => 'Nomor HP wajib diisi',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'Nama lengkap',
|
||||||
|
'email' => 'Alamat email',
|
||||||
|
'alamat' => 'Alamat',
|
||||||
|
'telepon' => 'Nomor telepon',
|
||||||
|
'keterangan' => 'Keterangan',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use App\Services\SawCalculationService;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class ProcessRankingJob implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $pengajuanIds;
|
||||||
|
|
||||||
|
public function __construct(array $pengajuanIds)
|
||||||
|
{
|
||||||
|
$this->pengajuanIds = $pengajuanIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(SawCalculationService $sawService)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$result = $sawService->processBatch($this->pengajuanIds);
|
||||||
|
|
||||||
|
Log::info('Ranking job completed', [
|
||||||
|
'processed_count' => $result['success_count'],
|
||||||
|
'error_count' => $result['error_count'],
|
||||||
|
'total_ids' => count($this->pengajuanIds)
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('Ranking job failed: '.$e->getMessage(), [
|
||||||
|
'exception' => $e,
|
||||||
|
'pengajuan_ids' => $this->pengajuanIds
|
||||||
|
]);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Alternatif extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'alternatif';
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function penilaian()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Penilaian::class, 'alternatif_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Crips extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = "crips";
|
||||||
|
protected $guarded = [];
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Form extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'status_form';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
public $timestamps = true;
|
||||||
|
protected $fillable = [
|
||||||
|
'nama_form',
|
||||||
|
'jenis_form',
|
||||||
|
'semester',
|
||||||
|
'status',
|
||||||
|
'tanggal_pembuatan',
|
||||||
|
'kuota_penurunan',
|
||||||
|
'kuota_pengangsuran',
|
||||||
|
'tahun',
|
||||||
|
'tanggal_pembukaan',
|
||||||
|
'tanggal_penutupan',
|
||||||
|
'tanggal_verifikasi',
|
||||||
|
'tanggal_pengumuman'
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'tanggal_pembuatan' => 'datetime',
|
||||||
|
'created_at' => 'datetime',
|
||||||
|
'updated_at' => 'datetime',
|
||||||
|
'tanggal_pembukaan' => 'datetime',
|
||||||
|
'tanggal_penutupan' => 'datetime',
|
||||||
|
'tanggal_verifikasi' => 'datetime',
|
||||||
|
'tanggal_pengumuman' => 'datetime'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getStatusBadgeAttribute()
|
||||||
|
{
|
||||||
|
return $this->status == 'Dibuka'
|
||||||
|
? '<span class="badge badge-success">Dibuka</span>'
|
||||||
|
: '<span class="badge badge-danger">Ditutup</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getKodeSemesterAttribute()
|
||||||
|
{
|
||||||
|
return $this->semester . '-' . $this->tahun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTahunAkademikAttribute()
|
||||||
|
{
|
||||||
|
if ($this->semester == 'Ganjil') {
|
||||||
|
return $this->tahun . '/' . ($this->tahun + 1);
|
||||||
|
}
|
||||||
|
return ($this->tahun - 1) . '/' . $this->tahun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pengajuan()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PengajuanUkt::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canSubmit($mahasiswaId)
|
||||||
|
{
|
||||||
|
$existing = $this->pengajuan()
|
||||||
|
->where('mahasiswa_id', $mahasiswaId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
return !$existing || $existing->status_validasi === 'tidak valid';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKuotaAttribute()
|
||||||
|
{
|
||||||
|
return $this->jenis_form == 'penurunan'
|
||||||
|
? $this->kuota_penurunan
|
||||||
|
: $this->kuota_pengangsuran;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class HasilPenilaian extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'hasil_penilaian';
|
||||||
|
protected $fillable = [
|
||||||
|
'pengajuan_id',
|
||||||
|
'nilai_preferensi',
|
||||||
|
'rekomendasi_ukt',
|
||||||
|
'keterangan',
|
||||||
|
'processed_by',
|
||||||
|
'ukt_penyesuaian',
|
||||||
|
'status_penyesuaian'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = ['ukt_formatted', 'budget_formatted']; // Menambahkan accessor formatted
|
||||||
|
|
||||||
|
public function pengajuan()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(PengajuanUkt::class, 'pengajuan_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processor()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'processed_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeTopRanking($query, $limit = 50)
|
||||||
|
{
|
||||||
|
return $query->orderBy('nilai_preferensi', 'desc')
|
||||||
|
->limit($limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUktFormattedAttribute()
|
||||||
|
{
|
||||||
|
return 'Rp' . number_format($this->ukt_penyesuaian, 0, ',', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeForForm($query, $formId)
|
||||||
|
{
|
||||||
|
return $query->whereHas('pengajuan', function($q) use ($formId) {
|
||||||
|
$q->where('status_form_id', $formId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateBudget($amount)
|
||||||
|
{
|
||||||
|
if (!is_numeric($amount)) {
|
||||||
|
throw new \InvalidArgumentException('Budget harus berupa angka');
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::query()->update(['keterangan' => $amount]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to get current budget (from keterangan column)
|
||||||
|
public static function getCurrentBudget()
|
||||||
|
{
|
||||||
|
$record = self::first();
|
||||||
|
return $record && !empty($record->keterangan) ? (float)$record->keterangan : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accessor for formatted budget display
|
||||||
|
public function getBudgetFormattedAttribute()
|
||||||
|
{
|
||||||
|
return 'Rp' . number_format($this->keterangan, 0, ',', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Virtual budget attribute for compatibility
|
||||||
|
public function getBudgetAttribute()
|
||||||
|
{
|
||||||
|
return $this->keterangan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBudgetAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['keterangan'] = $value;
|
||||||
|
}}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Kriteria extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'kriteria';
|
||||||
|
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'nama_kriteria',
|
||||||
|
'attribut',
|
||||||
|
'bobot'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function subKriteria()
|
||||||
|
{
|
||||||
|
return $this->hasMany(SubKriteria::class, 'kriteria_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Mahasiswa extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'mahasiswas';
|
||||||
|
|
||||||
|
protected $primaryKey = 'user_id';
|
||||||
|
public $incrementing = false;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'nim',
|
||||||
|
'program_studi',
|
||||||
|
'jurusan',
|
||||||
|
'no_hp'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pengajuan()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PengajuanUkt::class, 'mahasiswa_id', 'user_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class PengajuanDetail extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'pengajuan_details';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'pengajuan_ukt_id',
|
||||||
|
'kriteria_id',
|
||||||
|
'kriteria',
|
||||||
|
'sub_kriteria_id',
|
||||||
|
'subkriteria_text',
|
||||||
|
'file_dokumen',
|
||||||
|
'verified',
|
||||||
|
'verified_by',
|
||||||
|
'verified_at',
|
||||||
|
'rejection_reason'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'verified' => 'boolean',
|
||||||
|
'verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
protected $appends = ['file_url', 'display_kriteria', 'display_subkriteria', 'file_exists'];
|
||||||
|
|
||||||
|
public function pengajuanUkt()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(PengajuanUkt::class, 'pengajuan_ukt_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kriteria()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Kriteria::class, 'kriteria_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function subKriteria()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SubKriteria::class, 'sub_kriteria_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifier()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'verified_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsVerifiedAttribute()
|
||||||
|
{
|
||||||
|
return $this->verified && !is_null($this->verified_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cek ketersediaan file
|
||||||
|
*/
|
||||||
|
public function getFileUrlAttribute()
|
||||||
|
{
|
||||||
|
if (!$this->file_dokumen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle both storage paths
|
||||||
|
$filePath = str_replace('public/', '', $this->file_dokumen);
|
||||||
|
|
||||||
|
if (Storage::disk('public')->exists($filePath)) {
|
||||||
|
return Storage::disk('public')->url($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileExistsAttribute()
|
||||||
|
{
|
||||||
|
if (!$this->file_dokumen) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filePath = str_replace('public/', '', $this->file_dokumen);
|
||||||
|
return Storage::disk('public')->exists($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,180 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class PengajuanUkt extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'pengajuan_ukts';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
protected $attributes = [
|
||||||
|
'status_validasi' => 'menunggu'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'status_validasi' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'mahasiswa_id',
|
||||||
|
'jenis_pengajuan',
|
||||||
|
'status_validasi',
|
||||||
|
'alasan_penolakan',
|
||||||
|
'status_form_id',
|
||||||
|
'ukt_saat_ini',
|
||||||
|
'file_ukt',
|
||||||
|
'file_ukt_valid',
|
||||||
|
'file_ukt_alasan',
|
||||||
|
'alasan_pengajuan'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $appends = ['status', 'semester'];
|
||||||
|
|
||||||
|
// Event untuk handle penghapusan
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
static::deleting(function ($pengajuan) {
|
||||||
|
// Hapus semua relasi terlebih dahulu
|
||||||
|
$pengajuan->hasilPenilaian()->delete();
|
||||||
|
$pengajuan->details()->delete();
|
||||||
|
$pengajuan->dokumen()->delete();
|
||||||
|
|
||||||
|
// Hapus file-file terkait jika ada
|
||||||
|
foreach ($pengajuan->details as $detail) {
|
||||||
|
if ($detail->file_dokumen && Storage::exists('public/'.$detail->file_dokumen)) {
|
||||||
|
Storage::delete('public/'.$detail->file_dokumen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hapus notifikasi terkait pengajuan ini
|
||||||
|
if ($pengajuan->mahasiswa && $pengajuan->mahasiswa->user) {
|
||||||
|
$pengajuan->mahasiswa->user->notifications()
|
||||||
|
->where('data->pengajuan_id', $pengajuan->id)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusAttribute()
|
||||||
|
{
|
||||||
|
return $this->attributes['status_validasi'] ?? 'menunggu';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStatusAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['status_validasi'] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mahasiswa()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Mahasiswa::class, 'mahasiswa_id', 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasilPenilaian()
|
||||||
|
{
|
||||||
|
return $this->hasOne(HasilPenilaian::class, 'pengajuan_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function details()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PengajuanDetail::class, 'pengajuan_ukt_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validator()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'validator_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dokumen()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PengajuanDetail::class, 'pengajuan_ukt_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Form::class, 'status_form_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isDibuka()
|
||||||
|
{
|
||||||
|
return $this->form->status === 'Dibuka';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isDitutup()
|
||||||
|
{
|
||||||
|
return optional($this->form)->status === 'Ditutup';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPenurunan()
|
||||||
|
{
|
||||||
|
return $this->jenis_pengajuan === 'penurunan';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isPengangsuran()
|
||||||
|
{
|
||||||
|
return $this->jenis_pengajuan === 'pengangsuran';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isMenunggu()
|
||||||
|
{
|
||||||
|
return $this->getStatusAttribute() === 'menunggu';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isValid()
|
||||||
|
{
|
||||||
|
return $this->getStatusAttribute() === 'valid';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isTidakValid()
|
||||||
|
{
|
||||||
|
return $this->getStatusAttribute() === 'tidak valid';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function scopeMenunggu($query)
|
||||||
|
{
|
||||||
|
return $query->where('status_validasi', 'menunggu');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeValid($query)
|
||||||
|
{
|
||||||
|
return $query->where('status_validasi', 'valid');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeTidakValid($query)
|
||||||
|
{
|
||||||
|
return $query->where('status_validasi', 'tidak valid');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopePenurunan($query)
|
||||||
|
{
|
||||||
|
return $query->where('jenis_pengajuan', 'penurunan');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopePengangsuran($query)
|
||||||
|
{
|
||||||
|
return $query->where('jenis_pengajuan', 'pengangsuran');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSemesterAttribute()
|
||||||
|
{
|
||||||
|
return optional($this->form)->semester;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUktSaatIniAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['ukt_saat_ini'] = (int) str_replace('.', '', $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUktFormattedAttribute()
|
||||||
|
{
|
||||||
|
return number_format($this->ukt_saat_ini, 0, ',', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Penilaian extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $table = 'penilaian';
|
||||||
|
protected $guarded = [];
|
||||||
|
|
||||||
|
public function crips()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Crips::class, 'crips_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function alternatif()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Alternatif::class, 'alternatif_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class RankingFile extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
protected $fillable = ['path'];
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class SubKriteria extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'sub_kriterias';
|
||||||
|
protected $primaryKey = 'id';
|
||||||
|
|
||||||
|
protected $fillable = ['kriteria_id', 'nama_subkriteria', 'nilai'];
|
||||||
|
protected $casts = ['nilai' => 'integer'];
|
||||||
|
|
||||||
|
public function kriteria()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Kriteria::class, 'kriteria_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function penilaian()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Penilaian::class, 'sub_kriteria_id');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Laravel\Sanctum\HasApiTokens;
|
||||||
|
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
use HasApiTokens, HasFactory, Notifiable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
'alamat',
|
||||||
|
'telepon',
|
||||||
|
'role',
|
||||||
|
'keterangan'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'email_verified_at' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function mahasiswa()
|
||||||
|
{
|
||||||
|
return $this->hasOne(Mahasiswa::class, 'user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isMahasiswa()
|
||||||
|
{
|
||||||
|
return $this->role === 'mahasiswa';
|
||||||
|
}
|
||||||
|
protected $attributes = [
|
||||||
|
'role' => 'mahasiswa',
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class PengajuanDitolakNotification extends Notification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
protected $pengajuan;
|
||||||
|
protected $alasan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @param mixed $pengajuan
|
||||||
|
* @param string $alasan
|
||||||
|
*/
|
||||||
|
public function __construct($pengajuan, $alasan)
|
||||||
|
{
|
||||||
|
$this->pengajuan = $pengajuan;
|
||||||
|
$this->alasan = $alasan;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data yang akan disimpan di database
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class PengajuanHasilFinalNotification extends Notification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
protected $pengajuan;
|
||||||
|
|
||||||
|
public function __construct($pengajuan)
|
||||||
|
{
|
||||||
|
$this->pengajuan = $pengajuan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toDatabase($notifiable)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class PengajuanValidNotification extends Notification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
protected $pengajuan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @param mixed $pengajuan
|
||||||
|
*/
|
||||||
|
public function __construct($pengajuan)
|
||||||
|
{
|
||||||
|
$this->pengajuan = $pengajuan;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data yang akan disimpan di database
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Pagination\Paginator;
|
||||||
|
use App\Services\SawCalculationService;
|
||||||
|
|
||||||
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->singleton(SawCalculationService::class, function ($app) {
|
||||||
|
return new SawCalculationService();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Paginator::useBootstrap();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
|
class AuthServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The policy mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, class-string>
|
||||||
|
*/
|
||||||
|
protected $policies = [
|
||||||
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any authentication / authorization services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerPolicies();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Broadcast;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
|
class BroadcastServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
Broadcast::routes();
|
||||||
|
|
||||||
|
require base_path('routes/channels.php');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
|
class EventServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The event listener mappings for the application.
|
||||||
|
*
|
||||||
|
* @var array<class-string, array<int, class-string>>
|
||||||
|
*/
|
||||||
|
protected $listen = [
|
||||||
|
Registered::class => [
|
||||||
|
SendEmailVerificationNotification::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register any events for your application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Cache\RateLimiting\Limit;
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Subkriteria;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The path to the "home" route for your application.
|
||||||
|
*
|
||||||
|
* This is used by Laravel authentication to redirect users after login.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public const HOME = '/redirect';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The controller namespace for the application.
|
||||||
|
*
|
||||||
|
* When present, controller route declarations will automatically be prefixed with this namespace.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
// protected $namespace = 'App\\Http\\Controllers';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define your route model bindings, pattern filters, etc.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->configureRateLimiting();
|
||||||
|
|
||||||
|
$this->routes(function () {
|
||||||
|
Route::prefix('api')
|
||||||
|
->middleware('api')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/api.php'));
|
||||||
|
|
||||||
|
Route::middleware('web')
|
||||||
|
->namespace($this->namespace)
|
||||||
|
->group(base_path('routes/web.php'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the rate limiters for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function configureRateLimiting()
|
||||||
|
{
|
||||||
|
RateLimiter::for('api', function (Request $request) {
|
||||||
|
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configureModelBindings()
|
||||||
|
{
|
||||||
|
// Binding untuk Kriteria
|
||||||
|
Route::model('kriteria', Kriteria::class);
|
||||||
|
|
||||||
|
// Binding untuk Subkriteria
|
||||||
|
Route::model('subkriteria', Subkriteria::class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\PengajuanUkt;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\HasilPenilaian;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class SawCalculationService
|
||||||
|
{
|
||||||
|
protected $kriteria;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->kriteria = Kriteria::with('subKriteria')->orderBy('id')->get();
|
||||||
|
|
||||||
|
if ($this->kriteria->isEmpty()) {
|
||||||
|
throw new Exception('Tidak ada kriteria untuk perhitungan');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calculate(PengajuanUkt $pengajuan): array
|
||||||
|
{
|
||||||
|
// Cek apakah total bobot valid (== 1)
|
||||||
|
$totalBobot = $this->kriteria->sum('bobot');
|
||||||
|
if (abs($totalBobot - 1) > 0.0001) {
|
||||||
|
throw new Exception("Total bobot saat ini adalah ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($pengajuan->status_validasi !== 'valid') {
|
||||||
|
throw new Exception("Pengajuan belum divalidasi");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($pengajuan->details->isEmpty()) {
|
||||||
|
throw new Exception("Data detail pengajuan tidak lengkap");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Decision Matrix
|
||||||
|
$decisionMatrix = $this->buildDecisionMatrix($pengajuan);
|
||||||
|
|
||||||
|
// 2. Normalized Matrix
|
||||||
|
$normalizedMatrix = $this->normalizeMatrix($decisionMatrix);
|
||||||
|
|
||||||
|
// 3. Preference Value
|
||||||
|
$preferenceValue = $this->calculatePreferenceValue($normalizedMatrix);
|
||||||
|
|
||||||
|
// 4. Recommendation
|
||||||
|
$recommendation = $this->determineRecommendation($pengajuan->jenis_pengajuan, $preferenceValue);
|
||||||
|
|
||||||
|
// 5. Save Result
|
||||||
|
$this->saveResult($pengajuan, $preferenceValue, $recommendation);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'decision_matrix' => $decisionMatrix,
|
||||||
|
'normalized_matrix' => $normalizedMatrix,
|
||||||
|
'preference_value' => $preferenceValue,
|
||||||
|
'recommendation' => $recommendation,
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
Log::error("Error pada perhitungan SAW: " . $e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function determineRecommendation(string $jenisPengajuan, float $preferenceValue): string
|
||||||
|
{
|
||||||
|
if ($jenisPengajuan === 'penurunan') {
|
||||||
|
return ($preferenceValue >= 0.65) ? 'Dapat Penurunan UKT' : 'UKT Tetap';
|
||||||
|
}
|
||||||
|
elseif ($jenisPengajuan === 'pengangsuran') {
|
||||||
|
return ($preferenceValue >= 0.75) ? 'Dapat Pengangsuran UKT' : 'Tidak Dapat Mengangsur';
|
||||||
|
}
|
||||||
|
return 'UKT Tetap';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processBatch(array $pengajuanIds): array
|
||||||
|
{
|
||||||
|
$successCount = 0;
|
||||||
|
$errorCount = 0;
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
foreach ($pengajuanIds as $id) {
|
||||||
|
try {
|
||||||
|
$pengajuan = PengajuanUkt::findOrFail($id);
|
||||||
|
$this->calculate($pengajuan);
|
||||||
|
$successCount++;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$errorCount++;
|
||||||
|
$errors[$id] = $e->getMessage();
|
||||||
|
Log::error("Gagal memproses pengajuan ID {$id}: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'status' => $errorCount === 0 ? 'success' : ($successCount > 0 ? 'partial' : 'failed'),
|
||||||
|
'message' => "Berhasil memproses {$successCount} dari " . count($pengajuanIds) . " pengajuan",
|
||||||
|
'success_count' => $successCount,
|
||||||
|
'error_count' => $errorCount,
|
||||||
|
'errors' => $errors
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildDecisionMatrix(PengajuanUkt $pengajuan): array
|
||||||
|
{
|
||||||
|
$decisionMatrix = [];
|
||||||
|
|
||||||
|
foreach ($this->kriteria as $kriteria) {
|
||||||
|
$detail = $pengajuan->details->firstWhere('kriteria_id', $kriteria->id);
|
||||||
|
if (!$detail) {
|
||||||
|
Log::error("Missing detail for kriteria: {$kriteria->nama_kriteria}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub = $kriteria->subKriteria->firstWhere('id', $detail->sub_kriteria_id);
|
||||||
|
if (!$sub) {
|
||||||
|
Log::error("Missing subkriteria for detail: {$detail->id}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$decisionMatrix[$kriteria->id] = $sub->nilai;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($decisionMatrix) !== count($this->kriteria)) {
|
||||||
|
throw new Exception("Data kriteria tidak lengkap");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $decisionMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function normalizeMatrix(array $decisionMatrix): array
|
||||||
|
{
|
||||||
|
$normalizedMatrix = [];
|
||||||
|
|
||||||
|
foreach ($this->kriteria as $kriteria) {
|
||||||
|
$nilai = $decisionMatrix[$kriteria->id];
|
||||||
|
$allNilai = $kriteria->subKriteria->pluck('nilai')->toArray();
|
||||||
|
|
||||||
|
if (empty($allNilai)) {
|
||||||
|
throw new Exception("Subkriteria untuk kriteria ID {$kriteria->id} kosong");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strtolower($kriteria->attribut) === 'benefit') {
|
||||||
|
$max = max($allNilai);
|
||||||
|
$value = $max != 0 ? ($nilai / $max) : 0;
|
||||||
|
} else { // COST
|
||||||
|
$min = min($allNilai);
|
||||||
|
$value = $nilai != 0 ? ($min / $nilai) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$normalizedMatrix[$kriteria->id] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $normalizedMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function calculatePreferenceValue(array $normalizedMatrix): float
|
||||||
|
{
|
||||||
|
$preferenceValue = 0;
|
||||||
|
|
||||||
|
foreach ($this->kriteria as $kriteria) {
|
||||||
|
$bobot = $kriteria->bobot;
|
||||||
|
$nilaiNormalisasi = $normalizedMatrix[$kriteria->id];
|
||||||
|
|
||||||
|
$preferenceValue += $bobot * $nilaiNormalisasi;
|
||||||
|
}
|
||||||
|
|
||||||
|
return round($preferenceValue, 5, PHP_ROUND_HALF_EVEN);
|
||||||
|
}
|
||||||
|
protected function saveResult(PengajuanUkt $pengajuan, float $preferenceValue, string $recommendation): void
|
||||||
|
{
|
||||||
|
HasilPenilaian::updateOrCreate(
|
||||||
|
['pengajuan_id' => $pengajuan->id],
|
||||||
|
[
|
||||||
|
'nilai_preferensi' => $preferenceValue,
|
||||||
|
'rekomendasi_ukt' => $recommendation,
|
||||||
|
'keterangan' => null,
|
||||||
|
'processed_by' => auth()->id(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prosesPerhitunganLengkap(array $pengajuanIds): array
|
||||||
|
{
|
||||||
|
return $this->processBatch($pengajuanIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCalculationDetails($pengajuanId)
|
||||||
|
{
|
||||||
|
$pengajuan = PengajuanUkt::with('details.subKriteria')->findOrFail($pengajuanId);
|
||||||
|
|
||||||
|
// Rebuild the calculation to ensure consistency
|
||||||
|
$decisionMatrix = $this->buildDecisionMatrix($pengajuan);
|
||||||
|
$normalizedMatrix = $this->normalizeMatrix($decisionMatrix);
|
||||||
|
$preferenceValue = $this->calculatePreferenceValue($normalizedMatrix);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'decision_matrix' => $decisionMatrix,
|
||||||
|
'normalized_matrix' => $normalizedMatrix,
|
||||||
|
'preference_value' => $pengajuan->hasilPenilaian->nilai_preferensi,
|
||||||
|
'recommendation' => $pengajuan->hasilPenilaian->rekomendasi_ukt,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define('LARAVEL_START', microtime(true));
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Register The Auto Loader
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Composer provides a convenient, automatically generated class loader
|
||||||
|
| for our application. We just need to utilize it! We'll require it
|
||||||
|
| into the script here so that we do not have to worry about the
|
||||||
|
| loading of any of our classes manually. It's great to relax.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run The Artisan Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When we run the console application, the current CLI command will be
|
||||||
|
| executed in this console and the response sent back to a terminal
|
||||||
|
| or another output device for the developers. Here goes nothing!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||||
|
|
||||||
|
$status = $kernel->handle(
|
||||||
|
$input = new Symfony\Component\Console\Input\ArgvInput,
|
||||||
|
new Symfony\Component\Console\Output\ConsoleOutput
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Shutdown The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Once Artisan has finished running, we will fire off the shutdown events
|
||||||
|
| so that any final work may be done by the application before we shut
|
||||||
|
| down the process. This is the last thing to happen to the request.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$kernel->terminate($input, $status);
|
||||||
|
|
||||||
|
exit($status);
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Create The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The first thing we will do is create a new Laravel application instance
|
||||||
|
| which serves as the "glue" for all the components of Laravel, and is
|
||||||
|
| the IoC container for the system binding all of the various parts.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app = new Illuminate\Foundation\Application(
|
||||||
|
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Bind Important Interfaces
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, we need to bind some important interfaces into the container so
|
||||||
|
| we will be able to resolve them when needed. The kernels serve the
|
||||||
|
| incoming requests to this application from both the web and CLI.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Http\Kernel::class,
|
||||||
|
App\Http\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Console\Kernel::class,
|
||||||
|
App\Console\Kernel::class
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->singleton(
|
||||||
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||||
|
App\Exceptions\Handler::class
|
||||||
|
);
|
||||||
|
|
||||||
|
// $app->register(\Barryvdh\DomPDF\ServiceProvider::class);
|
||||||
|
// $app->configure('dompdf');
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Return The Application
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This script returns the application instance. The instance is given to
|
||||||
|
| the calling script so we can separate the building of the instances
|
||||||
|
| from the actual running of the application and sending responses.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return $app;
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
"name": "laravel/laravel",
|
||||||
|
"type": "project",
|
||||||
|
"description": "The Laravel Framework.",
|
||||||
|
"keywords": ["framework", "laravel"],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": "^8.0",
|
||||||
|
"barryvdh/laravel-dompdf": "^2.0",
|
||||||
|
"fruitcake/laravel-cors": "3.0",
|
||||||
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
|
"laravel/framework": "^9.0",
|
||||||
|
"laravel/sanctum": "3.0",
|
||||||
|
"laravel/tinker": "^2.7",
|
||||||
|
"laravel/ui": "^4.2",
|
||||||
|
"maatwebsite/excel": "^3.1",
|
||||||
|
"nesbot/carbon": "^2.68",
|
||||||
|
"spatie/laravel-backup": "^8.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-debugbar": "^3.15",
|
||||||
|
"fakerphp/faker": "^1.9.1",
|
||||||
|
"laravel/sail": "^1.0.1",
|
||||||
|
"mockery/mockery": "^1.4.4",
|
||||||
|
"nunomaduro/collision": "^6.1",
|
||||||
|
"phpunit/phpunit": "^9.5.10",
|
||||||
|
"spatie/laravel-ignition": "^1.7",
|
||||||
|
"symfony/var-dumper": "^6.4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "app/",
|
||||||
|
"Database\\Factories\\": "database/factories/",
|
||||||
|
"Database\\Seeders\\": "database/seeders/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"app/Helpers/helpers.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"dont-discover": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"optimize-autoloader": true,
|
||||||
|
"preferred-install": "dist",
|
||||||
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,198 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Facade;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value is the name of your application. This value is used when the
|
||||||
|
| framework needs to place the application's name in a notification or
|
||||||
|
| any other location as required by the application or its packages.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'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
|
||||||
|
| your application so that it is used when running Artisan tasks.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
|
'asset_url' => env('ASSET_URL', null),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Timezone
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the default timezone for your application, which
|
||||||
|
| will be used by the PHP date and date-time functions. We have gone
|
||||||
|
| ahead and set this to a sensible default for you out of the box.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'timezone' => 'Asia/Jakarta',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Locale Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The application locale determines the default locale that will be used
|
||||||
|
| by the translation service provider. You are free to set this value
|
||||||
|
| to any of the locales which will be supported by the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'locale' => 'id',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Fallback Locale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The fallback locale determines the locale to use when the current one
|
||||||
|
| is not available. You may change the value to correspond to any of
|
||||||
|
| the language folders that are provided through your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'fallback_locale' => 'en',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Faker Locale
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This locale will be used by the Faker PHP library when generating fake
|
||||||
|
| data for your database seeds. For example, this will be used to get
|
||||||
|
| localized telephone numbers, street address information and more.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'faker_locale' => 'id_ID',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Encryption Key
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This key is used by the Illuminate encrypter service and should be set
|
||||||
|
| to a random, 32 character string, otherwise these encrypted strings
|
||||||
|
| will not be safe. Please do this before deploying an application!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'key' => env('APP_KEY'),
|
||||||
|
|
||||||
|
'cipher' => 'AES-256-CBC',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Autoloaded Service Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The service providers listed here will be automatically loaded on the
|
||||||
|
| request to your application. Feel free to add your own services to
|
||||||
|
| this array to grant expanded functionality to your applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Laravel Framework Service Providers...
|
||||||
|
*/
|
||||||
|
Illuminate\Auth\AuthServiceProvider::class,
|
||||||
|
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||||
|
Illuminate\Bus\BusServiceProvider::class,
|
||||||
|
Illuminate\Cache\CacheServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||||
|
Illuminate\Cookie\CookieServiceProvider::class,
|
||||||
|
Illuminate\Database\DatabaseServiceProvider::class,
|
||||||
|
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||||
|
Illuminate\Filesystem\FilesystemServiceProvider::class,
|
||||||
|
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
|
||||||
|
Illuminate\Hashing\HashServiceProvider::class,
|
||||||
|
Illuminate\Mail\MailServiceProvider::class,
|
||||||
|
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||||
|
Illuminate\Pagination\PaginationServiceProvider::class,
|
||||||
|
Illuminate\Pipeline\PipelineServiceProvider::class,
|
||||||
|
Illuminate\Queue\QueueServiceProvider::class,
|
||||||
|
Illuminate\Redis\RedisServiceProvider::class,
|
||||||
|
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
|
||||||
|
Illuminate\Session\SessionServiceProvider::class,
|
||||||
|
Illuminate\Translation\TranslationServiceProvider::class,
|
||||||
|
Illuminate\Validation\ValidationServiceProvider::class,
|
||||||
|
Illuminate\View\ViewServiceProvider::class,
|
||||||
|
Barryvdh\DomPDF\ServiceProvider::class,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Package Service Providers...
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Application Service Providers...
|
||||||
|
*/
|
||||||
|
App\Providers\AppServiceProvider::class,
|
||||||
|
App\Providers\AuthServiceProvider::class,
|
||||||
|
// App\Providers\BroadcastServiceProvider::class,
|
||||||
|
App\Providers\EventServiceProvider::class,
|
||||||
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Class Aliases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This array of class aliases will be registered when this application
|
||||||
|
| is started. However, feel free to register as many as you wish as
|
||||||
|
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'aliases' => Facade::defaultAliases()->merge([
|
||||||
|
'PDF' => Barryvdh\DomPDF\Facade::class,
|
||||||
|
])->toArray(),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,111 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Defaults
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default authentication "guard" and password
|
||||||
|
| reset options for your application. You may change these defaults
|
||||||
|
| as required, but they're a perfect start for most applications.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'defaults' => [
|
||||||
|
'guard' => 'web',
|
||||||
|
'passwords' => 'users',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Authentication Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Next, you may define every authentication guard for your application.
|
||||||
|
| Of course, a great default configuration has been defined for you
|
||||||
|
| here which uses session storage and the Eloquent user provider.
|
||||||
|
|
|
||||||
|
| All authentication drivers have a user provider. This defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| mechanisms used by this application to persist your user's data.
|
||||||
|
|
|
||||||
|
| Supported: "session"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guards' => [
|
||||||
|
'web' => [
|
||||||
|
'driver' => 'session',
|
||||||
|
'provider' => 'users',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| User Providers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| All authentication drivers have a user provider. This defines how the
|
||||||
|
| users are actually retrieved out of your database or other storage
|
||||||
|
| mechanisms used by this application to persist your user's data.
|
||||||
|
|
|
||||||
|
| If you have multiple user tables or models you may configure multiple
|
||||||
|
| sources which represent each model / table. These sources may then
|
||||||
|
| be assigned to any extra authentication guards you have defined.
|
||||||
|
|
|
||||||
|
| Supported: "database", "eloquent"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'providers' => [
|
||||||
|
'users' => [
|
||||||
|
'driver' => 'eloquent',
|
||||||
|
'model' => App\Models\User::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
// 'users' => [
|
||||||
|
// 'driver' => 'database',
|
||||||
|
// 'table' => 'users',
|
||||||
|
// ],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Resetting Passwords
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You may specify multiple password reset configurations if you have more
|
||||||
|
| than one user table or model in the application and you want to have
|
||||||
|
| separate password reset settings based on the specific user types.
|
||||||
|
|
|
||||||
|
| The expire 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.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'passwords' => [
|
||||||
|
'users' => [
|
||||||
|
'provider' => 'users',
|
||||||
|
'table' => 'password_resets',
|
||||||
|
'expire' => 60,
|
||||||
|
'throttle' => 60,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Password Confirmation Timeout
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define the amount of seconds before a password confirmation
|
||||||
|
| times out and the user is prompted to re-enter their password via the
|
||||||
|
| confirmation screen. By default, the timeout lasts for three hours.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'password_timeout' => 10800,
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'backup' => [
|
||||||
|
'name' => env('APP_NAME', 'spk-saw'), // Ganti dengan nama aplikasi Anda
|
||||||
|
|
||||||
|
'source' => [
|
||||||
|
'files' => [
|
||||||
|
'include' => [
|
||||||
|
base_path('.env'),
|
||||||
|
base_path('app/'),
|
||||||
|
base_path('config/'),
|
||||||
|
base_path('database/'),
|
||||||
|
base_path('resources/'),
|
||||||
|
base_path('routes/'),
|
||||||
|
],
|
||||||
|
'exclude' => [
|
||||||
|
base_path('vendor'),
|
||||||
|
base_path('node_modules'),
|
||||||
|
base_path('storage'),
|
||||||
|
base_path('tests'),
|
||||||
|
],
|
||||||
|
'follow_links' => false,
|
||||||
|
'ignore_unreadable_directories' => true,
|
||||||
|
'relative_path' => base_path(),
|
||||||
|
],
|
||||||
|
|
||||||
|
'databases' => [
|
||||||
|
'mysql' => [
|
||||||
|
'dump' => [
|
||||||
|
'useSingleTransaction' => true,
|
||||||
|
'timeout' => 300, // 5 menit
|
||||||
|
'excludeTables' => [
|
||||||
|
'failed_jobs', // Tabel yang tidak perlu dibackup
|
||||||
|
'password_resets',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'destination' => [
|
||||||
|
'filename_prefix' => 'spk-saw-backup-', // Sesuaikan
|
||||||
|
'disks' => ['local', 'google'], // Tambahkan disk cloud jika perlu
|
||||||
|
],
|
||||||
|
|
||||||
|
'temporary_directory' => storage_path('app/backup-temp'),
|
||||||
|
'password' => env('BACKUP_ARCHIVE_PASSWORD', null),
|
||||||
|
'encryption' => 'default',
|
||||||
|
],
|
||||||
|
|
||||||
|
'notifications' => [
|
||||||
|
'notifications' => [
|
||||||
|
\Spatie\Backup\Notifications\Notifications\BackupHasFailedNotification::class => ['mail'],
|
||||||
|
\Spatie\Backup\Notifications\Notifications\BackupWasSuccessfulNotification::class => [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'mail' => [
|
||||||
|
'to' => env('BACKUP_NOTIFICATION_EMAIL', 'admin@example.com'),
|
||||||
|
'from' => [
|
||||||
|
'address' => env('MAIL_FROM_ADDRESS', 'no-reply@example.com'),
|
||||||
|
'name' => env('MAIL_FROM_NAME', 'SPK-SAW Backup'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'monitor_backups' => [
|
||||||
|
[
|
||||||
|
'name' => env('APP_NAME', 'spk-saw'),
|
||||||
|
'disks' => ['local'],
|
||||||
|
'health_checks' => [
|
||||||
|
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumAgeInDays::class => 1,
|
||||||
|
\Spatie\Backup\Tasks\Monitor\HealthChecks\MaximumStorageInMegabytes::class => 1000,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'cleanup' => [
|
||||||
|
'strategy' => \Spatie\Backup\Tasks\Cleanup\Strategies\DefaultStrategy::class,
|
||||||
|
'default_strategy' => [
|
||||||
|
'keep_all_backups_for_days' => 7,
|
||||||
|
'keep_daily_backups_for_days' => 16,
|
||||||
|
'keep_weekly_backups_for_weeks' => 4,
|
||||||
|
'keep_monthly_backups_for_months' => 6,
|
||||||
|
'keep_yearly_backups_for_years' => 1,
|
||||||
|
'delete_oldest_backups_when_using_more_megabytes_than' => 1000,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Broadcaster
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default broadcaster that will be used by the
|
||||||
|
| framework when an event needs to be broadcast. You may set this to
|
||||||
|
| any of the connections defined in the "connections" array below.
|
||||||
|
|
|
||||||
|
| Supported: "pusher", "ably", "redis", "log", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('BROADCAST_DRIVER', 'null'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Broadcast Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may define all of the broadcast connections that will be used
|
||||||
|
| to broadcast events to other systems or over websockets. Samples of
|
||||||
|
| each available type of connection are provided inside this array.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'pusher' => [
|
||||||
|
'driver' => 'pusher',
|
||||||
|
'key' => env('PUSHER_APP_KEY'),
|
||||||
|
'secret' => env('PUSHER_APP_SECRET'),
|
||||||
|
'app_id' => env('PUSHER_APP_ID'),
|
||||||
|
'options' => [
|
||||||
|
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||||
|
'useTLS' => true,
|
||||||
|
],
|
||||||
|
'client_options' => [
|
||||||
|
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'ably' => [
|
||||||
|
'driver' => 'ably',
|
||||||
|
'key' => env('ABLY_KEY'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
'driver' => 'redis',
|
||||||
|
'connection' => 'default',
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'driver' => 'log',
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'null',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default cache connection that gets used while
|
||||||
|
| using this caching library. This connection is used when another is
|
||||||
|
| not explicitly specified when executing a given caching function.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('CACHE_DRIVER', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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: "apc", "array", "database", "file",
|
||||||
|
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stores' => [
|
||||||
|
|
||||||
|
'apc' => [
|
||||||
|
'driver' => 'apc',
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'driver' => 'array',
|
||||||
|
'serialize' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'table' => 'cache',
|
||||||
|
'connection' => null,
|
||||||
|
'lock_connection' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'file' => [
|
||||||
|
'driver' => 'file',
|
||||||
|
'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' => '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',
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Key Prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When utilizing a RAM based store such as APC or Memcached, there might
|
||||||
|
| be other applications utilizing the same cache. So, we'll specify a
|
||||||
|
| value to get prefixed to all our keys so we can avoid collisions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cross-Origin Resource Sharing (CORS) Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure your settings for cross-origin resource sharing
|
||||||
|
| or "CORS". This determines what cross-origin operations may execute
|
||||||
|
| in web browsers. You are free to adjust these settings as needed.
|
||||||
|
|
|
||||||
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||||
|
|
||||||
|
'allowed_methods' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins' => ['*'],
|
||||||
|
|
||||||
|
'allowed_origins_patterns' => [],
|
||||||
|
|
||||||
|
'allowed_headers' => ['*'],
|
||||||
|
|
||||||
|
'exposed_headers' => [],
|
||||||
|
|
||||||
|
'max_age' => 0,
|
||||||
|
|
||||||
|
'supports_credentials' => false,
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,147 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Database Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify which of the database connections below you wish
|
||||||
|
| to use as your default connection for all database work. Of course
|
||||||
|
| you may use many connections at once using the Database library.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('DB_CONNECTION', 'mysql'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Database Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here are each of the database connections setup for your application.
|
||||||
|
| Of course, examples of configuring each database platform that is
|
||||||
|
| supported by Laravel is shown below to make development simple.
|
||||||
|
|
|
||||||
|
|
|
||||||
|
| All database work in Laravel is done through the PHP PDO facilities
|
||||||
|
| so make sure you have the driver for your particular database of
|
||||||
|
| choice installed on your machine before you begin development.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sqlite' => [
|
||||||
|
'driver' => 'sqlite',
|
||||||
|
'url' => env('DATABASE_URL'),
|
||||||
|
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||||
|
'prefix' => '',
|
||||||
|
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||||
|
],
|
||||||
|
|
||||||
|
'mysql' => [
|
||||||
|
'driver' => 'mysql',
|
||||||
|
'url' => env('DATABASE_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '3306'),
|
||||||
|
'database' => env('DB_DATABASE', 'forge'),
|
||||||
|
'username' => env('DB_USERNAME', 'forge'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'unix_socket' => env('DB_SOCKET', ''),
|
||||||
|
'charset' => 'utf8mb4',
|
||||||
|
'collation' => 'utf8mb4_unicode_ci',
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'strict' => true,
|
||||||
|
'engine' => null,
|
||||||
|
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||||
|
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||||
|
]) : [],
|
||||||
|
],
|
||||||
|
|
||||||
|
'pgsql' => [
|
||||||
|
'driver' => 'pgsql',
|
||||||
|
'url' => env('DATABASE_URL'),
|
||||||
|
'host' => env('DB_HOST', '127.0.0.1'),
|
||||||
|
'port' => env('DB_PORT', '5432'),
|
||||||
|
'database' => env('DB_DATABASE', 'forge'),
|
||||||
|
'username' => env('DB_USERNAME', 'forge'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
'search_path' => 'public',
|
||||||
|
'sslmode' => 'prefer',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sqlsrv' => [
|
||||||
|
'driver' => 'sqlsrv',
|
||||||
|
'url' => env('DATABASE_URL'),
|
||||||
|
'host' => env('DB_HOST', 'localhost'),
|
||||||
|
'port' => env('DB_PORT', '1433'),
|
||||||
|
'database' => env('DB_DATABASE', 'forge'),
|
||||||
|
'username' => env('DB_USERNAME', 'forge'),
|
||||||
|
'password' => env('DB_PASSWORD', ''),
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'prefix' => '',
|
||||||
|
'prefix_indexes' => true,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 in the database.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'migrations' => 'migrations',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 APC or Memcached. Laravel makes it easy to dig right in.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'redis' => [
|
||||||
|
|
||||||
|
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||||
|
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'default' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_DB', '0'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'cache' => [
|
||||||
|
'url' => env('REDIS_URL'),
|
||||||
|
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||||
|
'password' => env('REDIS_PASSWORD'),
|
||||||
|
'port' => env('REDIS_PORT', '6379'),
|
||||||
|
'database' => env('REDIS_CACHE_DB', '1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,333 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Debugbar Settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Debugbar is enabled by default, when debug is set to true in app.php.
|
||||||
|
| You can override the value by setting enable to true or false instead of null.
|
||||||
|
|
|
||||||
|
| You can provide an array of URI's that must be ignored (eg. 'api/*')
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enabled' => env('DEBUGBAR_ENABLED', null),
|
||||||
|
'hide_empty_tabs' => true, // Hide tabs until they have content
|
||||||
|
'except' => [
|
||||||
|
'telescope*',
|
||||||
|
'horizon*',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Storage settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Debugbar stores data for session/ajax requests.
|
||||||
|
| You can disable this, so the debugbar stores data in headers/session,
|
||||||
|
| but this can cause problems with large data collectors.
|
||||||
|
| By default, file storage (in the storage folder) is used. Redis and PDO
|
||||||
|
| can also be used. For PDO, run the package migrations first.
|
||||||
|
|
|
||||||
|
| Warning: Enabling storage.open will allow everyone to access previous
|
||||||
|
| request, do not enable open storage in publicly available environments!
|
||||||
|
| Specify a callback if you want to limit based on IP or authentication.
|
||||||
|
| Leaving it to null will allow localhost only.
|
||||||
|
*/
|
||||||
|
'storage' => [
|
||||||
|
'enabled' => true,
|
||||||
|
'open' => env('DEBUGBAR_OPEN_STORAGE'), // bool/callback.
|
||||||
|
'driver' => 'file', // redis, file, pdo, socket, custom
|
||||||
|
'path' => storage_path('debugbar'), // For file driver
|
||||||
|
'connection' => null, // Leave null for default connection (Redis/PDO)
|
||||||
|
'provider' => '', // Instance of StorageInterface for custom driver
|
||||||
|
'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver
|
||||||
|
'port' => 2304, // Port to use with the "socket" driver
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Editor
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Choose your preferred editor to use when clicking file name.
|
||||||
|
|
|
||||||
|
| Supported: "phpstorm", "vscode", "vscode-insiders", "vscode-remote",
|
||||||
|
| "vscode-insiders-remote", "vscodium", "textmate", "emacs",
|
||||||
|
| "sublime", "atom", "nova", "macvim", "idea", "netbeans",
|
||||||
|
| "xdebug", "espresso"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'editor' => env('DEBUGBAR_EDITOR') ?: env('IGNITION_EDITOR', 'phpstorm'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Remote Path Mapping
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| If you are using a remote dev server, like Laravel Homestead, Docker, or
|
||||||
|
| even a remote VPS, it will be necessary to specify your path mapping.
|
||||||
|
|
|
||||||
|
| Leaving one, or both of these, empty or null will not trigger the remote
|
||||||
|
| URL changes and Debugbar will treat your editor links as local files.
|
||||||
|
|
|
||||||
|
| "remote_sites_path" is an absolute base path for your sites or projects
|
||||||
|
| in Homestead, Vagrant, Docker, or another remote development server.
|
||||||
|
|
|
||||||
|
| Example value: "/home/vagrant/Code"
|
||||||
|
|
|
||||||
|
| "local_sites_path" is an absolute base path for your sites or projects
|
||||||
|
| on your local computer where your IDE or code editor is running on.
|
||||||
|
|
|
||||||
|
| Example values: "/Users/<name>/Code", "C:\Users\<name>\Documents\Code"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'remote_sites_path' => env('DEBUGBAR_REMOTE_SITES_PATH'),
|
||||||
|
'local_sites_path' => env('DEBUGBAR_LOCAL_SITES_PATH', env('IGNITION_LOCAL_SITES_PATH')),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Vendors
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Vendor files are included by default, but can be set to false.
|
||||||
|
| This can also be set to 'js' or 'css', to only include javascript or css vendor files.
|
||||||
|
| Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
|
||||||
|
| and for js: jquery and highlight.js
|
||||||
|
| So if you want syntax highlighting, set it to true.
|
||||||
|
| jQuery is set to not conflict with existing jQuery scripts.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'include_vendors' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Capture Ajax Requests
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
|
||||||
|
| you can use this option to disable sending the data through the headers.
|
||||||
|
|
|
||||||
|
| Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
|
||||||
|
|
|
||||||
|
| Note for your request to be identified as ajax requests they must either send the header
|
||||||
|
| X-Requested-With with the value XMLHttpRequest (most JS libraries send this), or have application/json as a Accept header.
|
||||||
|
|
|
||||||
|
| By default `ajax_handler_auto_show` is set to true allowing ajax requests to be shown automatically in the Debugbar.
|
||||||
|
| Changing `ajax_handler_auto_show` to false will prevent the Debugbar from reloading.
|
||||||
|
|
|
||||||
|
| You can defer loading the dataset, so it will be loaded with ajax after the request is done. (Experimental)
|
||||||
|
*/
|
||||||
|
|
||||||
|
'capture_ajax' => true,
|
||||||
|
'add_ajax_timing' => false,
|
||||||
|
'ajax_handler_auto_show' => true,
|
||||||
|
'ajax_handler_enable_tab' => true,
|
||||||
|
'defer_datasets' => false,
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Custom Error Handler for Deprecated warnings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When enabled, the Debugbar shows deprecated warnings for Symfony components
|
||||||
|
| in the Messages tab.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'error_handler' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Clockwork integration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The Debugbar can emulate the Clockwork headers, so you can use the Chrome
|
||||||
|
| Extension, without the server-side code. It uses Debugbar collectors instead.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'clockwork' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| DataCollectors
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enable/disable DataCollectors
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'collectors' => [
|
||||||
|
'phpinfo' => false, // Php version
|
||||||
|
'messages' => true, // Messages
|
||||||
|
'time' => true, // Time Datalogger
|
||||||
|
'memory' => true, // Memory usage
|
||||||
|
'exceptions' => true, // Exception displayer
|
||||||
|
'log' => true, // Logs from Monolog (merged in messages if enabled)
|
||||||
|
'db' => true, // Show database (PDO) queries and bindings
|
||||||
|
'views' => true, // Views with their data
|
||||||
|
'route' => false, // Current route information
|
||||||
|
'auth' => false, // Display Laravel authentication status
|
||||||
|
'gate' => true, // Display Laravel Gate checks
|
||||||
|
'session' => false, // Display session data
|
||||||
|
'symfony_request' => true, // Only one can be enabled..
|
||||||
|
'mail' => true, // Catch mail messages
|
||||||
|
'laravel' => true, // Laravel version and environment
|
||||||
|
'events' => false, // All events fired
|
||||||
|
'default_request' => false, // Regular or special Symfony request logger
|
||||||
|
'logs' => false, // Add the latest log messages
|
||||||
|
'files' => false, // Show the included files
|
||||||
|
'config' => false, // Display config settings
|
||||||
|
'cache' => false, // Display cache events
|
||||||
|
'models' => true, // Display models
|
||||||
|
'livewire' => true, // Display Livewire (when available)
|
||||||
|
'jobs' => false, // Display dispatched jobs
|
||||||
|
'pennant' => false, // Display Pennant feature flags
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Extra options
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Configure some DataCollectors
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'time' => [
|
||||||
|
'memory_usage' => false, // Calculated by subtracting memory start and end, it may be inaccurate
|
||||||
|
],
|
||||||
|
'messages' => [
|
||||||
|
'trace' => true, // Trace the origin of the debug message
|
||||||
|
'capture_dumps' => false, // Capture laravel `dump();` as message
|
||||||
|
],
|
||||||
|
'memory' => [
|
||||||
|
'reset_peak' => false, // run memory_reset_peak_usage before collecting
|
||||||
|
'with_baseline' => false, // Set boot memory usage as memory peak baseline
|
||||||
|
'precision' => 0, // Memory rounding precision
|
||||||
|
],
|
||||||
|
'auth' => [
|
||||||
|
'show_name' => true, // Also show the users name/email in the debugbar
|
||||||
|
'show_guards' => true, // Show the guards that are used
|
||||||
|
],
|
||||||
|
'db' => [
|
||||||
|
'with_params' => true, // Render SQL with the parameters substituted
|
||||||
|
'exclude_paths' => [ // Paths to exclude entirely from the collector
|
||||||
|
// 'vendor/laravel/framework/src/Illuminate/Session', // Exclude sessions queries
|
||||||
|
],
|
||||||
|
'backtrace' => true, // Use a backtrace to find the origin of the query in your files.
|
||||||
|
'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults)
|
||||||
|
'timeline' => false, // Add the queries to the timeline
|
||||||
|
'duration_background' => true, // Show shaded background on each query relative to how long it took to execute.
|
||||||
|
'explain' => [ // Show EXPLAIN output on queries
|
||||||
|
'enabled' => false,
|
||||||
|
],
|
||||||
|
'hints' => false, // Show hints for common mistakes
|
||||||
|
'show_copy' => true, // Show copy button next to the query,
|
||||||
|
'slow_threshold' => false, // Only track queries that last longer than this time in ms
|
||||||
|
'memory_usage' => false, // Show queries memory usage
|
||||||
|
'soft_limit' => 100, // After the soft limit, no parameters/backtrace are captured
|
||||||
|
'hard_limit' => 500, // After the hard limit, queries are ignored
|
||||||
|
],
|
||||||
|
'mail' => [
|
||||||
|
'timeline' => true, // Add mails to the timeline
|
||||||
|
'show_body' => true,
|
||||||
|
],
|
||||||
|
'views' => [
|
||||||
|
'timeline' => true, // Add the views to the timeline
|
||||||
|
'data' => false, // True for all data, 'keys' for only names, false for no parameters.
|
||||||
|
'group' => 50, // Group duplicate views. Pass value to auto-group, or true/false to force
|
||||||
|
'exclude_paths' => [ // Add the paths which you don't want to appear in the views
|
||||||
|
'vendor/filament' // Exclude Filament components by default
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'route' => [
|
||||||
|
'label' => true, // Show complete route on bar
|
||||||
|
],
|
||||||
|
'session' => [
|
||||||
|
'hiddens' => [], // Hides sensitive values using array paths
|
||||||
|
],
|
||||||
|
'symfony_request' => [
|
||||||
|
'label' => true, // Show route on bar
|
||||||
|
'hiddens' => [], // Hides sensitive values using array paths, example: request_request.password
|
||||||
|
],
|
||||||
|
'events' => [
|
||||||
|
'data' => false, // Collect events data, listeners
|
||||||
|
],
|
||||||
|
'logs' => [
|
||||||
|
'file' => null,
|
||||||
|
],
|
||||||
|
'cache' => [
|
||||||
|
'values' => true, // Collect cache values
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Inject Debugbar in Response
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Usually, the debugbar is added just before </body>, by listening to the
|
||||||
|
| Response after the App is done. If you disable this, you have to add them
|
||||||
|
| in your template yourself. See http://phpdebugbar.com/docs/rendering.html
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'inject' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Debugbar route prefix
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Sometimes you want to set route prefix to be used by Debugbar to load
|
||||||
|
| its resources from. Usually the need comes from misconfigured web server or
|
||||||
|
| from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'route_prefix' => '_debugbar',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Debugbar route middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Additional middleware to run on the Debugbar routes
|
||||||
|
*/
|
||||||
|
'route_middleware' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Debugbar route domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default Debugbar route served from the same domain that request served.
|
||||||
|
| To override default domain, specify it as a non-empty value.
|
||||||
|
*/
|
||||||
|
'route_domain' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Debugbar theme
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Switches between light and dark theme. If set to auto it will respect system preferences
|
||||||
|
| Possible values: auto, light, dark
|
||||||
|
*/
|
||||||
|
'theme' => env('DEBUGBAR_THEME', 'auto'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Backtrace stack limit
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default, the Debugbar limits the number of frames returned by the 'debug_backtrace()' function.
|
||||||
|
| If you need larger stacktraces, you can increase this number. Setting it to 0 will result in no limit.
|
||||||
|
*/
|
||||||
|
'debug_backtrace_limit' => 50,
|
||||||
|
];
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?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. Just store away!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filesystem Disks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||||
|
| may even configure multiple disks of the same driver. Defaults have
|
||||||
|
| been setup for each driver as an example of the required options.
|
||||||
|
|
|
||||||
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'disks' => [
|
||||||
|
|
||||||
|
'local' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app'),
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'public' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/public'),
|
||||||
|
'url' => env('APP_URL').'/storage',
|
||||||
|
'visibility' => 'public',
|
||||||
|
],
|
||||||
|
|
||||||
|
'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),
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Hash Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default hash driver that will be used to hash
|
||||||
|
| passwords for your application. By default, the bcrypt algorithm is
|
||||||
|
| used; however, you remain free to modify this option if you wish.
|
||||||
|
|
|
||||||
|
| Supported: "bcrypt", "argon", "argon2id"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => 'bcrypt',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Bcrypt Options
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the configuration options that should be used when
|
||||||
|
| passwords are hashed using the Bcrypt algorithm. This will allow you
|
||||||
|
| to control the amount of time it takes to hash the given password.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'bcrypt' => [
|
||||||
|
'rounds' => env('BCRYPT_ROUNDS', 10),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Argon Options
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may specify the configuration options that should be used when
|
||||||
|
| passwords are hashed using the Argon algorithm. These will allow you
|
||||||
|
| to control the amount of time it takes to hash the given password.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'argon' => [
|
||||||
|
'memory' => 65536,
|
||||||
|
'threads' => 1,
|
||||||
|
'time' => 4,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Monolog\Handler\NullHandler;
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Monolog\Handler\SyslogUdpHandler;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Log Channel
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option defines the default log channel that gets used when writing
|
||||||
|
| messages to the logs. The name specified in this option should match
|
||||||
|
| one of the channels defined in the "channels" configuration array.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'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' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log Channels
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the log channels for your application. Out of
|
||||||
|
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||||
|
| you a variety of powerful log handlers / formatters to utilize.
|
||||||
|
|
|
||||||
|
| Available Drivers: "single", "daily", "slack", "syslog",
|
||||||
|
| "errorlog", "monolog",
|
||||||
|
| "custom", "stack"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'channels' => [
|
||||||
|
'stack' => [
|
||||||
|
'driver' => 'stack',
|
||||||
|
'channels' => ['single'],
|
||||||
|
'ignore_exceptions' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'single' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'daily' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'days' => 14,
|
||||||
|
],
|
||||||
|
// ingat pada .env menggunakan LOG_CHANNEL=dailyKey
|
||||||
|
'dailykey' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/dailykey.log'),
|
||||||
|
'level' => 'debug',
|
||||||
|
'days' => 14,
|
||||||
|
],
|
||||||
|
|
||||||
|
'slack' => [
|
||||||
|
'driver' => 'slack',
|
||||||
|
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||||
|
'username' => 'Laravel Log',
|
||||||
|
'emoji' => ':boom:',
|
||||||
|
'level' => env('LOG_LEVEL', 'critical'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'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'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'stderr' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
'handler' => StreamHandler::class,
|
||||||
|
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||||
|
'with' => [
|
||||||
|
'stream' => 'php://stderr',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'syslog' => [
|
||||||
|
'driver' => 'syslog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'errorlog' => [
|
||||||
|
'driver' => 'errorlog',
|
||||||
|
'level' => env('LOG_LEVEL', 'debug'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'null' => [
|
||||||
|
'driver' => 'monolog',
|
||||||
|
'handler' => NullHandler::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'emergency' => [
|
||||||
|
'path' => storage_path('logs/laravel.log'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,117 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Mailer
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default mailer that is used to send any email
|
||||||
|
| messages sent by your application. Alternative mailers may be setup
|
||||||
|
| and used as needed; however, this mailer will be used by default.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('MAIL_MAILER', 'smtp'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 to be used while
|
||||||
|
| sending an e-mail. You will specify which one you are using for your
|
||||||
|
| mailers below. You are free to add additional mailers as required.
|
||||||
|
|
|
||||||
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
|
||||||
|
| "postmark", "log", "array", "failover"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailers' => [
|
||||||
|
'smtp' => [
|
||||||
|
'transport' => 'smtp',
|
||||||
|
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
|
||||||
|
'port' => env('MAIL_PORT', 587),
|
||||||
|
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
|
||||||
|
'username' => env('MAIL_USERNAME'),
|
||||||
|
'password' => env('MAIL_PASSWORD'),
|
||||||
|
'timeout' => null,
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'transport' => 'ses',
|
||||||
|
],
|
||||||
|
|
||||||
|
'mailgun' => [
|
||||||
|
'transport' => 'mailgun',
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'transport' => 'postmark',
|
||||||
|
],
|
||||||
|
|
||||||
|
'sendmail' => [
|
||||||
|
'transport' => 'sendmail',
|
||||||
|
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'log' => [
|
||||||
|
'transport' => 'log',
|
||||||
|
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'array' => [
|
||||||
|
'transport' => 'array',
|
||||||
|
],
|
||||||
|
|
||||||
|
'failover' => [
|
||||||
|
'transport' => 'failover',
|
||||||
|
'mailers' => [
|
||||||
|
'smtp',
|
||||||
|
'log',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Global "From" Address
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| You may wish for all e-mails 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 e-mails that are sent by your application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'from' => [
|
||||||
|
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||||
|
'name' => env('MAIL_FROM_NAME', 'Example'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Markdown Mail Settings
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| If you are using Markdown based email rendering, you may configure your
|
||||||
|
| theme and component paths here, allowing you to customize the design
|
||||||
|
| of the emails. Or, you may simply stick with the Laravel defaults!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'markdown' => [
|
||||||
|
'theme' => 'default',
|
||||||
|
|
||||||
|
'paths' => [
|
||||||
|
resource_path('views/vendor/mail'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Queue Connection Name
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Laravel's queue API supports an assortment of back-ends via a single
|
||||||
|
| API, giving you convenient access to each back-end using the same
|
||||||
|
| syntax for every one. Here you may define a default connection.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'default' => env('QUEUE_CONNECTION', 'sync'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Queue Connections
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may configure the connection information for each server that
|
||||||
|
| is used by your application. A default configuration has been added
|
||||||
|
| for each back-end shipped with Laravel. You are free to add more.
|
||||||
|
|
|
||||||
|
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'connections' => [
|
||||||
|
|
||||||
|
'sync' => [
|
||||||
|
'driver' => 'sync',
|
||||||
|
],
|
||||||
|
|
||||||
|
'database' => [
|
||||||
|
'driver' => 'database',
|
||||||
|
'table' => 'jobs',
|
||||||
|
'queue' => 'default',
|
||||||
|
'retry_after' => 90,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
'beanstalkd' => [
|
||||||
|
'driver' => 'beanstalkd',
|
||||||
|
'host' => 'localhost',
|
||||||
|
'queue' => 'default',
|
||||||
|
'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' => 'default',
|
||||||
|
'queue' => env('REDIS_QUEUE', 'default'),
|
||||||
|
'retry_after' => 90,
|
||||||
|
'block_for' => null,
|
||||||
|
'after_commit' => false,
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Failed Queue Jobs
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These options configure the behavior of failed queue job logging so you
|
||||||
|
| can control which database and table are used to store the jobs that
|
||||||
|
| have failed. You may change them to any database / table you wish.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'failed' => [
|
||||||
|
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||||
|
'database' => env('DB_CONNECTION', 'mysql'),
|
||||||
|
'table' => 'failed_jobs',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Stateful Domains
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Requests from the following domains / hosts will receive stateful API
|
||||||
|
| authentication cookies. Typically, these should include your local
|
||||||
|
| and production domains which access your API via a frontend SPA.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||||
|
'%s%s',
|
||||||
|
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||||
|
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
|
||||||
|
))),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Sanctum Guards
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This array contains the authentication guards that will be checked when
|
||||||
|
| Sanctum is trying to authenticate a request. If none of these guards
|
||||||
|
| are able to authenticate the request, Sanctum will use the bearer
|
||||||
|
| token that's present on an incoming request for authentication.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'guard' => ['web'],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Expiration Minutes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This value controls the number of minutes until an issued token will be
|
||||||
|
| considered expired. If this value is null, personal access tokens do
|
||||||
|
| not expire. This won't tweak the lifetime of first-party sessions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'expiration' => null,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Sanctum Middleware
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When authenticating your first-party SPA with Sanctum you may need to
|
||||||
|
| customize some of the middleware Sanctum uses while processing the
|
||||||
|
| request. You may change the middleware listed below as required.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'middleware' => [
|
||||||
|
'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'mailgun' => [
|
||||||
|
'domain' => env('MAILGUN_DOMAIN'),
|
||||||
|
'secret' => env('MAILGUN_SECRET'),
|
||||||
|
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'postmark' => [
|
||||||
|
'token' => env('POSTMARK_TOKEN'),
|
||||||
|
],
|
||||||
|
|
||||||
|
'ses' => [
|
||||||
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||||
|
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,201 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default Session Driver
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option controls the default session "driver" that will be used on
|
||||||
|
| requests. By default, we will use the lightweight native driver but
|
||||||
|
| you may specify any of the other wonderful drivers provided here.
|
||||||
|
|
|
||||||
|
| Supported: "file", "cookie", "database", "apc",
|
||||||
|
| "memcached", "redis", "dynamodb", "array"
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'driver' => env('SESSION_DRIVER', 'file'),
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| 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 immediately expire on the browser closing, set that option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'lifetime' => env('SESSION_LIFETIME', 120),
|
||||||
|
|
||||||
|
'expire_on_close' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Encryption
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option allows you to easily specify that all of your session data
|
||||||
|
| should be encrypted before it is stored. All encryption will be run
|
||||||
|
| automatically by Laravel and you can use the Session like normal.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'encrypt' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session File Location
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using the native session driver, we need a location where session
|
||||||
|
| files may be stored. A default has been set for you but a different
|
||||||
|
| location may be specified. This is only needed for file sessions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'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 we
|
||||||
|
| should use to manage the sessions. Of course, a sensible default is
|
||||||
|
| provided for you; however, you are free to change this as needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'table' => 'sessions',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cache Store
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| While using one of the framework's cache driven session backends you may
|
||||||
|
| list a cache store that should be used for these sessions. This value
|
||||||
|
| must match with one of the application's configured cache "stores".
|
||||||
|
|
|
||||||
|
| Affects: "apc", "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 cookie used to identify a session
|
||||||
|
| instance by ID. The name specified here will get used every time a
|
||||||
|
| new session cookie is created by the framework for every driver.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'cookie' => env(
|
||||||
|
'SESSION_COOKIE',
|
||||||
|
Str::slug(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 are free to change this when necessary.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'path' => '/',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Session Cookie Domain
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here you may change the domain of the cookie used to identify a session
|
||||||
|
| in your application. This will determine which domains the cookie is
|
||||||
|
| available to in your application. A sensible default has been set.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'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. You are free to modify this option if needed.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'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" since this is a secure default value.
|
||||||
|
|
|
||||||
|
| Supported: "lax", "strict", "none", null
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'same_site' => 'lax',
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| View Storage Paths
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Most templating systems load templates from disk. Here you may specify
|
||||||
|
| an array of paths that should be checked for your views. Of course
|
||||||
|
| the usual Laravel view path has already been registered for you.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'paths' => [
|
||||||
|
resource_path('views'),
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Compiled View Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option determines where all the compiled Blade templates will be
|
||||||
|
| stored for your application. Typically, this is within the storage
|
||||||
|
| directory. However, as usual, you are free to change this value.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'compiled' => env(
|
||||||
|
'VIEW_COMPILED_PATH',
|
||||||
|
realpath(storage_path('framework/views'))
|
||||||
|
),
|
||||||
|
|
||||||
|
];
|
|
@ -0,0 +1 @@
|
||||||
|
*.sqlite*
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||||
|
*/
|
||||||
|
class UserFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->faker->name(),
|
||||||
|
'email' => $this->faker->unique()->safeEmail(),
|
||||||
|
'email_verified_at' => now(),
|
||||||
|
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||||
|
'remember_token' => Str::random(10),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model's email address should be unverified.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
public function unverified()
|
||||||
|
{
|
||||||
|
return $this->state(function (array $attributes) {
|
||||||
|
return [
|
||||||
|
'email_verified_at' => null,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('users', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name',191);
|
||||||
|
$table->string('email',191)->unique();
|
||||||
|
$table->timestamp('email_verified_at')->nullable();
|
||||||
|
$table->string('password',191);
|
||||||
|
$table->string('alamat');
|
||||||
|
$table->string('telepon');
|
||||||
|
$table->string('keterangan');
|
||||||
|
$table->rememberToken();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('users');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('password_resets', function (Blueprint $table) {
|
||||||
|
$table->string('email')->index();
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('created_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('password_resets');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('failed_jobs');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->morphs('tokenable');
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('token', 64)->unique();
|
||||||
|
$table->text('abilities')->nullable();
|
||||||
|
$table->timestamp('last_used_at')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('personal_access_tokens');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('kriteria', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('nama_kriteria',191);
|
||||||
|
$table->string('attribut',191);
|
||||||
|
$table->integer('bobot');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('kriteria');
|
||||||
|
}
|
||||||
|
};
|
|
@ -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.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('alternatif', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('nama_alternatif');
|
||||||
|
$table->string('nik');
|
||||||
|
$table->string('alamat');
|
||||||
|
$table->string('telepon');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('alternatif');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('crips', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('kriteria_id');
|
||||||
|
$table->string('nama_crips',191);
|
||||||
|
$table->integer('bobot');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('crips');
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('penilaian', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('alternatif_id');
|
||||||
|
$table->unsignedBigInteger('crips_id');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('penilaian');
|
||||||
|
}
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue