Skip to content

Commit 90e5642

Browse files
committed
Add DRPP file handling to KakSp2d and DaftarSp2d models; update migration for arsip_drpp column
1 parent e4a4b64 commit 90e5642

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

app/Models/KakSp2d.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ protected static function booted(): void
3030
->copy($arsipSsp,
3131
session('year').'/'.'arsip-dokumens'.'/'.$kakSp2d->kerangka_acuan_id.'/SSP_'.DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->nomor_spp.'.pdf');
3232
}
33+
$arsipDrpp = DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->arsip_drpp;
34+
if ($arsipDrpp) {
35+
Storage::disk('arsip')
36+
->copy($arsipDrpp,
37+
session('year').'/'.'arsip-dokumens'.'/'.$kakSp2d->kerangka_acuan_id.'/DRPP_'.DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->nomor_spp.'.pdf');
38+
}
3339
});
3440
static::deleting(function (KakSp2d $kakSp2d) {
3541
Storage::disk('arsip')
@@ -42,6 +48,8 @@ protected static function booted(): void
4248
->delete(session('year').'/'.'arsip-dokumens'.'/'.$kakSp2d->kerangka_acuan_id.'/SPP_'.DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->nomor_spp.'.pdf');
4349
Storage::disk('arsip')
4450
->delete(session('year').'/'.'arsip-dokumens'.'/'.$kakSp2d->kerangka_acuan_id.'/SSP_'.DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->nomor_spp.'.pdf');
51+
Storage::disk('arsip')
52+
->delete(session('year').'/'.'arsip-dokumens'.'/'.$kakSp2d->kerangka_acuan_id.'/DRPP_'.DaftarSp2d::find($kakSp2d->daftar_sp2d_id)->nomor_spp.'.pdf');
4553
});
4654
}
4755
}

app/Nova/DaftarSp2d.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@ public function fields(NovaRequest $request)
163163
:
164164
Text::make('Lampiran SPM', fn () => null)->onlyOnDetail(),
165165

166+
Filepond::make('DRPP', 'arsip_drpp')
167+
->disk('arsip')
168+
->disableCredits()
169+
->onlyOnForms()
170+
->mimesTypes(['application/pdf'])
171+
->creationRules('required')
172+
->path(session('year').'/'.static::uriKey().'/'.$this->nomor_spp)
173+
->storeAs(function (Request $request) {
174+
$originalName = 'DRPP_'.$this->nomor_spp;
175+
$extension = $request->arsip_drpp->getClientOriginalExtension();
176+
177+
return $originalName.'_'.uniqid().'.'.$extension;
178+
})
179+
->canSee(fn () => Policy::make()->allowedFor('arsiparis,ppspm')->get())
180+
->prunable(),
181+
$this->arsip_drpp ?
182+
URL::make('DRPP', fn () => Storage::disk('arsip')
183+
->url($this->arsip_drpp))
184+
->displayUsing(fn () => 'Lihat')->onlyOnDetail()
185+
:
186+
Text::make('DRPP', fn () => null)->onlyOnDetail(),
187+
166188
Filepond::make('SSP', 'arsip_ssp')
167189
->disk('arsip')
168190
->disableCredits()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('daftar_sp2ds', function (Blueprint $table) {
15+
$table->after('arsip_lampiran', function (Blueprint $table) {
16+
$table->string('arsip_drpp')->nullable();
17+
});
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*/
24+
public function down(): void
25+
{
26+
Schema::table('daftar_sp2ds', function (Blueprint $table) {
27+
$table->dropColumn('arsip_drpp');
28+
});
29+
}
30+
};

0 commit comments

Comments
 (0)