Skip to content

Commit 9a8b6aa

Browse files
committed
fix some error
1 parent 833fb13 commit 9a8b6aa

25 files changed

+359
-63
lines changed

app/Helpers/Cetak.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function kak($id)
105105
'nomor' => NaskahKeluar::find($data->naskah_keluar_id)->nomor,
106106
'tanggal' => Helper::terbilangTanggal($data->tanggal),
107107
'rincian' => Helper::hapusTitikAkhirKalimat($data->rincian),
108-
'unit' => UnitKerja::cache()->get('all')->where('id', $data->unit_kerja_id)->first()->unit,
108+
'unit' => UnitKerja::cache()->get('all')->where('id', $data->unit_kerja_id)->first()->unit ?? '',
109109
'latar_belakang' => Helper::hapusTitikAkhirKalimat($data->latar),
110110
'maksud' => Helper::hapusTitikAkhirKalimat($data->maksud),
111111
'tujuan' => Helper::hapusTitikAkhirKalimat($data->tujuan),

app/Helpers/Helper.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ class Helper
5959
'12' => 'Desember',
6060
];
6161

62-
/**
63-
* Role admin|kpa|kepala|ppk|bendahara|ppspm|koordinator|anggota|pbj|bmn.
64-
*
65-
* @var array
66-
*/
6762
public static $role = [
6863
'kepala' => 'Kepala',
6964
'ppk' => 'Pejabat Pembuat Komitmen',
@@ -315,7 +310,7 @@ public static function nomor($tanggal, $jenis_naskah_id, $unit_kerja_id, $kode_a
315310
*/
316311
public static function getPengelola($role)
317312
{
318-
$pengelola_id = Pengelola::cache()->get('all')->where('role', $role)->first()->user_id;
313+
$pengelola_id = Pengelola::cache()->get('all')->where('role', $role)->first()->user_id ?? '';
319314

320315
return User::cache()->get('all')->where('id', $pengelola_id)->first();
321316
}
@@ -577,7 +572,7 @@ public static function getDetailAnggaran($mak, $level = 'akun', bool $kode_prefi
577572
];
578573
$detail = KamusAnggaran::cache()->get('all')->filter(function ($item, $key) use ($mak, $length, $level) {
579574
return Str::of($item->mak)->startsWith(Str::substr($mak, 0, $length[$level])) && Str::of($item->mak)->length == $length[$level];
580-
})->first()->detail;
575+
})->first()->detail ?? '';
581576

