diff --git a/app/Http/Controllers/PermohonanController.php b/app/Http/Controllers/PermohonanController.php index e2a3da4..b6a43f6 100644 --- a/app/Http/Controllers/PermohonanController.php +++ b/app/Http/Controllers/PermohonanController.php @@ -33,25 +33,20 @@ public function store(PermohonanRequest $request) { - $validate = $request->validated(); if ($validate) { try { // Save to database Permohonan::create($validate); return redirect() - ->route('permohonan.index') - ->with('success', 'Permohonan created successfully'); + ->route('permohonan.index')->with('success', 'Permohonan created successfully'); } catch (Exception $e) { return redirect() - ->route('permohonan.create') - ->with('error', 'Failed to create permohonan' . $e->getMessage()); + ->route('permohonan.create')->with('error', 'Failed to create permohonan' . $e->getMessage()); } } else { return redirect() - ->route('permohonan.create') - ->with('success', 'error naon iye') - ->withInput(); + ->route('permohonan.create')->with('success', 'error naon iye')->withInput(); } } @@ -118,14 +113,15 @@ try { // Update in database $permohonan = Permohonan::find($id); + if ($permohonan->status == 'revisi') { + $validate['status'] = 'order'; + } $permohonan->update($validate); return redirect() - ->route('permohonan.index') - ->with('success', 'Permohonan updated successfully'); + ->route('permohonan.index')->with('success', 'Permohonan updated successfully'); } catch (Exception $e) { return redirect() - ->route('permohonan.edit', $id) - ->with('error', 'Failed to update permohonan'); + ->route('permohonan.edit', $id)->with('error', 'Failed to update permohonan'); } } } @@ -313,11 +309,12 @@ return view('lpj::permohonan.show', compact('permohonan')); } - public function print($id){ + public function print($id) + { $permohonan = Permohonan::find($id); return view('lpj::permohonan.print', compact('permohonan')); -// $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan')); - // return $pdf->stream(); + // $pdf = Pdf::loadView('lpj::permohonan.print', compact('permohonan')); + // return $pdf->stream(); } }