Tambahkan fitur pembatalan permohonan

- Menambahkan controller, view, dan route untuk mengelola pembatalan permohonan.
- Memperbarui tampilan daftar permohonan dan menyesuaikan elemen UI terkait pembatalan.
- Integrasi logika validasi dan penyimpanan data pembatalan.
- Membuat endpoint datatable untuk kelola data pembatalan permohonan.
This commit is contained in:
Daeng Deni Mardaeni
2024-12-23 15:44:31 +07:00
parent e5d4874af1
commit ba029a89a6
7 changed files with 490 additions and 56 deletions

View File

@@ -11,6 +11,7 @@
use Modules\Location\Models\District;
use Modules\Location\Models\Province;
use Modules\Location\Models\Village;
use Modules\Lpj\Models\PermohonanPembatalan;
use Modules\Lpj\Exports\PermohonanExport;
use Modules\Lpj\Http\Requests\PermohonanRequest;
use Modules\Lpj\Models\Branch;
@@ -25,7 +26,7 @@
class PermohonanController extends Controller
{
public $user;
public $user;
protected $historyService;
public function __construct(PermohonanHistoryService $historyService)
@@ -46,7 +47,7 @@
// Process file upload
$filePath = null;
if ($request->hasFile('attachment')) {
$file = $request->file('attachment');
$file = $request->file('attachment');
$fileName = time() . '_' . $file->getClientOriginalName();
$filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
}
@@ -65,7 +66,7 @@
$keterangan,
[], // beforeRequest is empty for new permohonan
$permohonan->toArray(),
$filePath
$filePath,
);
return redirect()
->route('permohonan.index')->with('success', 'Permohonan created successfully');
@@ -136,7 +137,7 @@
public function update(PermohonanRequest $request, $id)
{
$permohonan = Permohonan::findOrFail($id);
$permohonan = Permohonan::findOrFail($id);
$beforeRequest = $permohonan->toArray();
$validate = $request->validated();
@@ -203,10 +204,10 @@
// Get the total count of records
$totalRecords = $query->count();
$size = $request->get('size', 10);
if ($size == 0) {
$size = 10;
}
$size = $request->get('size', 10);
if ($size == 0) {
$size = 10;
}
// Apply pagination if provided
if ($request->has('page') && $request->has('size')) {
@@ -221,7 +222,7 @@
$filteredRecords = $query->count();
// Get the data for the current page
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian','penilaian'])->get();
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian'])->get();
// Calculate the page count
$pageCount = ceil($totalRecords / $size);