582577
return $kode_prefix ? $kode[$level].$detail : $detail;
583578
}
@@ -593,7 +588,7 @@ public static function getJenisKontrak($tahun, $bulan): array
593588
{
594589
$tanggal = Carbon::createFromDate($tahun, $bulan)->startOfMonth();
595590

596-
return JenisKontrak::cache()->get('all')->where('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first()->jenis;
591+
return JenisKontrak::cache()->get('all')->where('tanggal', '<=', $tanggal)->sortByDesc('tanggal')->first()->jenis ?? '';
597592
}
598593

599594
/**
@@ -799,7 +794,7 @@ public static function formatSpj($spesifikasi)
799794
*/
800795
public static function getTemplatePath($jenis)
801796
{
802-
$file = Template::cache()->get('all')->where('slug', 'template_'.$jenis)->first()->file;
797+
$file = Template::cache()->get('all')->where('slug', 'template_'.$jenis)->first()->file ?? '';
803798

804799
return Storage::disk('templates')->path($file);
805800
}
@@ -828,7 +823,7 @@ public static function hapusTitikAkhirKalimat($kalimat)
828823

829824
public static function setOptionsMataAnggaran($tahun)
830825
{
831-
$dipa_id = Dipa::cache()->get('all')->where('tahun', $tahun)->first()->id;
826+
$dipa_id = Dipa::cache()->get('all')->where('tahun', $tahun)->first()->id ?? '';
832827

833828
return self::setOptions(MataAnggaran::cache()->get('all')->where('dipa_id', $dipa_id), 'mak', 'mak');
834829
}

app/Imports/DaftarHonorImport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function collection(Collection $rows)
3030
$daftar->bruto = $row[5] * $row[6];
3131
$daftar->pajak = round(($row[5] * $row[6] * $row[7]) / 100, 0, PHP_ROUND_HALF_UP);
3232
$daftar->netto = ($row[5] * $row[6]) - round(($row[5] * $row[6] * $row[7]) / 100, 0, PHP_ROUND_HALF_UP);
33-
$daftar->rekening = Mitra::cache()->get('all')->where('nik', $row[0])->first()->rekening;
33+
$daftar->rekening = Mitra::cache()->get('all')->where('nik', $row[0])->first()->rekening ?? '';
3434
$daftar->honor_survei_id = $this->id[0];
3535
$daftar->bulan = $this->id[1];
3636
$daftar->jenis = $this->id[2];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8+
9+
class AnggaranKerangkaAcuan extends Model
10+
{
11+
use HasFactory;
12+
13+
/**
14+
* Define a relationship where the AnggaranKerangkaAcuan model belongs to the KerangkaAcuan model.
15+
*
16+
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
17+
*/
18+
public function kerangkaAcuan(): BelongsTo
19+
{
20+
return $this->belongsTo(KerangkaAcuan::class);
21+
}
22+
}

app/Models/KerangkaAcuan.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ class KerangkaAcuan extends Model
1717
'tanggal' => 'date',
1818
'awal' => 'date',
1919
'akhir' => 'date',
20-
'spesifikasi' => 'array',
21-
'anggaran' => 'array',
2220
];
2321

2422
/**
@@ -34,6 +32,12 @@ public function arsipDokumen(): HasMany
3432
return $this->hasMany(ArsipDokumen::class);
3533
}
3634

35+
public function anggaranKerangkaAcuan(): HasMany
36+
{
37+
return $this->hasMany(AnggaranKerangkaAcuan::class);
38+
}
39+
40+
3741
/**
3842
* The "booted" method of the model.
3943
*/

app/Models/TataNaskah.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ public function kodeNaskah(): HasMany
2929
return $this->hasMany(KodeNaskah::class);
3030
}
3131

32-
public function template(): HasMany
33-
{
34-
return $this->hasMany(Template::class);
35-
}
36-
3732
public static function cacheEntities(): array
3833
{
3934
return [

app/Models/Template.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Database\Eloquent\Factories\HasFactory;
66
use Illuminate\Database\Eloquent\Model;
7-
use Illuminate\Database\Eloquent\Relations\BelongsTo;
87
use Mostafaznv\LaraCache\CacheEntity;
98
use Mostafaznv\LaraCache\Traits\LaraCache;
109

@@ -22,8 +21,4 @@ public static function cacheEntities(): array
2221
];
2322
}
2423

25-
public function tataNaskah(): BelongsTo
26-
{
27-
return $this->belongsTo(TataNaskah::class);
28-
}
2924
}

app/Nova/Actions/ImportKodeArsip.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Nova\Actions;
44

5+
use App\Helpers\Helper;
56
use App\Imports\KodeArsipsImport;
67
use App\Models\KodeArsip;
78
use App\Models\Template;
@@ -50,7 +51,7 @@ public function fields(NovaRequest $request)
5051
File::make('File')
5152
->rules('required', 'mimes:xlsx')
5253
->acceptedTypes('.xlsx')->help('Data Lama Akan dihapus dan ditimpa data baru'),
53-
Heading::make('<a href = "'.Storage::disk('templates')->url(Template::cache()->get('all')->where('slug', 'template_import_kode_arsip')->first()->file).'">Unduh Template</a>')
54+
Heading::make('<a href = "'.Storage::disk('templates')->url(Helper::getTemplatePath('import_kode_arsip')).'">Unduh Template</a>')
5455
->asHtml(),
5556
];
5657
}

app/Nova/Actions/ImportMitra.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Nova\Actions;
44

