Membuat Fitur Menu KJPP part 2

This commit is contained in:
2024-09-24 17:41:24 +07:00
parent 8b4dd34b51
commit 33ba88a276
5 changed files with 24 additions and 27 deletions

View File

@@ -6,17 +6,14 @@ use Illuminate\Http\Request;
use Modules\Lpj\Models\KJPP;
use Illuminate\Http\Response;
use Modules\Lpj\Models\Branch;
use Modules\Location\Models\City;
use Modules\Lpj\Models\IjinUsaha;
use Modules\Lpj\Exports\KJPPExport;
use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;
use Modules\Location\Models\District;
use Modules\Lpj\Models\JenisJaminan;
use Modules\Location\Models\Province;
use Modules\Location\Models\Village;
use Illuminate\Support\Facades\Storage;
use Modules\Lpj\Http\Requests\KJPPRequest;
use Throwable;
class KJPPController extends Controller
{
@@ -49,22 +46,22 @@ class KJPPController extends Controller
{
$validate = $request->validated();
if ($validate) {
try {
$file = $request->file('attachment');
$filename = time() . '.' . $file->getClientOriginalExtension();
$file = $request->file('attachment');
$filename = $file ? time() . '.' . $file->getClientOriginalExtension() : 'default.pdf';
if ($file) {
$file->storeAs('uploads_pdf', $filename, 'public');
KJPP::create($validate);
return redirect()
->route('basicdata.kjpp.index')
->with('success', 'Ijin Usaha created successfully');
} catch (Throwable $e) {
return redirect()
->route('basicdata.kjpp.create')
->with('error', 'Failed to create ijin Usaha: ' . $e);
} else {
Storage::copy('/home/bagi/Downloads/default.pdf', 'public/uploads_pdf/' . $filename);
}
dd($validate);
KJPP::create($validate);
return redirect()
->route('basicdata.kjpp.index')
->with('success', 'Ijin Usaha created successfully');
}
}

View File

@@ -32,9 +32,9 @@ class KJPPRequest extends FormRequest
'nomor_hp_pic_admin' => 'required|numeric|digits_between:10,15',
'nama_pic_marketing' => 'required|string|not_regex:/^\d+$/|max:255',
'nomor_hp_pic_marketing' => 'required|numeric|digits_between:10,15',
'ijin_usaha_id' => 'nullable|exists:ijin_usaha,id',
'jenis_aset_id' => 'nullable|exists:jenis_jaminan,id',
'attachment' => 'required|mimes:pdf|max:1024'
'ijin_usaha.*' => 'nullable',
'jenis_jaminan.*' => 'nullable',
'attachment' => 'nullable|mimes:pdf|max:1024'
];
if ($this->method() == 'PUT') {
@@ -115,7 +115,6 @@ class KJPPRequest extends FormRequest
'nomor_hp_pic_marketing.required' => 'Nomor HP PIC Marketing Wajib diisi!',
'nomor_hp_pic_marketing.numeric' => 'Nomor HP PIC Marketing harus berupa angka!',
'nomor_hp_pic_marketing.digits_between' => 'Nomor HP PIC Marketing minimum 10 digit dan maksimum 15 digit!',
'attachment.required' => 'Attachment Wajib diisi!',
'attachment.mimes' => 'Attachment harus berformat pdf!',
'attachment.max' => 'Attachment berukuran maksimum 1 MB!',
];

View File

@@ -35,7 +35,7 @@ return new class extends Migration
$table->string('nomor_hp_pic_marketing');
$table->string('ijin_usaha_id')->nullable();
$table->string('jenis_aset_id')->nullable();
$table->string('attachment');
$table->string('attachment')->nullable();
$table->boolean('status')->default(true)->nullable();
$table->char('authorized_status', 1)->nullable();
$table->timestamp('authorized_at')->nullable();

View File

@@ -13,6 +13,7 @@
@method('PUT')
@endif
@csrf
<div class="card pb-2.5">
<div class="card-header" id="basic_settings">
<h3 class="card-title">
@@ -350,11 +351,11 @@
@if (isset($kjpp->ijin_usaha_id))
<input type="checkbox"
@if (in_array($row->code, old('ijin_usaha_id', json_decode($kjpp->ijin_usaha_id, true)))) {{ 'checked' }} @endif
value="{{ $row->code }}" name="ijin_usaha_id[]" />
value="{{ $row->code }}" name="ijin_usaha[]" />
@else
<input type="checkbox"
@if (in_array($row->code, old('ijin_usaha_id', []))) {{ 'checked' }} @endif
value="{{ $row->code }}" name="ijin_usaha_id[]" />
value="{{ $row->code }}" name="ijin_usaha[]" />
@endif
<span class="switch-label">
{{ $row->name }}
@@ -373,11 +374,11 @@
@if (isset($kjpp->jenis_aset_id))
<input type="checkbox"
@if (in_array($row->code, old('jenis_aset_id', json_decode($kjpp->jenis_aset_id, true)))) {{ 'checked' }} @endif
value="{{ $row->code }}" name="jenis_aset_id[]" />
value="{{ $row->code }}" name="jenis_jaminan[]" />
@else
<input type="checkbox"
@if (in_array($row->code, old('jenis_aset_id', []))) {{ 'checked' }} @endif
value="{{ $row->code }}" name="jenis_aset_id[]" />
value="{{ $row->code }}" name="jenis_jaminan[]" />
@endif
<span class="switch-label">
{{ $row->name }}

View File

@@ -123,10 +123,10 @@
return checkbox.outerHTML.trim();
},
},
nomor: {
code: {
title: 'Nomor KJPP',
},
nama_kjpp: {
name: {
title: 'Nama KJPP',
},
jenis_kantor: {