diff --git a/app/Http/Controllers/PermohonanController.php b/app/Http/Controllers/PermohonanController.php index d45c873..1392157 100644 --- a/app/Http/Controllers/PermohonanController.php +++ b/app/Http/Controllers/PermohonanController.php @@ -11,6 +11,7 @@ use Modules\Lpj\Models\Branch; use Modules\Lpj\Models\Debiture; use Modules\Lpj\Models\Permohonan; + use Modules\Lpj\Models\StatusPermohonan; use Modules\Lpj\Models\TujuanPenilaian; class PermohonanController extends Controller @@ -24,7 +25,6 @@ public function store(PermohonanRequest $request) { - $validate = $request->validated(); if ($validate) { @@ -37,7 +37,7 @@ } catch (Exception $e) { return redirect() ->route('permohonan.create') - ->with('error', 'Failed to create permohonan'. $e->getMessage()); + ->with('error', 'Failed to create permohonan' . $e->getMessage()); } } else { return redirect() @@ -47,26 +47,19 @@ } } - public function create() + public function create(){ + + return view('lpj::permohonan.create'); + } + + public function createPermohonan($debitur) { $branches = Branch::all(); - $debitures = Debiture::all(); + $debitur = Debiture::find($debitur); $tujuanPenilaian = TujuanPenilaian::all(); - $status = [ - 'order' => 'Order', - 'revisi' => 'Revisi', - 'register' => 'Register', - 'assign' => 'Assign', - 'survey' => 'Survey', - 'finalisasi' => 'Proses Laporan', - 'approved' => 'Diterima', - 'rejected' => 'Ditolak', - 'cancel' => 'Dibatalkan', - 'finished' => 'Selesai', - 'not_started' => 'Belum dimulai', - ]; + $status = StatusPermohonan::all(); - return view('lpj::permohonan.form', compact('branches', 'debitures', 'tujuanPenilaian','status')); + return view('lpj::permohonan.form', compact('branches', 'debitur', 'tujuanPenilaian', 'status')); } public function edit($id) @@ -75,23 +68,11 @@ $branches = Branch::all(); $debitures = Debiture::all(); $tujuanPenilaian = TujuanPenilaian::all(); - $status = [ - 'order' => 'Order', - 'revisi' => 'Revisi', - 'register' => 'Register', - 'assign' => 'Assign', - 'survey' => 'Survey', - 'finalisasi' => 'Proses Laporan', - 'approved' => 'Diterima', - 'rejected' => 'Ditolak', - 'cancel' => 'Dibatalkan', - 'finished' => 'Selesai', - 'not_started' => 'Belum dimulai', - ]; + $status = StatusPermohonan::all(); return view( 'lpj::permohonan.form', - compact('permohonan', 'branches', 'debitures', 'tujuanPenilaian','status'), + compact('permohonan', 'branches', 'debitures', 'tujuanPenilaian', 'status'), ); } diff --git a/app/Http/Requests/JenisJaminanRequest.php b/app/Http/Requests/JenisJaminanRequest.php index 4e2da8f..0295054 100644 --- a/app/Http/Requests/JenisJaminanRequest.php +++ b/app/Http/Requests/JenisJaminanRequest.php @@ -2,6 +2,7 @@ namespace Modules\Lpj\Http\Requests; + use Haruncpi\LaravelIdGenerator\IdGenerator; use Illuminate\Foundation\Http\FormRequest; class JenisJaminanRequest extends FormRequest @@ -12,16 +13,10 @@ public function rules() : array { - $rules = [ + return [ + 'code' => 'required|max:5', 'name' => 'required|max:255', ]; - - if ($this->method() == 'PUT') { - $rules['code'] = 'required|max:50|unique:jenis_jaminan,code,' . $this->id; - } else { - $rules['code'] = 'required|max:50|unique:jenis_jaminan,code'; - } - return $rules; } /** @@ -32,4 +27,16 @@ { return true; } + + public function prepareForValidation() + : void + { + if ($this->method() == 'POST') { + $this->merge([ + 'code' => IdGenerator::generate( + ['table' => 'jenis_jaminan', 'length' => 5, 'prefix' => 'JJ', 'field' => 'code'], + ), + ]); + } + } } diff --git a/app/Http/Requests/PermohonanRequest.php b/app/Http/Requests/PermohonanRequest.php index 5a576dd..e4c4bd8 100644 --- a/app/Http/Requests/PermohonanRequest.php +++ b/app/Http/Requests/PermohonanRequest.php @@ -40,10 +40,11 @@ if (!$this->id) { $this->merge([ 'nomor_registrasi' => IdGenerator::generate( - ['table' => 'permohonan', 'length' => 10, 'prefix'=>'REG', 'field' => 'nomor_registrasi'], + ['table' => 'permohonan', 'length' => 10, 'prefix' => 'REG', 'field' => 'nomor_registrasi'], ), 'tanggal_permohonan' => date('Y-m-d'), 'user_id' => auth()->user()->id, + 'branch_id' => auth()->user()->branch_id, ]); } } diff --git a/database/migrations/2024_08_23_073834_create_permohonan_jaminan_table.php b/database/migrations/2024_08_23_073834_create_permohonan_jaminan_table.php new file mode 100644 index 0000000..ad46f00 --- /dev/null +++ b/database/migrations/2024_08_23_073834_create_permohonan_jaminan_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignIdFor(Permohonan::class)->constrained('permohonan'); + $table->foreignIdFor(DokumenJaminan::class)->constrained('dokumen_jaminan'); + $table->boolean('status')->default(true)->nullable(); + $table->timestamps(); + $table->softDeletes(); + + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down() + : void + { + Schema::dropIfExists('permohonan_jaminan'); + } + }; diff --git a/resources/views/debitur/edit.blade.php b/resources/views/debitur/edit.blade.php index a8cca46..8e2935a 100644 --- a/resources/views/debitur/edit.blade.php +++ b/resources/views/debitur/edit.blade.php @@ -10,12 +10,16 @@
- Back + @if(request()->get('from') == 'permohonan') + Back + @else + Back + @endif
diff --git a/resources/views/permohonan/create.blade.php b/resources/views/permohonan/create.blade.php new file mode 100644 index 0000000..eaf9e31 --- /dev/null +++ b/resources/views/permohonan/create.blade.php @@ -0,0 +1,184 @@ +@extends('layouts.main') + +@section('breadcrumbs') + {{ Breadcrumbs::render(request()->route()->getName()) }} +@endsection + +@section('content') +
+
+
+

+ Daftar Debitur +

+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + +
+ + + Cif + + + Nomor Rekening + + + Debitur + + + Cabang + + + Email + + + Phone + + + Alamat + + Action
+
+ +
+
+
+@endsection + +@push('scripts') + + + +@endpush diff --git a/resources/views/permohonan/form.blade.php b/resources/views/permohonan/form.blade.php index 091c4d5..8dbe82f 100644 --- a/resources/views/permohonan/form.blade.php +++ b/resources/views/permohonan/form.blade.php @@ -50,33 +50,6 @@
-
- -
- - @error('branch_id') - {{ $message }} - @enderror -
-
-