5+
use App\Helpers\Helper;
56
use App\Imports\MitrasImport;
67
use App\Models\Mitra;
78
use App\Models\Template;
@@ -49,7 +50,7 @@ public function fields(NovaRequest $request)
4950
File::make('File')
5051
->rules('required', 'mimes:xlsx')
5152
->acceptedTypes('.xlsx')->help('Data Lama Akan dihapus dan ditimpa data baru'),
52-
Heading::make('<a href = "'.Storage::disk('templates')->url(Template::cache()->get('all')->where('slug', 'template_import_mitra')->first()->file).'">Unduh Template</a>')
53+
Heading::make('<a href = "'.Storage::disk('templates')->url(Helper::getTemplatePath('import_mitra')).'">Unduh Template</a>')
5354
->asHtml(),
5455
];
5556
}

app/Nova/AnggaranKerangkaAcuan.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
namespace App\Nova;
4+
5+
use App\Helpers\Helper;
6+
use App\Models\KerangkaAcuan;
7+
use Laravel\Nova\Fields\BelongsTo;
8+
use Laravel\Nova\Fields\Currency;
9+
use Laravel\Nova\Fields\FormData;
10+
use Laravel\Nova\Fields\Select;
11+
use Laravel\Nova\Http\Requests\NovaRequest;
12+
13+
class AnggaranKerangkaAcuan extends Resource
14+
{
15+
/**
16+
* The model the resource corresponds to.
17+
*
18+
* @var class-string<\App\Models\AnggaranKerangkaAcuan>
19+
*/
20+
public static $model = \App\Models\AnggaranKerangkaAcuan::class;
21+
public static $with = ['kerangkaAcuan'];
22+
public static $displayInNavigation = false;
23+
24+
public static function label()
25+
{
26+
return 'Anggaran';
27+
}
28+
29+
/**
30+
* The single value that should be used to represent the resource when being displayed.
31+
*
32+
* @var string
33+
*/
34+
public static $title = 'mak';
35+
36+
/**
37+
* The columns that should be searched.
38+
*
39+
* @var array
40+
*/
41+
public static $search = [
42+
'mak',
43+
];
44+
45+
/**
46+
* Get the fields displayed by the resource.
47+
*
48+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
49+
* @return array
50+
*/
51+
public function fields(NovaRequest $request)
52+
{
53+
return [
54+
Select::make('MAK', 'mak')
55+
->rules('required')
56+
->searchable()
57+
->filterable()
58+
->dependsOn('tanggal', function (Select $field, NovaRequest $request, FormData $formData) {
59+
$field->options(Helper::setOptionsMataAnggaran(Helper::getYearFromDate(KerangkaAcuan::find($formData->kerangkaAcuan)->tanggal)));
60+
}),
61+
62+
Currency::make('Perkiraan Digunakan ', 'perkiraan')
63+
->rules('required')
64+
->step(1)
65+
->default(0),
66+
67+
BelongsTo::make('Kerangka Acuan Kerja', 'kerangkaAcuan', KerangkaAcuan::class)
68+
->rules('required')
69+
->searchable()
70+
->onlyOnForms(),
71+
];
72+
}
73+
74+
/**
75+
* Get the cards available for the request.
76+
*
77+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
78+
* @return array
79+
*/
80+
public function cards(NovaRequest $request)
81+
{
82+
return [];
83+
}
84+
85+
/**
86+
* Get the filters available for the resource.
87+
*
88+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
89+
* @return array
90+
*/
91+
public function filters(NovaRequest $request)
92+
{
93+
return [];
94+
}
95+
96+
/**
97+
* Get the lenses available for the resource.
98+
*
99+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
100+
* @return array
101+
*/
102+
public function lenses(NovaRequest $request)
103+
{
104+
return [];
105+
}
106+
107+
/**
108+
* Get the actions available for the resource.
109+
*
110+
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
111+
* @return array
112+
*/
113+
public function actions(NovaRequest $request)
114+
{
115+
return [];
116+
}
117+
}

0 commit comments

Comments
 (0)