feat(penilai): tambahkan fitur upload file paparan
- Menambahkan metode edit untuk menampilkan form upload file paparan. - Menambahkan metode storePaparan untuk menyimpan file paparan ke database. - Membuat migrasi untuk menambahkan kolom file_paparan pada tabel penilai. - Menambahkan tampilan edit.blade.php untuk form upload. - Memperbarui tampilan show.blade.php untuk mengarahkan ke form edit. - Menambahkan breadcrumb untuk navigasi ke halaman upload file paparan. - Memperbarui rute untuk mendukung pengeditan dan penyimpanan file paparan.
This commit is contained in:
@@ -246,11 +246,13 @@ class PenilaiController extends Controller
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('lpj::edit');
|
||||
$permohonan = Permohonan::with('debiture')->find($id);
|
||||
return view('lpj::penilai.edit',compact('permohonan'));
|
||||
}
|
||||
|
||||
|
||||
public function storePaparan($id)
|
||||
|
||||
public function storePaparan(Request $request, $id)
|
||||
{
|
||||
try {
|
||||
$permohonan = Permohonan::findOrFail($id);
|
||||
@@ -269,17 +271,20 @@ class PenilaiController extends Controller
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'diperbarui ke status paparan dan dikirim ke So untuk proses lebih lanjut.'
|
||||
], 200);
|
||||
if($request->hasFile('file_paparan')) {
|
||||
$file = $request->file('file_paparan');
|
||||
$path = $file->store('public/file_paparan');
|
||||
|
||||
$penilai = Penilai::where('permohonan_id', $id)->first();
|
||||
$penilai->file_paparan = $path;
|
||||
$penilai->save();
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('penilai.show',['id'=>$id])->with('success', 'diperbarui ke status paparan dan dikirim ke So untuk proses lebih lanjut.');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Terjadi kesalahan saat memproses permohonan.',
|
||||
'error' => $e->getMessage()
|
||||
], 500);
|
||||
return redirect()->route('penilai.show',['id'=>$id])->with('error', 'Terjadi kesalahan saat memproses permohonan.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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('penilai', function (Blueprint $table) {
|
||||
$table->string('file_paparan')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('penilai', function (Blueprint $table) {
|
||||
$table->dropColumn('file_paparan');
|
||||
});
|
||||
}
|
||||
};
|
||||
72
resources/views/penilai/edit.blade.php
Normal file
72
resources/views/penilai/edit.blade.php
Normal file
@@ -0,0 +1,72 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('penilai.edit') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<div class="card-title flex flex-row gap-1.5">
|
||||
Upload File Paparan
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('pembayaran.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('penilai.storePaparan',['id'=> $permohonan->id]) }}" method="POST" class="grid gap-5" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nomor Registrasi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input readonly type="text" name="nomor_registrasi" id="nomor_registrasi" class="input w-full @error('nomor_registrasi') border-danger bg-danger-light @enderror" value="{{ old('nomor_registrasi', $permohonan->nomor_registrasi ?? '') }}" placeholder="Nomor Registrasi">
|
||||
@error('nomor_registrasi')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Debitur
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input readonly type="text" name="debitur" id="debitur" class="input w-full @error('debitur') border-danger bg-danger-light @enderror" value="{{ old('debitur', $permohonan->debiture->name ?? '') }}" placeholder="Debitur">
|
||||
@error('debitur')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
File Paparan
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input type="file" name="file_paparan" id="file_paparan" class="file-input w-full @error('file_paparan') border-danger bg-danger-light @enderror" accept=".pdf,.jpg,.jpeg,.png">
|
||||
@error('file_paparan')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Proses
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
|
||||
@push('scripts')
|
||||
|
||||
@endpush
|
||||
@@ -560,47 +560,11 @@
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes'
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: `/penilai/storePaparan/${permohonanId}`,
|
||||
type: "PUT",
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// window.location.reload();
|
||||
hideLoadingSwal();
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
window.location.reload();
|
||||
window.location.href = `/penilai/${permohonanId}/edit`;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.log('Error checking button status:', error, status, xhr);
|
||||
if (xhr.responseJSON.message) {
|
||||
// window.location.reload();
|
||||
hideLoadingSwal();
|
||||
|
||||
} else {
|
||||
// window.location.reload();
|
||||
hideLoadingSwal();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function savePenilai() {
|
||||
showLoadingSwal('Mengirim data keserver ...');
|
||||
|
||||
@@ -587,6 +587,12 @@
|
||||
$trail->push('Detail Penilai');
|
||||
});
|
||||
|
||||
Breadcrumbs::for('penilai.edit', function (BreadcrumbTrail $trail) {
|
||||
$trail->parent('penilai');
|
||||
$trail->push('Upload File Paparan');
|
||||
});
|
||||
|
||||
|
||||
Breadcrumbs::for('penilai.standard', function (BreadcrumbTrail $trail) {
|
||||
$trail->parent('penilai.show');
|
||||
$trail->push('Standard');
|
||||
|
||||
@@ -561,6 +561,7 @@ Route::middleware(['auth'])->group(function () {
|
||||
|
||||
Route::name('penilai.')->prefix('penilai')->group(function () {
|
||||
Route::get('/', [PenilaiController::class, 'index'])->name('index');
|
||||
Route::get('/{id}/edit', [PenilaiController::class, 'edit'])->name('edit');
|
||||
Route::get('/{id}/show', [PenilaiController::class, 'show'])->name('show');
|
||||
Route::get('datatables', [PenilaiController::class, 'dataForDatatables'])->name('dataForTables');
|
||||
|
||||
@@ -575,7 +576,7 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::get('resume', [PenilaiController::class, 'resume'])->name('resume');
|
||||
Route::get('memo', [PenilaiController::class, 'memo'])->name('memo');
|
||||
Route::get('paparan', [PenilaiController::class, 'paparan'])->name('paparan');
|
||||
Route::put('storePaparan/{id}', [PenilaiController::class, 'storePaparan'])->name('storePaparan');
|
||||
Route::post('storePaparan/{id}', [PenilaiController::class, 'storePaparan'])->name('storePaparan');
|
||||
Route::get('rap', [PenilaiController::class, 'rap'])->name('rap');
|
||||
Route::get('/check-status-lpj', [PenilaiController::class, 'checkStatusLpj'])->name('check.status.lpj');
|
||||
Route::get('/check-laporan', [PenilaiController::class, 'checkPrintOutLaporan'])->name('check-laporan');
|
||||
|
||||
Reference in New Issue
Block a user