Initial commit for combined ProjectKP
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
@@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
@@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
@@ -0,0 +1,24 @@
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
@@ -0,0 +1,59 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## 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 Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Redberry](https://redberry.international/laravel-development)**
|
||||
- **[Active Logic](https://activelogic.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,20 @@
|
||||
<?php
|
||||
|
||||
require 'vendor/autoload.php';
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
try {
|
||||
DB::statement("UPDATE users SET role='superadmin' WHERE role='super admin'");
|
||||
// Since 'user' is not yet in enum, we might need to add it first.
|
||||
DB::statement("ALTER TABLE users MODIFY COLUMN role ENUM('superadmin', 'admin', 'pegawai', 'user')");
|
||||
DB::statement("UPDATE users SET role='user' WHERE role='pegawai'");
|
||||
DB::statement("ALTER TABLE users MODIFY COLUMN role ENUM('superadmin', 'admin', 'user') DEFAULT 'user'");
|
||||
echo "Success altering table and migrating data.\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Penugasan;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class PenugasanExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithDrawings, WithEvents
|
||||
{
|
||||
protected $columns;
|
||||
|
||||
public function __construct(array $columns = [])
|
||||
{
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return Penugasan::with(['petugas', 'pembuat'])->latest()->get();
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
if (empty($this->columns)) {
|
||||
return [
|
||||
'No', 'Nomor Surat', 'Kegiatan', 'Lokasi', 'Keterangan',
|
||||
'Tanggal Mulai', 'Tanggal Selesai', 'Status', 'Catatan Status',
|
||||
'Daftar Petugas', 'Dibuat Oleh', 'Dokumentasi'
|
||||
];
|
||||
}
|
||||
|
||||
$headings = ['No'];
|
||||
$map = [
|
||||
'nomor_surat' => 'Nomor Surat',
|
||||
'kegiatan' => 'Nama Kegiatan',
|
||||
'lokasi' => 'Lokasi',
|
||||
'keterangan' => 'Deskripsi',
|
||||
'tanggal_mulai' => 'Tanggal Pelaksanaan',
|
||||
'status' => 'Status',
|
||||
'status_note' => 'Catatan Status',
|
||||
'petugas' => 'Petugas',
|
||||
'pembuat' => 'Dibuat Oleh',
|
||||
'dokumentasi' => 'Dokumentasi'
|
||||
];
|
||||
|
||||
foreach ($this->columns as $col) {
|
||||
if (isset($map[$col])) {
|
||||
$headings[] = $map[$col];
|
||||
}
|
||||
}
|
||||
|
||||
return $headings;
|
||||
}
|
||||
|
||||
public function map($penugasan): array
|
||||
{
|
||||
static $no = 1;
|
||||
|
||||
if (empty($this->columns)) {
|
||||
$namaPetugas = $penugasan->petugas->map(function($p) {
|
||||
return $p->name ?? $p->username;
|
||||
})->implode(', ');
|
||||
|
||||
return [
|
||||
$no++,
|
||||
$penugasan->nomor_surat ?? '-',
|
||||
$penugasan->kegiatan,
|
||||
$penugasan->lokasi ?? '-',
|
||||
$penugasan->keterangan ?? '-',
|
||||
$penugasan->tanggal_mulai,
|
||||
$penugasan->tanggal_selesai ?? '-',
|
||||
strtoupper($penugasan->status),
|
||||
$penugasan->status_note ?? '-',
|
||||
$namaPetugas ?: 'Belum ada petugas',
|
||||
$penugasan->pembuat->name ?? 'System',
|
||||
$penugasan->lampiran ? '' : 'Tidak ada'
|
||||
];
|
||||
}
|
||||
|
||||
$row = [$no++];
|
||||
|
||||
foreach ($this->columns as $col) {
|
||||
switch ($col) {
|
||||
case 'nomor_surat':
|
||||
$row[] = $penugasan->nomor_surat ?? '-';
|
||||
break;
|
||||
case 'kegiatan':
|
||||
$row[] = $penugasan->kegiatan;
|
||||
break;
|
||||
case 'lokasi':
|
||||
$row[] = $penugasan->lokasi ?? '-';
|
||||
break;
|
||||
case 'keterangan':
|
||||
$row[] = $penugasan->keterangan ?? '-';
|
||||
break;
|
||||
case 'tanggal_mulai':
|
||||
$row[] = $penugasan->tanggal_mulai;
|
||||
break;
|
||||
case 'status':
|
||||
$row[] = strtoupper($penugasan->status);
|
||||
break;
|
||||
case 'status_note':
|
||||
$row[] = $penugasan->status_note ?? '-';
|
||||
break;
|
||||
case 'petugas':
|
||||
$namaPetugas = $penugasan->petugas->map(function($p) {
|
||||
return $p->name ?? $p->username;
|
||||
})->implode(', ');
|
||||
$row[] = $namaPetugas ?: 'Belum ada petugas';
|
||||
break;
|
||||
case 'pembuat':
|
||||
$row[] = $penugasan->pembuat->name ?? 'System';
|
||||
break;
|
||||
case 'dokumentasi':
|
||||
$row[] = $penugasan->lampiran ? '' : 'Tidak ada';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function drawings()
|
||||
{
|
||||
$drawings = [];
|
||||
$rowNum = 2; // Data starts at row 2
|
||||
$penugasans = $this->collection();
|
||||
|
||||
$headings = $this->headings();
|
||||
$colIndex = array_search('Dokumentasi', $headings);
|
||||
|
||||
if ($colIndex !== false) {
|
||||
$colLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex + 1); // +1 because Excel is 1-based, array_search is 0-based
|
||||
|
||||
foreach ($penugasans as $penugasan) {
|
||||
if ($penugasan->lampiran && \Storage::disk('public')->exists($penugasan->lampiran)) {
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Dokumentasi');
|
||||
$drawing->setDescription('Dokumentasi');
|
||||
$drawing->setPath(storage_path('app/public/' . $penugasan->lampiran));
|
||||
$drawing->setHeight(70);
|
||||
$drawing->setCoordinates($colLetter . $rowNum);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawings[] = $drawing;
|
||||
}
|
||||
$rowNum++;
|
||||
}
|
||||
}
|
||||
|
||||
return $drawings;
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function(AfterSheet $event) {
|
||||
$penugasans = $this->collection();
|
||||
$rowNum = 2;
|
||||
|
||||
$headings = $this->headings();
|
||||
$hasDokumentasi = in_array('Dokumentasi', $headings);
|
||||
|
||||
if ($hasDokumentasi) {
|
||||
foreach ($penugasans as $penugasan) {
|
||||
if ($penugasan->lampiran && \Storage::disk('public')->exists($penugasan->lampiran)) {
|
||||
$event->sheet->getDelegate()->getRowDimension($rowNum)->setRowHeight(60);
|
||||
}
|
||||
$rowNum++;
|
||||
}
|
||||
|
||||
$colIndex = array_search('Dokumentasi', $headings);
|
||||
$colLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($colIndex + 1);
|
||||
$event->sheet->getDelegate()->getColumnDimension($colLetter)->setWidth(20);
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Mendapatkan daftar notifikasi user saat ini.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json(['success' => false, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
// Ambil notifikasi (semua), urutkan yang terbaru, batasi 20
|
||||
$notifications = $user->notifications()->latest()->take(20)->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $notifications
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menandai semua notifikasi sebagai telah dibaca.
|
||||
*/
|
||||
public function markAsRead()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json(['success' => false, 'message' => 'Unauthorized'], 401);
|
||||
}
|
||||
|
||||
$user->unreadNotifications->markAsRead();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Semua notifikasi ditandai telah dibaca.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,390 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Penugasan;
|
||||
use App\Models\User;
|
||||
use App\Exports\PenugasanExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use App\Notifications\PenugasanStatusNotification;
|
||||
|
||||
class PenugasanController extends Controller
|
||||
{
|
||||
/**
|
||||
* 1. DASHBOARD STATS
|
||||
*/
|
||||
public function dashboard()
|
||||
{
|
||||
try {
|
||||
$user = Auth::user();
|
||||
|
||||
$query = Penugasan::query()->where('is_archived', false);
|
||||
|
||||
if ($user && $user->role === 'user') {
|
||||
$query->whereHas('petugas', function($q) use ($user) {
|
||||
$q->where('users.id', $user->id);
|
||||
});
|
||||
}
|
||||
|
||||
$totalTugas = (clone $query)->where('status', '!=', 'dibatalkan')->count();
|
||||
$proses = (clone $query)->where('status', 'proses')->count();
|
||||
$selesai = (clone $query)->where('status', 'selesai')->count();
|
||||
$telahDitinjau = (clone $query)->where('status', 'telah_ditinjau')->count();
|
||||
$dibatalkan = (clone $query)->where('status', 'dibatalkan')->count();
|
||||
|
||||
// Ambil 5 tugas terbaru beserta data petugasnya, kecuali yang dibatalkan
|
||||
$terbaru = (clone $query)->with('petugas')->where('status', '!=', 'dibatalkan')->latest()->limit(5)->get();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'stats' => [
|
||||
'total_tugas' => $totalTugas,
|
||||
'status_proses' => $proses,
|
||||
'status_selesai' => $selesai,
|
||||
'status_ditinjau' => $telahDitinjau,
|
||||
'status_batal' => $dibatalkan,
|
||||
],
|
||||
'recent_activities' => $terbaru
|
||||
]
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. LIST SEMUA TUGAS
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
$query = Penugasan::with(['petugas', 'pembuat', 'progress.user']);
|
||||
|
||||
if ($user && $user->role === 'user') {
|
||||
$query->whereHas('petugas', function($q) use ($user) {
|
||||
$q->where('users.id', $user->id);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('is_archived') && $request->is_archived == 'true') {
|
||||
$query->where('is_archived', true);
|
||||
} else {
|
||||
$query->where('is_archived', false);
|
||||
}
|
||||
|
||||
$data = $query->latest()->get();
|
||||
return response()->json(['success' => true, 'data' => $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. SIMPAN TUGAS BARU (SINKRON DENGAN FRONTEND)
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nomor_surat' => 'nullable|string|unique:penugasan,nomor_surat',
|
||||
'kegiatan' => 'required|string',
|
||||
'tanggal_mulai' => 'required|date',
|
||||
'pegawai_ids' => 'required|array|min:1',
|
||||
], [
|
||||
'nomor_surat.unique' => 'Nomor surat ini sudah terdaftar di sistem (termasuk yang sudah dihapus/dibatalkan). Harap gunakan nomor yang berbeda.',
|
||||
'pegawai_ids.required' => 'Pilih minimal satu petugas.',
|
||||
'pegawai_ids.min' => 'Pilih minimal satu petugas.',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$adminId = Auth::id() ?? 1;
|
||||
|
||||
$lampiranPath = null;
|
||||
if ($request->hasFile('lampiran')) {
|
||||
$lampiranPath = $request->file('lampiran')->store('lampiran', 'public');
|
||||
}
|
||||
|
||||
$penugasan = Penugasan::create([
|
||||
'nomor_surat' => $request->nomor_surat,
|
||||
'kegiatan' => $request->kegiatan,
|
||||
'lokasi' => $request->lokasi,
|
||||
'keterangan' => $request->keterangan,
|
||||
'lampiran' => $lampiranPath,
|
||||
'tanggal_mulai' => $request->tanggal_mulai,
|
||||
'tanggal_selesai' => $request->tanggal_selesai,
|
||||
'status_note' => $request->status_note,
|
||||
'status' => 'proses',
|
||||
'created_by' => $adminId,
|
||||
]);
|
||||
|
||||
// SIMPAN MULTIPLE PEGAWAI
|
||||
$penugasan->petugas()->sync($request->pegawai_ids);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Penugasan berhasil dibuat!',
|
||||
'data' => $penugasan->load('petugas')
|
||||
], 201);
|
||||
} catch (\Exception $e) {
|
||||
|
||||
DB::rollback();
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 3b. SHOW DETAIL TUGAS
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
try {
|
||||
$penugasan = Penugasan::with(['petugas', 'pembuat', 'penyetuju', 'progress.user'])->findOrFail($id);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $penugasan
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Data tidak ditemukan: ' . $e->getMessage()], 404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 3c. UPDATE TUGAS
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'nomor_surat' => 'nullable|string|unique:penugasan,nomor_surat,' . $id,
|
||||
'kegiatan' => 'required|string',
|
||||
'tanggal_mulai' => 'required|date',
|
||||
'pegawai_ids' => 'required|array|min:1',
|
||||
], [
|
||||
'nomor_surat.unique' => 'Nomor surat ini sudah terdaftar di sistem (termasuk yang sudah dihapus/dibatalkan). Harap gunakan nomor yang berbeda.',
|
||||
'pegawai_ids.required' => 'Pilih minimal satu petugas.',
|
||||
'pegawai_ids.min' => 'Pilih minimal satu petugas.',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$penugasan = Penugasan::findOrFail($id);
|
||||
|
||||
$lampiranPath = $penugasan->lampiran;
|
||||
if ($request->hasFile('lampiran')) {
|
||||
if ($lampiranPath && Storage::disk('public')->exists($lampiranPath)) {
|
||||
Storage::disk('public')->delete($lampiranPath);
|
||||
}
|
||||
$lampiranPath = $request->file('lampiran')->store('lampiran', 'public');
|
||||
}
|
||||
|
||||
$penugasan->update([
|
||||
'nomor_surat' => $request->nomor_surat,
|
||||
'kegiatan' => $request->kegiatan,
|
||||
'lokasi' => $request->lokasi,
|
||||
'keterangan' => $request->keterangan,
|
||||
'lampiran' => $lampiranPath,
|
||||
'tanggal_mulai' => $request->tanggal_mulai,
|
||||
'tanggal_selesai' => $request->tanggal_selesai,
|
||||
'status_note' => $request->status_note,
|
||||
// tidak update status/created_by
|
||||
]);
|
||||
|
||||
$penugasan->petugas()->sync($request->pegawai_ids);
|
||||
|
||||
DB::commit();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Penugasan berhasil diperbarui!',
|
||||
'data' => $penugasan->load('petugas')
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollback();
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 4. UPDATE STATUS (TINJAU)
|
||||
*/
|
||||
public function updateStatus(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$penugasan = Penugasan::findOrFail($id);
|
||||
|
||||
if ($request->status == 'telah_ditinjau') {
|
||||
$penugasan->update([
|
||||
'status' => 'telah_ditinjau',
|
||||
'approved_by' => Auth::id() ?? $request->approved_by,
|
||||
'approved_at' => now(),
|
||||
'status_note' => $request->has('status_note') ? $request->status_note : null
|
||||
]);
|
||||
} else {
|
||||
$updateData = ['status' => $request->status];
|
||||
if ($request->has('status_note')) {
|
||||
$updateData['status_note'] = $request->status_note;
|
||||
}
|
||||
$penugasan->update($updateData);
|
||||
|
||||
// Kirim notifikasi
|
||||
if (in_array($request->status, ['selesai', 'dibatalkan', 'proses'])) {
|
||||
$action = 'diperbarui';
|
||||
if ($request->status === 'selesai') $action = 'disetujui';
|
||||
if ($request->status === 'dibatalkan') $action = 'dibatalkan';
|
||||
if ($request->status === 'proses') $action = 'dikembalikan (revisi)';
|
||||
|
||||
if ($penugasan->petugas->isNotEmpty()) {
|
||||
Notification::send($penugasan->petugas, new PenugasanStatusNotification($penugasan, $request->status, $action));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['success' => true, 'message' => 'Status diperbarui!']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. BATALKAN TUGAS
|
||||
*/
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'alasan' => 'required|string' // Frontend kirim 'alasan'
|
||||
]);
|
||||
|
||||
try {
|
||||
$penugasan = Penugasan::findOrFail($id);
|
||||
|
||||
$penugasan->update([
|
||||
'status' => 'dibatalkan',
|
||||
'alasan_hapus' => $request->alasan
|
||||
]);
|
||||
|
||||
if ($penugasan->petugas->isNotEmpty()) {
|
||||
Notification::send($penugasan->petugas, new PenugasanStatusNotification($penugasan, 'dibatalkan', 'dihapus'));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Kegiatan berhasil dibatalkan.'
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 6. NOTIFIKASI
|
||||
*/
|
||||
public function notifications()
|
||||
{
|
||||
// Contoh implementasi: kirim kegiatan yang sudah 'telah_ditinjau' untuk user ini
|
||||
try {
|
||||
$user = Auth::user();
|
||||
$notifications = [];
|
||||
|
||||
if ($user && $user->role === 'user') {
|
||||
// Pegawai id mungkin sama dengan user_id
|
||||
$pegawai = \App\Models\Pegawai::where('user_id', $user->id)->first();
|
||||
if ($pegawai) {
|
||||
$notifications = $pegawai->penugasan()
|
||||
->where('status', 'telah_ditinjau')
|
||||
->orderBy('approved_at', 'desc')
|
||||
->limit(5)
|
||||
->get()
|
||||
->map(function($p) {
|
||||
return [
|
||||
'id' => $p->id,
|
||||
'text' => "Penugasan '{$p->kegiatan}' telah ditinjau.",
|
||||
'is_read' => false
|
||||
];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $notifications
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 7. EXCEL EXPORT
|
||||
*/
|
||||
public function export(Request $request)
|
||||
{
|
||||
try {
|
||||
$columns = $request->input('columns', []);
|
||||
return Excel::download(new PenugasanExport($columns), 'Laporan_Penugasan.xlsx');
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Export Gagal: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleArchive($id)
|
||||
{
|
||||
try {
|
||||
$penugasan = Penugasan::findOrFail($id);
|
||||
$penugasan->is_archived = !$penugasan->is_archived;
|
||||
$penugasan->save();
|
||||
|
||||
$status = $penugasan->is_archived ? 'diarsipkan' : 'dikembalikan dari arsip';
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => "Laporan berhasil $status."
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Gagal mengarsipkan laporan: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function storeProgress(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$request->validate([
|
||||
'note' => 'required|string',
|
||||
'attachment' => 'nullable|file|mimes:jpg,jpeg,png,pdf|max:2048'
|
||||
]);
|
||||
|
||||
$penugasan = Penugasan::findOrFail($id);
|
||||
|
||||
$path = null;
|
||||
if ($request->hasFile('attachment')) {
|
||||
$file = $request->file('attachment');
|
||||
$filename = time() . '_' . $file->getClientOriginalName();
|
||||
$file->move(public_path('uploads/progress'), $filename);
|
||||
$path = 'uploads/progress/' . $filename;
|
||||
}
|
||||
|
||||
$progress = $penugasan->progress()->create([
|
||||
'user_id' => Auth::id(),
|
||||
'note' => $request->note,
|
||||
'attachment' => $path
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Progress log added successfully',
|
||||
'data' => $progress->load('user')
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Failed to add progress: ' . $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Models\User;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/**
|
||||
* LOGIN API
|
||||
* Menerima username/email + password.
|
||||
* Mengembalikan token untuk dipakai frontend KP-ASOY.
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'username' => 'nullable|string',
|
||||
'login' => 'nullable|string',
|
||||
'password' => 'required|string',
|
||||
]);
|
||||
|
||||
// Frontend KP-ASOY mengirim field "username".
|
||||
// Tapi tetap kita dukung field "login" agar fleksibel.
|
||||
$login = trim($request->username ?? $request->login);
|
||||
|
||||
if (!$login) {
|
||||
return response()->json([
|
||||
'message' => 'Username atau email wajib diisi.'
|
||||
], 422);
|
||||
}
|
||||
|
||||
// Cek apakah input berupa email atau username
|
||||
$field = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
|
||||
|
||||
$user = User::where($field, $login)->first();
|
||||
|
||||
\Illuminate\Support\Facades\Log::info('Login Attempt', ['login' => $login, 'password' => $request->password, 'user_found' => $user ? true : false, 'hash_check' => $user ? Hash::check($request->password, $user->password) : false]);
|
||||
|
||||
if (!$user || !Hash::check($request->password, $user->password)) {
|
||||
return response()->json([
|
||||
'message' => 'Login gagal. Username/email atau password salah.'
|
||||
], 401);
|
||||
}
|
||||
|
||||
// Hapus token lama agar tidak menumpuk terlalu banyak
|
||||
$user->tokens()->delete();
|
||||
|
||||
// Buat token Sanctum
|
||||
$token = $user->createToken('kp-asoy-token')->plainTextToken;
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Login berhasil',
|
||||
'token' => $token,
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
'role' => strtolower($user->role),
|
||||
'jabatan' => $user->jabatan,
|
||||
]
|
||||
], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* REGISTER USER
|
||||
* Dipakai admin/superadmin untuk membuat akun user/pegawai.
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'username' => 'required|string|max:255|unique:users,username',
|
||||
'password' => 'required|string|min:6',
|
||||
'role' => [
|
||||
'required',
|
||||
Rule::in(['user', 'admin', 'superadmin', 'User', 'Admin', 'Superadmin', 'Super Admin'])
|
||||
],
|
||||
'jabatan' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
$role = strtolower($request->role);
|
||||
|
||||
if ($role === 'super admin') {
|
||||
$role = 'superadmin';
|
||||
}
|
||||
|
||||
// Generate email if not provided to satisfy DB unique constraint
|
||||
$email = $request->email ?? ($request->username . '@mail.com');
|
||||
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'username' => $request->username,
|
||||
'email' => $email,
|
||||
'password' => bcrypt($request->password),
|
||||
'role' => $role,
|
||||
'jabatan' => $request->jabatan,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Register berhasil',
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
'role' => $user->role,
|
||||
'jabatan' => $user->jabatan,
|
||||
]
|
||||
], 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* DATA USER YANG SEDANG LOGIN
|
||||
*/
|
||||
public function me(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
return response()->json([
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
'role' => strtolower($user->role),
|
||||
'jabatan' => $user->jabatan,
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* LOGOUT API
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
if ($request->user()) {
|
||||
$request->user()->currentAccessToken()->delete();
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Logout berhasil'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* UPDATE AKUN
|
||||
* Untuk fitur pengaturan akun: ubah email dan password.
|
||||
*/
|
||||
public function updateProfile(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
$request->validate([
|
||||
'username' => [
|
||||
'required',
|
||||
'string',
|
||||
Rule::unique('users', 'username')->ignore($user->id),
|
||||
],
|
||||
'password' => 'nullable|string|min:6',
|
||||
'current_password' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$user->username = $request->username;
|
||||
// Jika tidak ada email, tidak perlu diupdate.
|
||||
// Backend tetap aman karena saat register kita yang men-generate email.
|
||||
|
||||
if ($request->filled('password')) {
|
||||
if ($user->role === 'user') {
|
||||
return response()->json([
|
||||
'message' => 'Pegawai tidak diizinkan mengubah kata sandi.'
|
||||
], 403);
|
||||
}
|
||||
if (!Hash::check($request->current_password, $user->password)) {
|
||||
return response()->json([
|
||||
'message' => 'Kata sandi saat ini tidak cocok.'
|
||||
], 400);
|
||||
}
|
||||
$user->password = bcrypt($request->password);
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Profil berhasil diperbarui',
|
||||
'user' => [
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
'role' => strtolower($user->role),
|
||||
'jabatan' => $user->jabatan,
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Pegawai;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class PegawaiController extends Controller
|
||||
{
|
||||
// 1. Tampil Semua Data
|
||||
public function index()
|
||||
{
|
||||
$data = Pegawai::with('user:id,email,role')->get();
|
||||
return response()->json(['status' => true, 'data' => $data], 200);
|
||||
}
|
||||
|
||||
// 2. Simpan Data Baru (Oleh Admin/Super Admin)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'password' => 'required|string|min:6',
|
||||
'nip' => 'required|string|unique:pegawai,nip',
|
||||
'nama' => 'required|string|max:255',
|
||||
'jabatan' => 'required|string|max:255',
|
||||
'role' => 'nullable|in:super_admin,admin,pegawai',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['status' => false, 'errors' => $validator->errors()], 422);
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$user = User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
'role' => $request->role ?? 'pegawai',
|
||||
]);
|
||||
|
||||
Pegawai::create([
|
||||
'nip' => $request->nip,
|
||||
'nama' => $request->nama,
|
||||
'jabatan' => $request->jabatan,
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'Pegawai berhasil ditambah'], 201);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json(['status' => false, 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Lihat Detail
|
||||
public function show($id)
|
||||
{
|
||||
$pegawai = Pegawai::with('user:id,email,role')->find($id);
|
||||
if (!$pegawai) return response()->json(['status' => false, 'message' => 'Data tidak ditemukan'], 404);
|
||||
return response()->json(['status' => true, 'data' => $pegawai], 200);
|
||||
}
|
||||
|
||||
// 4. Update Data
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$pegawai = Pegawai::find($id);
|
||||
if (!$pegawai) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$pegawai->update([
|
||||
'nip' => $request->nip ?? $pegawai->nip,
|
||||
'nama' => $request->nama ?? $pegawai->nama,
|
||||
'jabatan' => $request->jabatan ?? $pegawai->jabatan,
|
||||
]);
|
||||
|
||||
$user = User::find($pegawai->user_id);
|
||||
if ($user) {
|
||||
$user->update([
|
||||
'name' => $request->nama ?? $user->name,
|
||||
'role' => $request->role ?? $user->role,
|
||||
]);
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return response()->json(['status' => true, 'message' => 'Data berhasil diupdate']);
|
||||
} catch (\Exception $e) {
|
||||
DB::rollBack();
|
||||
return response()->json(['status' => false, 'error' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 5. HAPUS PEGAWAI (REVISI SESUAI REQUEST DOSEN)
|
||||
* Ditambahkan input 'alasan_hapus'
|
||||
*/
|
||||
public function destroy(Request $request, $id)
|
||||
{
|
||||
$pegawai = Pegawai::find($id);
|
||||
if (!$pegawai) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
// Validasi alasan hapus (Request Dosen)
|
||||
$request->validate([
|
||||
'alasan_hapus' => 'required|string'
|
||||
]);
|
||||
|
||||
// Simpan alasan ke database sebelum di-soft delete
|
||||
$pegawai->update([
|
||||
'alasan_hapus' => $request->alasan_hapus
|
||||
]);
|
||||
|
||||
$pegawai->delete();
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Pegawai berhasil dipindahkan ke tempat sampah dengan alasan: ' . $request->alasan_hapus
|
||||
]);
|
||||
}
|
||||
|
||||
// 6. Melihat "Tong Sampah" (Sesuai request dosen: Dashboard tidak perlu detail, detail di sini)
|
||||
public function trash()
|
||||
{
|
||||
// Ambil data yang sudah di-soft delete beserta alasan hapusnya
|
||||
$pegawaiTerhapus = Pegawai::onlyTrashed()->get();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'data' => $pegawaiTerhapus
|
||||
]);
|
||||
}
|
||||
|
||||
// 7. Restore
|
||||
public function restore($id)
|
||||
{
|
||||
$pegawai = Pegawai::withTrashed()->find($id);
|
||||
|
||||
if ($pegawai && $pegawai->trashed()) {
|
||||
// Kosongkan kembali alasan hapus saat di-restore
|
||||
$pegawai->update(['alasan_hapus' => null]);
|
||||
$pegawai->restore();
|
||||
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data pegawai ' . $pegawai->nama . ' berhasil dikembalikan!'
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json(['status' => false, 'message' => 'Data tidak ditemukan di tong sampah'], 404);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\UnitKerja;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UnitKerjaController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$data = UnitKerja::all();
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'nama_unit' => 'required|unique:unit_kerja,nama_unit',
|
||||
]);
|
||||
|
||||
$unit = UnitKerja::create($request->all());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Unit Kerja berhasil ditambah',
|
||||
'data' => $unit
|
||||
]);
|
||||
}
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$unit = UnitKerja::find($id);
|
||||
if (!$unit) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
return response()->json(['success' => true, 'data' => $unit]);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$unit = UnitKerja::find($id);
|
||||
if (!$unit) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
$unit->update($request->all());
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Unit Kerja berhasil diupdate'
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$unit = UnitKerja::find($id);
|
||||
if (!$unit) return response()->json(['message' => 'Data tidak ditemukan'], 404);
|
||||
|
||||
$unit->delete();
|
||||
return response()->json(['success' => true, 'message' => 'Unit Kerja dihapus']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckRole
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, ...$roles)
|
||||
{
|
||||
// Cek apakah user sudah login dan rolenya ada di daftar yang diizinkan
|
||||
if (!$request->user() || !in_array($request->user()->role, $roles)) {
|
||||
return response()->json([
|
||||
'status' => false,
|
||||
'message' => 'Akses ditolak! Anda tidak punya hak akses untuk aksi ini.'
|
||||
], 403); // 403 artinya Forbidden
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Pegawai extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'pegawai';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $fillable = [
|
||||
'nip',
|
||||
'nama',
|
||||
'jabatan',
|
||||
'user_id'
|
||||
];
|
||||
|
||||
// 1. Relasi ke User (Sudah ada)
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 2. TAMBAHKAN INI: Relasi ke Penugasan (Many-to-Many)
|
||||
* Ini supaya Pegawai tahu dia punya banyak tugas melalui tabel pivot
|
||||
*/
|
||||
public function penugasan()
|
||||
{
|
||||
return $this->belongsToMany(Penugasan::class, 'penugasan_pegawai', 'pegawai_id', 'penugasan_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes; // WAJIB UNTUK SOFT DELETES
|
||||
|
||||
class Penugasan extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes; // Gunakan trait SoftDeletes di sini
|
||||
|
||||
// REVISI: Paksa nama tabel menjadi 'penugasan' (tanpa s) sesuai keinginanmu
|
||||
protected $table = 'penugasan';
|
||||
|
||||
protected $fillable = [
|
||||
'nomor_surat',
|
||||
'kegiatan',
|
||||
'lokasi',
|
||||
'keterangan',
|
||||
'lampiran',
|
||||
'tanggal_mulai',
|
||||
'tanggal_selesai',
|
||||
'status', // Isinya nanti: 'proses', 'selesai', 'telah_ditinjau'
|
||||
'status_note', // Catatan progres dari pegawai
|
||||
'is_archived',
|
||||
'created_by',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'alasan_hapus' // TAMBAHAN: Kolom untuk menyimpan alasan hapus sesuai saran KP
|
||||
];
|
||||
|
||||
// Mengatur kolom deleted_at agar dikenali sebagai instance Carbon/Tanggal
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
// 1. Relasi ke Pegawai (Pivot: penugasan_pegawai)
|
||||
public function petugas()
|
||||
{
|
||||
// Sesuaikan nama tabel pivot jika kamu juga mengubahnya nanti
|
||||
return $this->belongsToMany(User::class, 'penugasan_pegawai', 'penugasan_id', 'pegawai_id');
|
||||
}
|
||||
|
||||
public function progress()
|
||||
{
|
||||
return $this->hasMany(PenugasanProgress::class)->latest();
|
||||
}
|
||||
|
||||
// 2. Relasi ke Pembuat (Admin/Kasi)
|
||||
public function pembuat()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
// 3. Relasi ke Penyetuju (Superadmin/Kabid)
|
||||
public function penyetuju()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
// 4. Accessor untuk Status Dinamis (Otomatis Terlambat jika melewati deadline)
|
||||
public function getStatusAttribute($value)
|
||||
{
|
||||
if ($value === 'proses' && !empty($this->attributes['tanggal_selesai'])) {
|
||||
if (\Carbon\Carbon::now()->startOfDay()->gt(\Carbon\Carbon::parse($this->attributes['tanggal_selesai'])->startOfDay())) {
|
||||
return 'terlambat';
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PenugasanProgress extends Model
|
||||
{
|
||||
protected $table = 'penugasan_progress';
|
||||
protected $fillable = ['penugasan_id', 'user_id', 'note', 'attachment'];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Pegawai;
|
||||
|
||||
class UnitKerja extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'unit_kerja'; // sesuaikan dengan nama tabel di migration
|
||||
|
||||
protected $fillable = [
|
||||
'nama_unit'
|
||||
];
|
||||
|
||||
// 🔗 Relasi: 1 unit kerja punya banyak pegawai
|
||||
public function pegawai()
|
||||
{
|
||||
return $this->hasMany(Pegawai::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// Import yang diperlukan
|
||||
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;
|
||||
|
||||
/**
|
||||
* Kolom yang bisa diisi secara massal.
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'username',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
'jabatan',
|
||||
];
|
||||
|
||||
/**
|
||||
* Kolom yang disembunyikan saat data dikonversi ke JSON.
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Casting tipe data kolom.
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RELASI ANTAR TABEL
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Relasi 1 User ke 1 Pegawai
|
||||
*/
|
||||
public function pegawai()
|
||||
{
|
||||
return $this->hasOne(Pegawai::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* REVISI DI SINI:
|
||||
* Relasi agar Pegawai bisa melihat daftar tugas yang diberikan kepadanya.
|
||||
*/
|
||||
public function penugasan()
|
||||
{
|
||||
return $this->belongsToMany(Penugasan::class, 'penugasan_pegawai', 'pegawai_id', 'penugasan_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Penugasan (User sebagai pembuat)
|
||||
*/
|
||||
public function penugasanDibuat()
|
||||
{
|
||||
return $this->hasMany(Penugasan::class, 'created_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relasi ke Penugasan (User sebagai penyetuju/admin)
|
||||
*/
|
||||
public function penugasanDisetujui()
|
||||
{
|
||||
return $this->hasMany(Penugasan::class, 'approved_by');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class PenugasanStatusNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $penugasan;
|
||||
protected $status;
|
||||
protected $action;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct($penugasan, $status, $action = 'diperbarui')
|
||||
{
|
||||
$this->penugasan = $penugasan;
|
||||
$this->status = $status;
|
||||
$this->action = $action; // 'disetujui', 'dihapus', 'ditolak'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toDatabase(object $notifiable): array
|
||||
{
|
||||
$kegiatan = $this->penugasan->kegiatan ?? 'Kegiatan Anda';
|
||||
|
||||
if ($this->action === 'dihapus') {
|
||||
$message = "Laporan kegiatan '{$kegiatan}' telah Dihapus oleh Admin.";
|
||||
} elseif ($this->action === 'disetujui') {
|
||||
$message = "Hore! Laporan kegiatan '{$kegiatan}' telah Disetujui (Selesai).";
|
||||
} elseif ($this->action === 'ditolak') {
|
||||
$message = "Maaf, Laporan kegiatan '{$kegiatan}' Ditolak. Silakan periksa kembali.";
|
||||
} else {
|
||||
$message = "Status laporan kegiatan '{$kegiatan}' diubah menjadi: {$this->status}.";
|
||||
}
|
||||
|
||||
return [
|
||||
'penugasan_id' => $this->penugasan->id ?? null,
|
||||
'status' => $this->status,
|
||||
'action' => $this->action,
|
||||
'message' => $message,
|
||||
'kegiatan' => $kegiatan
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
$middleware->alias([
|
||||
'role' => \App\Http\Middleware\CheckRole::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions) {
|
||||
$exceptions->render(function (\Illuminate\Auth\AuthenticationException $e, \Illuminate\Http\Request $request) {
|
||||
if ($request->is('api/*')) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Unauthenticated. Token tidak valid atau tidak ada.'
|
||||
], 401);
|
||||
}
|
||||
});
|
||||
})->create();
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
];
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
|
||||
$penugasan = \App\Models\Penugasan::latest()->first();
|
||||
echo "Last Penugasan ID: " . ($penugasan ? $penugasan->id : 'null') . "\n";
|
||||
echo "Kegiatan: " . ($penugasan ? $penugasan->kegiatan : 'null') . "\n";
|
||||
if ($penugasan) {
|
||||
$petugas = $penugasan->petugas()->pluck('users.id')->toArray();
|
||||
echo "Petugas IDs: " . json_encode($petugas) . "\n";
|
||||
}
|
||||
|
||||
$user = \App\Models\User::where('username', 'hari_disnaker')->first();
|
||||
echo "hari_disnaker ID: " . ($user ? $user->id : 'null') . "\n";
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"framework"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"maatwebsite/excel": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/boost": "2.0",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"pestphp/pest": "^4.4",
|
||||
"pestphp/pest-plugin-laravel": "^4.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"npm run dev\" --names='server,queue,vite'"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
|
||||
"@php artisan boost:update --ansi"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
Generated
+10226
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'Asia/Jakarta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_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: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
];
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
// Tuliskan alamat frontend kamu secara spesifik di sini
|
||||
'allowed_origins' => ['http://localhost:8001', 'http://127.0.0.1:8001'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => true,
|
||||
];
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
'default' => env('DB_CONNECTION', 'mysql'), // Langsung set ke mysql biar gak lari ke sqlite
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'database_monitoring'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', 'radit123'),
|
||||
'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'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
'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'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
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',
|
||||
Sanctum::currentApplicationUrlWithPort(),
|
||||
// Sanctum::currentRequestHost(),
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('username')->unique(); // <--- BARIS INI WAJIB ADA
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->enum('role', ['superadmin', 'admin', 'user'])->default('user');
|
||||
$table->string('jabatan')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
|
||||
// 2. Tabel Password Reset
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
// 3. Tabel Sessions (Penting untuk login)
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue');
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
|
||||
$table->index(['queue', 'reserved_at', 'available_at']);
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('pegawai', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('nip')->unique();
|
||||
$table->string('nama');
|
||||
$table->string('jabatan');
|
||||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('pegawai');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| TABEL PENUGASAN
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Schema::create('penugasan', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
|
||||
$table->string('nomor_surat')
|
||||
->unique()
|
||||
->nullable();
|
||||
|
||||
$table->string('kegiatan');
|
||||
|
||||
$table->string('lokasi')->nullable();
|
||||
|
||||
$table->text('keterangan')->nullable();
|
||||
|
||||
$table->string('lampiran')->nullable();
|
||||
|
||||
$table->date('tanggal_mulai');
|
||||
|
||||
$table->date('tanggal_selesai')
|
||||
->nullable();
|
||||
|
||||
$table->enum('status', [
|
||||
'proses',
|
||||
'selesai',
|
||||
'telah_ditinjau',
|
||||
'dibatalkan'
|
||||
])->default('proses');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| FOREIGN KEY
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$table->foreignId('created_by')
|
||||
->constrained('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreignId('approved_by')
|
||||
->nullable()
|
||||
->constrained('users')
|
||||
->onDelete('set null');
|
||||
|
||||
$table->timestamp('approved_at')
|
||||
->nullable();
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| LAINNYA
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$table->text('alasan_hapus')
|
||||
->nullable();
|
||||
|
||||
$table->softDeletes();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| TABEL PIVOT PENUGASAN PEGAWAI
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Schema::create('penugasan_pegawai', function (Blueprint $table) {
|
||||
|
||||
$table->id();
|
||||
|
||||
$table->foreignId('penugasan_id')
|
||||
->constrained('penugasan')
|
||||
->onDelete('cascade');
|
||||
|
||||
// FIX DI SINI: Mereferensikan ke tabel users karena pegawai mengambil dari role user
|
||||
$table->foreignId('pegawai_id')
|
||||
->constrained('users')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
Schema::dropIfExists('penugasan_pegawai');
|
||||
|
||||
Schema::dropIfExists('penugasan');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('unit_kerjas', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('unit_kerjas');
|
||||
}
|
||||
};
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('notifications', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('type');
|
||||
$table->morphs('notifiable');
|
||||
$table->text('data');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('penugasan', function (Blueprint $table) {
|
||||
$table->text('status_note')->nullable()->after('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('penugasan', function (Blueprint $table) {
|
||||
$table->dropColumn('status_note');
|
||||
});
|
||||
}
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('penugasan', function (Blueprint $table) {
|
||||
$table->boolean('is_archived')->default(false)->after('status_note');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('penugasan', function (Blueprint $table) {
|
||||
$table->dropColumn('is_archived');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('penugasan_progress', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('penugasan_id')->constrained('penugasan')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->constrained('users')->onDelete('cascade');
|
||||
$table->text('note');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('penugasan_progress');
|
||||
}
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('penugasan_progress', function (Blueprint $table) {
|
||||
$table->string('attachment')->nullable()->after('note');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('penugasan_progress', function (Blueprint $table) {
|
||||
$table->dropColumn('attachment');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AkunSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| SUPER ADMIN
|
||||
|--------------------------------------------------------------------------
|
||||
| Super Admin memiliki akses penuh terhadap sistem.
|
||||
*/
|
||||
User::updateOrCreate(
|
||||
['username' => 'sutowo_superadmin'],
|
||||
[
|
||||
'name' => 'SUTOWO, SE, M.Si',
|
||||
'email' => 'superadmin@mail.com',
|
||||
'password' => Hash::make('password123'),
|
||||
'role' => 'superadmin',
|
||||
'jabatan' => 'Kepala Bidang Pengawasan Ketenagakerjaan',
|
||||
]
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ADMIN
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin hanya digunakan untuk membuat akun pegawai/user.
|
||||
*/
|
||||
$admins = [
|
||||
[
|
||||
'name' => 'WELPRIDA IRANI, SH, M.Si',
|
||||
'username' => 'welprida_admin',
|
||||
'email' => 'welprida@admin.com',
|
||||
'jabatan' => 'Kepala Seksi Penegakan Hukum',
|
||||
],
|
||||
[
|
||||
'name' => 'RINI YULIASTI, ST.,MM',
|
||||
'username' => 'rini_admin',
|
||||
'email' => 'rini@admin.com',
|
||||
'jabatan' => 'Kasi Informasi Pasar Kerja dan Analisis Produktivitas',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
User::updateOrCreate(
|
||||
['username' => $admin['username']],
|
||||
[
|
||||
'name' => $admin['name'],
|
||||
'email' => $admin['email'],
|
||||
'password' => Hash::make('password123'),
|
||||
'role' => 'admin',
|
||||
'jabatan' => $admin['jabatan'],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| USER / PEGAWAI
|
||||
|--------------------------------------------------------------------------
|
||||
| Dalam database role disimpan sebagai "user".
|
||||
| Di tampilan sistem boleh tetap ditulis sebagai "Pegawai".
|
||||
*/
|
||||
$pegawai = [
|
||||
[
|
||||
'name' => 'HARRI MULIAWAN, ST',
|
||||
'username' => 'hari_disnaker',
|
||||
'email' => 'harri@pegawai.com',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
|
||||
],
|
||||
[
|
||||
'name' => 'DANA OKTAVIAN, S.Sos',
|
||||
'username' => 'dana_disnaker',
|
||||
'email' => 'dana@pegawai.com',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
|
||||
],
|
||||
[
|
||||
'name' => 'LISBET MARYATI S, SH',
|
||||
'username' => 'lisbet_disnaker',
|
||||
'email' => 'lisbet@pegawai.com',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
],
|
||||
[
|
||||
'name' => 'MAISA BAHARI, SH',
|
||||
'username' => 'maisa_disnaker',
|
||||
'email' => 'maisa@pegawai.com',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
],
|
||||
[
|
||||
'name' => 'URAY NANDA KHARISMA, SE',
|
||||
'username' => 'uray_disnaker',
|
||||
'email' => 'uray@pegawai.com',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($pegawai as $user) {
|
||||
User::updateOrCreate(
|
||||
['username' => $user['username']],
|
||||
[
|
||||
'name' => $user['name'],
|
||||
'email' => $user['email'],
|
||||
'password' => Hash::make('password123'),
|
||||
'role' => 'user',
|
||||
'jabatan' => $user['jabatan'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
AkunSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PegawaiSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
// Matikan pengecekan foreign key sementara agar bisa truncate (bersihkan tabel)
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
|
||||
DB::table('pegawais')->truncate();
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
|
||||
|
||||
// Masukkan data pegawai saja (Profile), User ID disesuaikan dengan urutan di AkunSeeder
|
||||
// ID 1: Sutowo, ID 2: Welprida, ID 3: Rini, ID 4: Harri ...
|
||||
DB::table('pegawais')->insert([
|
||||
[
|
||||
'id' => 4,
|
||||
'nip' => '198501012010011001',
|
||||
'nama' => 'HARRI MULIAWAN, ST',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
|
||||
'user_id' => 4, // Nyambung ke Harri di tabel users
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'id' => 5,
|
||||
'nip' => '198602022011021002',
|
||||
'nama' => 'DANA OKTAVIAN, S.Sos',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Muda',
|
||||
'user_id' => 5,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'nip' => '198703032012032003',
|
||||
'nama' => 'LISBET MARYATI S, SH',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
'user_id' => 6,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'id' => 7,
|
||||
'nip' => '198804042013042004',
|
||||
'nama' => 'MAISA BAHARI, SH',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
'user_id' => 7,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'id' => 8,
|
||||
'nip' => '198905052014051005',
|
||||
'nama' => 'URAY NANDA KHARISMA, SE',
|
||||
'jabatan' => 'Pengawas Ketenagakerjaan Ahli Pertama',
|
||||
'user_id' => 8,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
|
||||
$this->command->info('✓ PegawaiSeeder Berhasil: Data profil pegawai sudah masuk!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
-- =====================
|
||||
-- DATABASE
|
||||
-- =====================
|
||||
DROP DATABASE IF EXISTS database_monitoring;
|
||||
CREATE DATABASE database_monitoring;
|
||||
USE database_monitoring;
|
||||
|
||||
-- =====================
|
||||
-- USERS
|
||||
-- =====================
|
||||
CREATE TABLE users (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
email VARCHAR(100) UNIQUE,
|
||||
password VARCHAR(255),
|
||||
role ENUM('super_admin','admin','user') DEFAULT 'user',
|
||||
created_at TIMESTAMP NULL,
|
||||
updated_at TIMESTAMP NULL
|
||||
);
|
||||
|
||||
-- =====================
|
||||
-- PEGAWAI
|
||||
-- =====================
|
||||
DROP TABLE pegawai;
|
||||
|
||||
CREATE TABLE pegawai (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
nip VARCHAR(50) UNIQUE,
|
||||
nama VARCHAR(100),
|
||||
jabatan VARCHAR(100),
|
||||
user_id BIGINT NULL,
|
||||
created_at TIMESTAMP NULL,
|
||||
updated_at TIMESTAMP NULL
|
||||
);
|
||||
|
||||
-- =====================
|
||||
-- PENUGASAN
|
||||
-- =====================
|
||||
CREATE TABLE penugasan (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
nomor_surat VARCHAR(100),
|
||||
kegiatan VARCHAR(255),
|
||||
tanggal_mulai DATE,
|
||||
tanggal_selesai DATE,
|
||||
status ENUM('on_progress','selesai','telah_ditinjau') DEFAULT 'on_progress',
|
||||
created_by BIGINT,
|
||||
approved_by BIGINT NULL,
|
||||
approved_at TIMESTAMP NULL,
|
||||
created_at TIMESTAMP NULL,
|
||||
updated_at TIMESTAMP NULL,
|
||||
FOREIGN KEY (created_by) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (approved_by) REFERENCES users(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
-- =====================
|
||||
-- RELASI MANY TO MANY
|
||||
-- =====================
|
||||
CREATE TABLE penugasan_pegawai (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
penugasan_id BIGINT,
|
||||
pegawai_id BIGINT,
|
||||
|
||||
FOREIGN KEY (penugasan_id) REFERENCES penugasan(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (pegawai_id) REFERENCES pegawai(id) ON DELETE CASCADE,
|
||||
|
||||
UNIQUE (penugasan_id, pegawai_id)
|
||||
);
|
||||
|
||||
INSERT INTO users (name, email, password, role)
|
||||
VALUES (
|
||||
'ERIKA FITRANOVA, SH.,M.A.P',
|
||||
'superadmin@mail.com',
|
||||
'123456',
|
||||
'super_admin'
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO users (name, email, password, role) VALUES
|
||||
('SUTOWO, SE, M.Si', 'admin1@mail.com', '123456', 'admin'),
|
||||
('WELPRIDA IRANI, SH, M.Si', 'admin2@mail.com', '123456', 'admin');
|
||||
|
||||
|
||||
INSERT INTO pegawai (nip, nama, jabatan) VALUES
|
||||
('P001', 'HARRI MULIAWAN, ST', 'Pengawas Ketenagakerjaan Ahli Muda'),
|
||||
('P002', 'DANA OKTAVIAN, S.Sos', 'Pengawas Ketenagakerjaan Ahli Muda'),
|
||||
('P003', 'LISBET MARYATI S, SH', 'Pengawas Ketenagakerjaan Ahli Pertama'),
|
||||
('P004', 'MAISA BAHARI, SH', 'Pengawas Ketenagakerjaan Ahli Pertama'),
|
||||
('P005', 'URAY NANDA KHARISMA, SE', 'Pengawas Ketenagakerjaan Ahli Pertama');
|
||||
|
||||
DROP DATABASE IF EXISTS database_monitoring;
|
||||
CREATE DATABASE database_monitoring;
|
||||
USE database_monitoring;
|
||||
RENAME TABLE pegawais TO pegawai;
|
||||
SELECT * FROM pegawai;
|
||||
SELECT * FROM users;
|
||||
Binary file not shown.
Generated
+2421
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"$schema": "https://www.schemastore.org/package.json",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"dev": "vite"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.0.0",
|
||||
"axios": "^1.11.0",
|
||||
"concurrently": "^9.0.1",
|
||||
"laravel-vite-plugin": "^2.0.0",
|
||||
"tailwindcss": "^4.0.0",
|
||||
"vite": "^7.0.7"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Unit">
|
||||
<directory>tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory>tests/Feature</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source>
|
||||
<include>
|
||||
<directory>app</directory>
|
||||
</include>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="testing"/>
|
||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||
<env name="BCRYPT_ROUNDS" value="4"/>
|
||||
<env name="BROADCAST_CONNECTION" value="null"/>
|
||||
<env name="CACHE_STORE" value="array"/>
|
||||
<env name="DB_CONNECTION" value="sqlite"/>
|
||||
<env name="DB_DATABASE" value=":memory:"/>
|
||||
<env name="DB_URL" value=""/>
|
||||
<env name="MAIL_MAILER" value="array"/>
|
||||
<env name="QUEUE_CONNECTION" value="sync"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="PULSE_ENABLED" value="false"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
<env name="NIGHTWATCH_ENABLED" value="false"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -0,0 +1,25 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Handle X-XSRF-Token Header
|
||||
RewriteCond %{HTTP:x-xsrf-token} .
|
||||
RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) {
|
||||
require __DIR__.'/../storage/framework/maintenance.php';
|
||||
}
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$kernel = $app->make(Kernel::class);
|
||||
|
||||
$response = $kernel->handle(
|
||||
$request = Request::capture()
|
||||
);
|
||||
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
||||
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 227 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 227 KiB |
@@ -0,0 +1,11 @@
|
||||
@import 'tailwindcss';
|
||||
|
||||
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
|
||||
@source '../../storage/framework/views/*.php';
|
||||
@source '../**/*.blade.php';
|
||||
@source '../**/*.js';
|
||||
|
||||
@theme {
|
||||
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import './bootstrap';
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import axios from 'axios';
|
||||
window.axios = axios;
|
||||
|
||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||
@@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Activity Reports</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-100 p-6">
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-blue-900">Laporan Aktivitas Pegawai</h1>
|
||||
<p class="text-gray-500">Manajemen dan pemantauan kinerja harian instansi</p>
|
||||
</div>
|
||||
|
||||
<button onclick="exportPDF()" class="bg-blue-800 text-white px-4 py-2 rounded-lg">
|
||||
Export PDF
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- FILTER -->
|
||||
<form method="GET" class="bg-white p-4 rounded-xl shadow mb-6 grid grid-cols-4 gap-4">
|
||||
|
||||
<input type="text" name="search"
|
||||
placeholder="Cari pegawai / aktivitas"
|
||||
class="border rounded-lg px-3 py-2">
|
||||
|
||||
<input type="date" name="tanggal"
|
||||
class="border rounded-lg px-3 py-2">
|
||||
|
||||
<select name="status" class="border rounded-lg px-3 py-2">
|
||||
<option>Semua</option>
|
||||
<option>Selesai</option>
|
||||
<option>Dalam Proses</option>
|
||||
<option>Menunggu</option>
|
||||
</select>
|
||||
|
||||
<button class="bg-blue-800 text-white rounded-lg px-4">
|
||||
Terapkan Filter
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- TABLE -->
|
||||
<div class="bg-white rounded-xl shadow overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
<th class="p-3 text-left">Nama</th>
|
||||
<th class="p-3 text-left">Aktivitas</th>
|
||||
<th class="p-3 text-left">Lokasi</th>
|
||||
<th class="p-3 text-left">Tanggal</th>
|
||||
<th class="p-3 text-left">Status</th>
|
||||
<th class="p-3 text-left">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr class="border-t">
|
||||
<td class="p-3 flex items-center gap-3">
|
||||
<div class="w-8 h-8 bg-blue-200 rounded-full flex items-center justify-center text-xs font-bold">
|
||||
AS
|
||||
</div>
|
||||
Agus Setiawan
|
||||
</td>
|
||||
|
||||
<td class="p-3">Sosialisasi Ketenagakerjaan</td>
|
||||
<td class="p-3">Pontianak</td>
|
||||
<td class="p-3">24 Mei 2024</td>
|
||||
|
||||
<td class="p-3">
|
||||
<span class="bg-green-100 text-green-700 px-2 py-1 rounded-full text-xs">
|
||||
SELESAI
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="p-3">
|
||||
<button onclick="showDetail()" class="text-blue-700 font-semibold">
|
||||
Detail
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- SUMMARY -->
|
||||
<div class="grid grid-cols-3 gap-4 mt-6">
|
||||
|
||||
<div class="bg-white p-4 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">Total Selesai</p>
|
||||
<h2 class="text-2xl font-bold text-blue-900">86</h2>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-4 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">Dalam Antrian</p>
|
||||
<h2 class="text-2xl font-bold">38</h2>
|
||||
</div>
|
||||
|
||||
<div class="bg-red-50 p-4 rounded-xl shadow">
|
||||
<p class="text-red-500 text-sm">Urgent / Menunggu</p>
|
||||
<h2 class="text-2xl font-bold text-red-600">12</h2>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- MODAL -->
|
||||
<div id="modal" class="hidden fixed inset-0 bg-black bg-opacity-40 flex items-center justify-center">
|
||||
<div class="bg-white p-6 rounded-xl w-96">
|
||||
<h2 class="text-xl font-bold mb-4">Detail Aktivitas</h2>
|
||||
|
||||
<p>Detail data pegawai...</p>
|
||||
|
||||
<button onclick="closeModal()" class="mt-4 bg-blue-800 text-white px-4 py-2 rounded">
|
||||
Tutup
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showDetail(){
|
||||
document.getElementById('modal').classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeModal(){
|
||||
document.getElementById('modal').classList.add('hidden');
|
||||
}
|
||||
|
||||
function exportPDF(){
|
||||
alert('Export PDF diklik');
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,198 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Dashboard Monitoring - Disnaker Pontianak</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
<style>
|
||||
body { font-family: 'Inter', sans-serif; background-color: #F8FAFC; }
|
||||
.sidebar-active { background-color: #FFFFFF; color: #0D215C; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05); }
|
||||
.custom-scroll::-webkit-scrollbar { width: 6px; }
|
||||
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
|
||||
.custom-scroll::-webkit-scrollbar-thumb { background: #E2E8F0; border-radius: 10px; }
|
||||
</style>
|
||||
</head>
|
||||
<body class="flex h-screen overflow-hidden text-slate-700">
|
||||
|
||||
<aside class="w-64 bg-[#F8FAFC] border-r border-slate-200 flex flex-col">
|
||||
<div class="p-8 mb-4">
|
||||
<h1 class="text-[#0D215C] font-extrabold text-xl tracking-tight">Disnaker</h1>
|
||||
<p class="text-slate-400 text-[10px] font-bold tracking-widest uppercase mt-0.5">Kota Pontianak</p>
|
||||
</div>
|
||||
|
||||
<nav class="flex-1 px-4 space-y-1">
|
||||
<a href="#" class="sidebar-active flex items-center gap-3 p-3 rounded-xl font-bold text-sm transition-all">
|
||||
<i data-lucide="layout-grid" class="w-5 h-5"></i> Dashboard
|
||||
</a>
|
||||
<a href="{{ route('input.activity') }}" class="flex items-center gap-3 p-3 rounded-xl text-slate-400 hover:text-[#0D215C] font-semibold text-sm transition-all group">
|
||||
<i data-lucide="bar-chart-3" class="w-5 h-5"></i> Activity Report
|
||||
</a>
|
||||
<a href="{{ route('input.activity') }}" class="flex items-center gap-3 p-3 rounded-xl text-slate-400 hover:text-[#0D215C] font-semibold text-sm transition-all group">
|
||||
<i data-lucide="file-text" class="w-5 h-5"></i> Input Activity
|
||||
</a>
|
||||
</nav>
|
||||
|
||||
<div class="p-4 border-t border-slate-200 space-y-1 mb-4">
|
||||
<a href="#" class="flex items-center gap-3 p-3 rounded-xl text-slate-400 hover:text-[#0D215C] font-semibold text-sm transition-all">
|
||||
<i data-lucide="settings" class="w-5 h-5"></i> Pengaturan
|
||||
</a>
|
||||
<a href="{{ route('logout') }}" class="flex items-center gap-3 p-3 rounded-xl text-red-400 hover:bg-red-50 font-bold text-sm transition-all">
|
||||
<i data-lucide="log-out" class="w-5 h-5"></i> Logout
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<main class="flex-1 overflow-y-auto bg-white m-4 rounded-[32px] border border-slate-100 shadow-sm relative custom-scroll">
|
||||
|
||||
<div class="sticky top-0 bg-white/80 backdrop-blur-md px-10 py-6 flex justify-between items-center z-10 border-b border-slate-50 border-dashed">
|
||||
<div class="relative w-96 group">
|
||||
<i data-lucide="search" class="absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-300 group-focus-within:text-blue-500 transition-colors"></i>
|
||||
<input type="text" placeholder="Cari aktivitas atau pegawai..."
|
||||
class="w-full pl-11 pr-4 py-2.5 bg-slate-50 border border-slate-100 rounded-2xl focus:ring-4 focus:ring-blue-500/5 focus:border-blue-500/20 outline-none text-sm transition-all">
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-6">
|
||||
<button class="relative p-2 text-slate-400 hover:bg-slate-50 rounded-full transition-colors">
|
||||
<i data-lucide="bell" class="w-5 h-5"></i>
|
||||
<span class="absolute top-2.5 right-2.5 w-2 h-2 bg-red-500 rounded-full border-2 border-white"></span>
|
||||
</button>
|
||||
<div class="flex items-center gap-4 pl-6 border-l border-slate-100">
|
||||
<div class="text-right">
|
||||
<p class="text-xs font-extrabold text-[#0D215C]">Ahmad Ridwan</p>
|
||||
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-wider mt-0.5">Administrator</p>
|
||||
</div>
|
||||
<div class="w-10 h-10 rounded-2xl bg-[#0D215C] flex items-center justify-center shadow-lg shadow-blue-900/20 overflow-hidden border-2 border-slate-50">
|
||||
<img src="https://ui-avatars.com/api/?name=Ahmad+Ridwan&background=0D215C&color=fff" alt="Avatar">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-10">
|
||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-end mb-10 gap-4">
|
||||
<div>
|
||||
<h2 class="text-[28px] font-black text-[#0D215C] tracking-tight">Dashboard Monitoring</h2>
|
||||
<p class="text-slate-400 text-sm mt-2 font-medium">Pantau progres dan efektivitas kerja pegawai secara real-time.</p>
|
||||
</div>
|
||||
<button class="bg-[#0D215C] text-white px-7 py-3 rounded-2xl font-bold text-xs uppercase tracking-widest hover:bg-blue-900 shadow-xl shadow-blue-900/20 active:scale-95 transition-all flex items-center gap-2">
|
||||
<i data-lucide="plus" class="w-4 h-4"></i> Tambah Aktivitas
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-12">
|
||||
<div class="bg-white p-6 rounded-[28px] border border-slate-100 shadow-sm border-l-4 border-blue-500 flex justify-between items-start hover:scale-[1.02] transition-all">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-widest mb-1">Total Activities</p>
|
||||
<h3 class="text-3xl font-black text-[#0D215C]">1,284</h3>
|
||||
<p class="text-[10px] text-green-500 font-bold mt-3 flex items-center gap-1">
|
||||
<i data-lucide="trending-up" class="w-3 h-3"></i> +12% dari bulan lalu
|
||||
</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-blue-50 rounded-2xl flex items-center justify-center">
|
||||
<i data-lucide="archive" class="text-blue-500 w-6 h-6"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-6 rounded-[28px] border border-slate-100 shadow-sm border-l-4 border-green-500 flex justify-between items-start hover:scale-[1.02] transition-all">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-widest mb-1">Completed</p>
|
||||
<h3 class="text-3xl font-black text-[#0D215C]">942</h3>
|
||||
<div class="w-32 h-1.5 bg-slate-100 rounded-full mt-5 overflow-hidden">
|
||||
<div class="w-[75%] h-full bg-green-500"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-green-50 rounded-2xl flex items-center justify-center">
|
||||
<i data-lucide="check-circle" class="text-green-500 w-6 h-6"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-6 rounded-[28px] border border-slate-100 shadow-sm border-l-4 border-amber-500 flex justify-between items-start hover:scale-[1.02] transition-all">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-widest mb-1">Ongoing</p>
|
||||
<h3 class="text-3xl font-black text-[#0D215C]">215</h3>
|
||||
<p class="text-[10px] text-slate-400 font-medium mt-4 italic">Dalam peninjauan aktif</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-amber-50 rounded-2xl flex items-center justify-center">
|
||||
<i data-lucide="clock" class="text-amber-500 w-6 h-6"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white p-6 rounded-[28px] border border-slate-100 shadow-sm border-l-4 border-red-500 flex justify-between items-start hover:scale-[1.02] transition-all">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold text-slate-400 uppercase tracking-widest mb-1">Pending</p>
|
||||
<h3 class="text-3xl font-black text-[#0D215C]">127</h3>
|
||||
<p class="text-[10px] text-red-500 font-bold mt-4 uppercase tracking-tighter">Perlu tindakan segera</p>
|
||||
</div>
|
||||
<div class="w-12 h-12 bg-red-50 rounded-2xl flex items-center justify-center">
|
||||
<i data-lucide="alert-circle" class="text-red-500 w-6 h-6"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-[32px] border border-slate-100 shadow-sm overflow-hidden">
|
||||
<div class="px-8 py-6 flex justify-between items-center border-b border-slate-50">
|
||||
<h4 class="font-extrabold text-[#0D215C] tracking-tight">Recent Activities</h4>
|
||||
<a href="#" class="text-[11px] font-black text-blue-600 uppercase tracking-widest hover:text-blue-800 transition-colors">Lihat Semua</a>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full">
|
||||
<thead class="bg-slate-50/50">
|
||||
<tr class="text-left text-[10px] font-black text-slate-400 uppercase tracking-[0.15em]">
|
||||
<th class="px-8 py-5">Employee Name</th>
|
||||
<th class="px-8 py-5">Activity</th>
|
||||
<th class="px-8 py-5">Location</th>
|
||||
<th class="px-8 py-5">Date</th>
|
||||
<th class="px-8 py-5 text-center">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-50">
|
||||
<tr class="hover:bg-slate-50/50 transition-colors group">
|
||||
<td class="px-8 py-5">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-9 h-9 rounded-xl bg-blue-50 flex items-center justify-center text-[10px] font-bold text-blue-600">BP</div>
|
||||
<span class="text-xs font-extrabold text-slate-700">Bambang Pamungkas</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-xs font-semibold text-slate-500">Audit K3 Lapangan</td>
|
||||
<td class="px-8 py-5">
|
||||
<div class="flex items-center gap-1.5 text-xs font-semibold text-slate-400">
|
||||
<i data-lucide="map-pin" class="w-3 h-3"></i> Kawasan Industri
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-xs font-bold text-slate-400">24 Okt 2023</td>
|
||||
<td class="px-8 py-5 text-center">
|
||||
<span class="bg-green-100 text-green-600 px-4 py-1.5 rounded-lg text-[9px] font-black uppercase tracking-widest">Completed</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="hover:bg-slate-50/50 transition-colors group">
|
||||
<td class="px-8 py-5">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-9 h-9 rounded-xl bg-purple-50 flex items-center justify-center text-[10px] font-bold text-purple-600">SP</div>
|
||||
<span class="text-xs font-extrabold text-slate-700">Siti Permata</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-xs font-semibold text-slate-500">Sosialisasi BPJS TK</td>
|
||||
<td class="px-8 py-5">
|
||||
<div class="flex items-center gap-1.5 text-xs font-semibold text-slate-400">
|
||||
<i data-lucide="map-pin" class="w-3 h-3"></i> Aula Kantor Camat
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-xs font-bold text-slate-400">24 Okt 2023</td>
|
||||
<td class="px-8 py-5 text-center">
|
||||
<span class="bg-amber-100 text-amber-600 px-4 py-1.5 rounded-lg text-[9px] font-black uppercase tracking-widest">Ongoing</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
// Inisialisasi Ikon Lucide
|
||||
lucide.createIcons();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,199 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Input Activity - Disnaker Pontianak</title>
|
||||
|
||||
<!-- Tailwind -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
<!-- ICON -->
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
|
||||
<!-- Font -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
body { font-family: 'Inter', sans-serif; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="bg-[#F5F7FB] text-slate-700">
|
||||
|
||||
<!-- NAVBAR -->
|
||||
<div class="bg-white px-10 py-4 flex justify-between items-center shadow-sm">
|
||||
|
||||
<h1 class="font-bold text-[#0D215C] tracking-wide">
|
||||
DISNAKER PONTIANAK
|
||||
</h1>
|
||||
|
||||
<div class="flex items-center gap-6 text-sm text-slate-500">
|
||||
<a href="{{ route('dashboard') }}">Dashboard</a>
|
||||
<a href="#">Activity Reports</a>
|
||||
<a href="#" class="text-[#0D215C] font-semibold">Input Activity</a>
|
||||
<a href="#">Settings</a>
|
||||
|
||||
<!-- ICON 3D STYLE -->
|
||||
<div class="flex items-center gap-3 ml-4">
|
||||
|
||||
<!-- NOTIF -->
|
||||
<div class="bg-white p-2 rounded-xl shadow-md hover:shadow-xl hover:-translate-y-1 transition cursor-pointer">
|
||||
<i data-lucide="bell" class="w-5 h-5 text-[#0D215C]"></i>
|
||||
</div>
|
||||
|
||||
<!-- USER -->
|
||||
<div class="bg-white p-2 rounded-xl shadow-md hover:shadow-xl hover:-translate-y-1 transition cursor-pointer">
|
||||
<i data-lucide="user" class="w-5 h-5 text-[#0D215C]"></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<div class="max-w-6xl mx-auto mt-10 px-4">
|
||||
|
||||
<div class="mb-6">
|
||||
<h2 class="text-2xl font-bold text-[#0D215C]">
|
||||
Input Laporan Kegiatan
|
||||
</h2>
|
||||
<p class="text-sm text-slate-400 mt-2 max-w-xl">
|
||||
Silakan lengkapi formulir di bawah ini untuk melaporkan aktivitas lapangan Anda.
|
||||
Pastikan data yang dimasukkan akurat sesuai dengan pelaksanaan tugas.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-6">
|
||||
|
||||
<!-- FORM -->
|
||||
<div class="col-span-2 bg-white p-6 rounded-xl shadow-sm border">
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="text-sm font-semibold text-[#0D215C]">Nama Kegiatan</label>
|
||||
<input type="text" placeholder="Contoh: Monitoring Kepatuhan Perusahaan"
|
||||
class="w-full mt-2 p-3 bg-[#F5F7FB] rounded-lg outline-none focus:ring-2 focus:ring-[#0D215C]">
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
|
||||
<div>
|
||||
<label class="text-sm font-semibold text-[#0D215C]">Tanggal Pelaksanaan</label>
|
||||
<input type="date"
|
||||
class="w-full mt-2 p-3 bg-[#F5F7FB] rounded-lg outline-none focus:ring-2 focus:ring-[#0D215C]">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-sm font-semibold text-[#0D215C]">Lokasi</label>
|
||||
<input type="text" placeholder="Kec. Pontianak Selatan"
|
||||
class="w-full mt-2 p-3 bg-[#F5F7FB] rounded-lg outline-none focus:ring-2 focus:ring-[#0D215C]">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="text-sm font-semibold text-[#0D215C]">Deskripsi Kegiatan</label>
|
||||
<textarea rows="5"
|
||||
placeholder="Uraikan detail jalannya kegiatan..."
|
||||
class="w-full mt-2 p-3 bg-[#F5F7FB] rounded-lg outline-none focus:ring-2 focus:ring-[#0D215C]"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- RIGHT PANEL -->
|
||||
<div class="space-y-6">
|
||||
|
||||
<!-- Upload -->
|
||||
<div class="bg-white p-6 rounded-xl shadow-sm border">
|
||||
|
||||
<h4 class="font-semibold text-[#0D215C] mb-4">
|
||||
Unggah Dokumen
|
||||
</h4>
|
||||
|
||||
<div id="drop-area"
|
||||
onclick="document.getElementById('fileInput').click()"
|
||||
class="border-2 border-dashed rounded-xl p-6 text-center text-slate-400 hover:border-[#0D215C] hover:bg-[#F0F4FF] transition cursor-pointer">
|
||||
|
||||
<p class="text-sm">Klik untuk upload atau drag file ke sini</p>
|
||||
|
||||
<button type="button"
|
||||
class="mt-3 bg-[#0D215C] hover:bg-blue-900 transition text-white px-4 py-2 rounded-lg shadow">
|
||||
Browse Files
|
||||
</button>
|
||||
|
||||
<input type="file" id="fileInput" multiple class="hidden">
|
||||
</div>
|
||||
|
||||
<div id="fileList" class="mt-4 space-y-2 text-sm"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Panduan -->
|
||||
<div class="bg-[#0D215C] text-white p-5 rounded-xl">
|
||||
<h4 class="font-semibold mb-3">Panduan Input</h4>
|
||||
<ul class="text-sm space-y-1 opacity-90">
|
||||
<li>- Gunakan bahasa formal</li>
|
||||
<li>- Lampirkan minimal 1 foto</li>
|
||||
<li>- Data harus valid</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<button class="w-full bg-[#0D215C] hover:bg-blue-900 transition text-white py-3 rounded-xl font-semibold shadow-lg hover:scale-[1.02]">
|
||||
Kirim Laporan
|
||||
</button>
|
||||
|
||||
<p class="text-center text-sm text-slate-400">
|
||||
Simpan Sebagai Draft
|
||||
</p>
|
||||
|
||||
<a href="{{ route('dashboard') }}" class="block text-center text-sm text-blue-600 mt-2">
|
||||
← Kembali ke Dashboard
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- SCRIPT -->
|
||||
<script>
|
||||
lucide.createIcons();
|
||||
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const fileList = document.getElementById('fileList');
|
||||
|
||||
fileInput.addEventListener('change', function () {
|
||||
fileList.innerHTML = "";
|
||||
|
||||
Array.from(this.files).forEach((file, index) => {
|
||||
const item = document.createElement('div');
|
||||
item.className = "flex justify-between items-center bg-[#F5F7FB] p-3 rounded-lg hover:shadow transition";
|
||||
|
||||
item.innerHTML = `
|
||||
<div class="flex items-center gap-2">
|
||||
📄 <span>${file.name}</span>
|
||||
</div>
|
||||
<button onclick="removeFile(${index})" class="text-red-500 hover:text-red-700 font-bold text-lg">
|
||||
×
|
||||
</button>
|
||||
`;
|
||||
|
||||
fileList.appendChild(item);
|
||||
});
|
||||
});
|
||||
|
||||
function removeFile(index) {
|
||||
const dt = new DataTransfer();
|
||||
|
||||
Array.from(fileInput.files).forEach((file, i) => {
|
||||
if (i !== index) dt.items.add(file);
|
||||
});
|
||||
|
||||
fileInput.files = dt.files;
|
||||
fileInput.dispatchEvent(new Event('change'));
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,270 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - Disnaker Pontianak</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: 'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
background-color: #f8fafc;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* --- SISI KIRI (Visual & Branding) --- */
|
||||
.left {
|
||||
width: 50%;
|
||||
background: linear-gradient(135deg, rgba(15, 42, 92, 0.92), rgba(30, 60, 114, 0.85)),
|
||||
url('https://www.pontianak.go.id/themes/pontianak/assets/images/gedung-walikota.jpg');
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
color: white;
|
||||
padding: 60px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.logo img {
|
||||
height: 70px;
|
||||
width: auto;
|
||||
filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
|
||||
}
|
||||
|
||||
.logo h3 {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 1px;
|
||||
line-height: 1.2;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.mid-content {
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 48px;
|
||||
font-weight: 800;
|
||||
line-height: 1.1;
|
||||
margin-bottom: 25px;
|
||||
text-shadow: 0 4px 10px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.title::after {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 60px;
|
||||
height: 6px;
|
||||
background: #3b82f6;
|
||||
margin-top: 20px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 16px;
|
||||
line-height: 1.8;
|
||||
color: #e2e8f0;
|
||||
max-width: 85%;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.footer-left {
|
||||
font-size: 11px;
|
||||
letter-spacing: 3px;
|
||||
color: rgba(255,255,255,0.6);
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* --- SISI KANAN (Form Login) --- */
|
||||
.right {
|
||||
width: 50%;
|
||||
background: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px;
|
||||
}
|
||||
|
||||
.form-box {
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.form-box h2 {
|
||||
font-size: 32px;
|
||||
font-weight: 700;
|
||||
color: #0f172a;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.form-box p {
|
||||
margin-bottom: 40px;
|
||||
color: #64748b;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.input-group label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #1e293b;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.input-group input {
|
||||
width: 100%;
|
||||
padding: 14px 18px;
|
||||
border: 1.5px solid #e2e8f0;
|
||||
border-radius: 12px;
|
||||
font-size: 14px;
|
||||
background: #f8fafc;
|
||||
transition: all 0.3s ease;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-group input:focus {
|
||||
border-color: #3b82f6;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
background: #1e3c72;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
margin-top: 10px;
|
||||
transition: all 0.3s ease;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #0f2a5c;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px rgba(30, 60, 114, 0.2);
|
||||
}
|
||||
|
||||
.btn:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.footer-right {
|
||||
margin-top: 40px;
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
color: #94a3b8;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 992px) {
|
||||
.left { display: none; }
|
||||
.right { width: 100%; background: #f8fafc; }
|
||||
.form-box {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.05);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="left">
|
||||
<div class="logo">
|
||||
<img src="{{ asset('Kalimantan-Barat-Logo-Vector.png') }}" alt="Logo">
|
||||
<h3>DINAS TENAGA KERJA<br>KOTA PONTIANAK</h3>
|
||||
</div>
|
||||
|
||||
<div class="mid-content">
|
||||
<div class="title">
|
||||
Sistem Monitoring <br>
|
||||
Aktivitas Pegawai
|
||||
</div>
|
||||
<div class="desc">
|
||||
Platform terintegrasi untuk pelaporan aktivitas pegawai, pemantauan kinerja institusi,
|
||||
serta peningkatan kualitas administrasi pemerintahan di lingkungan
|
||||
Dinas Tenaga Kerja dan Transmigrasi Kota Pontianak.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="footer-left">
|
||||
TRANSPARANSI • AKUNTABILITAS • INTEGRITAS
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<div class="form-box">
|
||||
<h2>Selamat Datang</h2>
|
||||
<p>Masuk dengan akun Anda untuk mengakses panel.</p>
|
||||
|
||||
<form action="{{ route('dashboard') }}" method="GET">
|
||||
<div class="input-group">
|
||||
<label>Alamat Email</label>
|
||||
<input type="email" name="email" placeholder="nama@disnaker.pontianak.go.id" required>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>Kata Sandi</label>
|
||||
<input type="password" name="password" placeholder="********" required>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn">
|
||||
Masuk ke Sistem
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="footer-right">
|
||||
© 2026 DINAS TENAGA KERJA KOTA PONTIANAK
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\Http\Controllers\Api\PenugasanController;
|
||||
use App\Http\Controllers\Api\NotificationController;
|
||||
use App\Http\Controllers\UnitKerjaController;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API ROUTES - BACKEND Laravel_KP
|
||||
|--------------------------------------------------------------------------
|
||||
| Backend berjalan di port 8000.
|
||||
| Frontend KP-ASOY akan mengakses API ini melalui:
|
||||
| http://127.0.0.1:8000/api
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PUBLIC ROUTES
|
||||
|--------------------------------------------------------------------------
|
||||
| Route yang boleh diakses tanpa login/token.
|
||||
*/
|
||||
|
||||
Route::post('/login', [AuthController::class, 'login']);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PROTECTED ROUTES
|
||||
|--------------------------------------------------------------------------
|
||||
| Semua route di bawah ini wajib menggunakan token Sanctum.
|
||||
| Token dikirim dari frontend melalui:
|
||||
| Http::withToken(session('api_token'))
|
||||
*/
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| AUTH
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Route::post('/logout', [AuthController::class, 'logout']);
|
||||
Route::get('/me', [AuthController::class, 'me']);
|
||||
Route::put('/profile/update', [AuthController::class, 'updateProfile']);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| USER MANAGEMENT
|
||||
|--------------------------------------------------------------------------
|
||||
| Admin/Super Admin membuat akun pegawai/user melalui endpoint ini.
|
||||
*/
|
||||
Route::post('/register', [AuthController::class, 'register'])->middleware('role:admin,superadmin');
|
||||
|
||||
Route::get('/users', function () {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => User::select(
|
||||
'id',
|
||||
'name',
|
||||
'username',
|
||||
'email',
|
||||
'role',
|
||||
'jabatan',
|
||||
'created_at'
|
||||
)->get()
|
||||
]);
|
||||
})->middleware('role:admin,superadmin');
|
||||
|
||||
Route::get('/users/{id}', function ($id) {
|
||||
try {
|
||||
$user = User::findOrFail($id);
|
||||
return response()->json(['success' => true, 'data' => $user]);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'User tidak ditemukan.'], 404);
|
||||
}
|
||||
})->middleware('role:admin,superadmin');
|
||||
|
||||
Route::delete('/users/{id}', function ($id) {
|
||||
try {
|
||||
$user = User::findOrFail($id);
|
||||
if ($user->role === 'superadmin') {
|
||||
return response()->json(['success' => false, 'message' => 'Superadmin tidak dapat dihapus.'], 403);
|
||||
}
|
||||
$user->delete();
|
||||
return response()->json(['success' => true, 'message' => 'User berhasil dihapus.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Gagal menghapus user: ' . $e->getMessage()], 500);
|
||||
}
|
||||
})->middleware('role:admin,superadmin');
|
||||
|
||||
Route::put('/users/{id}', function (Request $request, $id) {
|
||||
$request->validate([
|
||||
'username' => 'nullable|string|unique:users,username,' . $id,
|
||||
]);
|
||||
|
||||
try {
|
||||
$user = User::findOrFail($id);
|
||||
$data = $request->only(['name', 'username', 'role', 'jabatan']);
|
||||
if ($request->filled('password')) {
|
||||
$data['password'] = bcrypt($request->password);
|
||||
}
|
||||
$user->update($data);
|
||||
return response()->json(['success' => true, 'message' => 'User berhasil diupdate.']);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['success' => false, 'message' => 'Gagal update user: ' . $e->getMessage()], 500);
|
||||
}
|
||||
})->middleware('role:admin,superadmin');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DATA PEGAWAI / USER
|
||||
|--------------------------------------------------------------------------
|
||||
| Karena role pegawai di sistem kamu memakai nama "user",
|
||||
| maka data pegawai diambil dari role user.
|
||||
*/
|
||||
Route::get('/pegawai', function () {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => User::where('role', 'user')
|
||||
->select('id', 'name', 'username', 'email', 'role', 'jabatan')
|
||||
->get()
|
||||
]);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DASHBOARD & PENUGASAN / KEGIATAN
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Route::get('/dashboard', [PenugasanController::class, 'dashboard']);
|
||||
|
||||
Route::get('/penugasan', [PenugasanController::class, 'index']);
|
||||
Route::post('/penugasan', [PenugasanController::class, 'store']);
|
||||
|
||||
Route::get('/penugasan/{id}', [PenugasanController::class, 'show']);
|
||||
Route::put('/penugasan/{id}', [PenugasanController::class, 'update']);
|
||||
|
||||
Route::post('/penugasan/{id}/update-status', [PenugasanController::class, 'updateStatus']);
|
||||
Route::post('/penugasan/{id}/delete', [PenugasanController::class, 'destroy']);
|
||||
Route::post('/penugasan/{id}/archive', [PenugasanController::class, 'toggleArchive']);
|
||||
Route::post('/penugasan/{id}/progress', [PenugasanController::class, 'storeProgress']);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| NOTIFIKASI
|
||||
|--------------------------------------------------------------------------
|
||||
| Nanti dipakai frontend user untuk melihat kegiatan yang sudah ditinjau.
|
||||
*/
|
||||
Route::get('/notifications', [NotificationController::class, 'index']);
|
||||
Route::post('/notifications/read', [NotificationController::class, 'markAsRead']);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| UNIT KERJA
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Route::get('/unit-kerja', [UnitKerjaController::class, 'index']);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| EXPORT EXCEL
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
Route::get('/export-penugasan', [PenugasanController::class, 'export']);
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', function () {
|
||||
return 'Laravel hidup';
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
$kernel->handle(Illuminate\Http\Request::capture());
|
||||
|
||||
$users = App\Models\User::where('role', 'user')->get();
|
||||
foreach($users as $u) {
|
||||
$penugasan = App\Models\Penugasan::first();
|
||||
if (!$penugasan) {
|
||||
$penugasan = App\Models\Penugasan::create(['kegiatan' => 'Monitoring Internal', 'status' => 'selesai', 'tanggal_mulai' => now(), 'created_by' => 1]);
|
||||
}
|
||||
$u->notify(new App\Notifications\PenugasanStatusNotification($penugasan, 'selesai', 'disetujui'));
|
||||
}
|
||||
echo "Notifikasi dummy berhasil ditambahkan!\n";
|
||||
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!private/
|
||||
!public/
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,9 @@
|
||||
compiled.php
|
||||
config.php
|
||||
down
|
||||
events.scanned.php
|
||||
maintenance.php
|
||||
routes.php
|
||||
routes.scanned.php
|
||||
schedule-*
|
||||
services.json
|
||||
@@ -0,0 +1,3 @@
|
||||
*
|
||||
!data/
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,2 @@
|
||||
GET http://127.0.0.1:8000/api/pegawai
|
||||
Accept: application/json
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
$token = \App\Models\User::first()->createToken('test')->plainTextToken;
|
||||
|
||||
$response = \Illuminate\Support\Facades\Http::withToken($token)
|
||||
->acceptJson()
|
||||
->post('http://127.0.0.1:8000/api/penugasan/4/update-status', [
|
||||
'status' => 'selesai',
|
||||
]);
|
||||
|
||||
echo "Status Code: " . $response->status() . "\n";
|
||||
echo "Body: " . $response->body() . "\n";
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
|
||||
function testApi($kernel, $method, $uri, $data = [], $token = null) {
|
||||
$server = ['HTTP_ACCEPT' => 'application/json'];
|
||||
if ($token) {
|
||||
$server['HTTP_AUTHORIZATION'] = 'Bearer ' . $token;
|
||||
}
|
||||
$request = Illuminate\Http\Request::create($uri, $method, $data, [], [], $server);
|
||||
$response = $kernel->handle($request);
|
||||
|
||||
$status = $response->getStatusCode();
|
||||
$content = json_decode($response->getContent(), true);
|
||||
|
||||
if ($status >= 400 && $status !== 422) { // 422 is expected for some negative tests
|
||||
echo "FAIL: [$method] $uri returned $status\n";
|
||||
echo "Response: " . $response->getContent() . "\n\n";
|
||||
} else {
|
||||
echo "PASS: [$method] $uri returned $status\n";
|
||||
}
|
||||
return ['status' => $status, 'data' => $content];
|
||||
}
|
||||
|
||||
echo "--- STARTING API TESTS ---\n";
|
||||
|
||||
// 1. LOGIN PEGawai
|
||||
$res = testApi($kernel, 'POST', '/api/login', ['username' => 'hari_disnaker', 'password' => 'password123']);
|
||||
$userToken = $res['data']['data']['token'] ?? null;
|
||||
|
||||
// 2. LOGIN ADMIN
|
||||
$res = testApi($kernel, 'POST', '/api/login', ['username' => 'welprida_admin', 'password' => 'password123']);
|
||||
$adminToken = $res['data']['data']['token'] ?? null;
|
||||
|
||||
// 3. LOGIN SUPERADMIN
|
||||
$res = testApi($kernel, 'POST', '/api/login', ['username' => 'sutowo_superadmin', 'password' => 'password123']);
|
||||
$superToken = $res['data']['data']['token'] ?? null;
|
||||
|
||||
if (!$userToken || !$adminToken || !$superToken) {
|
||||
die("Tokens missing, cannot proceed.\n");
|
||||
}
|
||||
|
||||
// --- PEGAWAI TESTS ---
|
||||
echo "\n--- ROLE: PEGAWAI ---\n";
|
||||
testApi($kernel, 'GET', '/api/dashboard', [], $userToken);
|
||||
testApi($kernel, 'GET', '/api/penugasan', [], $userToken);
|
||||
$createTask = testApi($kernel, 'POST', '/api/penugasan', [
|
||||
'kegiatan' => 'Tugas Testing',
|
||||
'tanggal_mulai' => '2026-06-01',
|
||||
'pegawai_ids' => [4] // hari_disnaker ID is likely 4
|
||||
], $userToken);
|
||||
$taskId = $createTask['data']['data']['id'] ?? null;
|
||||
|
||||
if ($taskId) {
|
||||
testApi($kernel, 'GET', '/api/penugasan/' . $taskId, [], $userToken);
|
||||
testApi($kernel, 'PUT', '/api/penugasan/' . $taskId, [
|
||||
'kegiatan' => 'Tugas Testing Updated',
|
||||
'tanggal_mulai' => '2026-06-01',
|
||||
'pegawai_ids' => [4]
|
||||
], $userToken);
|
||||
testApi($kernel, 'POST', '/api/penugasan/' . $taskId . '/update-status', ['status' => 'selesai'], $userToken);
|
||||
}
|
||||
|
||||
// --- ADMIN TESTS ---
|
||||
echo "\n--- ROLE: ADMIN ---\n";
|
||||
testApi($kernel, 'GET', '/api/dashboard', [], $adminToken);
|
||||
testApi($kernel, 'GET', '/api/users', [], $adminToken);
|
||||
testApi($kernel, 'GET', '/api/pegawai', [], $adminToken);
|
||||
|
||||
// Create User
|
||||
$createUser = testApi($kernel, 'POST', '/api/register', [
|
||||
'name' => 'User Test',
|
||||
'username' => 'usertest_'.time(),
|
||||
'email' => 'usertest'.time().'@mail.com',
|
||||
'password' => 'password123',
|
||||
'role' => 'user'
|
||||
], $adminToken);
|
||||
$newUserId = $createUser['data']['user']['id'] ?? null;
|
||||
|
||||
if ($newUserId) {
|
||||
testApi($kernel, 'PUT', '/api/users/' . $newUserId, ['name' => 'User Test Updated', 'role' => 'user'], $adminToken);
|
||||
testApi($kernel, 'DELETE', '/api/users/' . $newUserId, [], $adminToken);
|
||||
}
|
||||
|
||||
// --- SUPER ADMIN TESTS ---
|
||||
echo "\n--- ROLE: SUPER ADMIN ---\n";
|
||||
testApi($kernel, 'GET', '/api/dashboard', [], $superToken);
|
||||
if ($taskId) {
|
||||
testApi($kernel, 'POST', '/api/penugasan/' . $taskId . '/update-status', ['status' => 'telah_ditinjau'], $superToken);
|
||||
testApi($kernel, 'POST', '/api/penugasan/' . $taskId . '/delete', ['alasan' => 'Dibatalkan karena testing selesai'], $superToken);
|
||||
}
|
||||
testApi($kernel, 'GET', '/api/export-penugasan', [], $superToken);
|
||||
|
||||
echo "\n--- TESTS COMPLETED ---\n";
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
$token = 'simulate-from-db';
|
||||
$user = \App\Models\User::where('role', 'admin')->first();
|
||||
$tokenStr = $user->createToken('test')->plainTextToken;
|
||||
|
||||
$response = \Illuminate\Support\Facades\Http::withToken($tokenStr)
|
||||
->acceptJson()
|
||||
->post('http://127.0.0.1:8000/api/penugasan/4/update-status', [
|
||||
'status' => 'on_progres',
|
||||
]);
|
||||
|
||||
echo "Status: " . $response->status() . "\n";
|
||||
echo "Body: " . $response->body() . "\n";
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
$token = \App\Models\User::where('role', 'admin')->first()->createToken('test')->plainTextToken;
|
||||
|
||||
$response = \Illuminate\Support\Facades\Http::withToken($token)
|
||||
->acceptJson()
|
||||
->post('http://127.0.0.1:8000/api/penugasan/4/update-status', [
|
||||
'status' => 'proses',
|
||||
]);
|
||||
|
||||
echo "Status: " . $response->status() . "\n";
|
||||
echo "Body: " . $response->body() . "\n";
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
|
||||
$penugasan = \App\Models\Penugasan::findOrFail(4);
|
||||
try {
|
||||
\Illuminate\Support\Facades\Notification::send($penugasan->petugas, new \App\Notifications\PenugasanStatusNotification($penugasan, 'selesai', 'disetujui'));
|
||||
echo "OK\n";
|
||||
} catch (\Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
test('the application returns a successful response', function () {
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Test Case
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||
| need to change it using the "pest()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
pest()->extend(TestCase::class)
|
||||
// ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
|
||||
->in('Feature');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expectations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||
|
|
||||
*/
|
||||
|
||||
expect()->extend('toBeOne', function () {
|
||||
return $this->toBe(1);
|
||||
});
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Functions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||
| global functions to help you to reduce the number of lines of code in your test files.
|
||||
|
|
||||
*/
|
||||
|
||||
function something()
|
||||
{
|
||||
// ..
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user