Skip to content

Commit ad399b3

Browse files
test add UangPersediaan
1 parent ce9f054 commit ad399b3

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
6363

6464
VITE_APP_NAME="${APP_NAME}"
6565

66-
NOVA_INITIAL_YEAR=2024
66+
INITIAL_YEAR=2024
6767

6868
# CONFIG SATKER
6969
SATKER_KAB="Kabupaten Hulu Sungai Tengah"

app/Helpers/Helper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ class Helper
7676
'kkp' => 'KKP',
7777
];
7878

79+
const JENIS_UANG_PERSEDIAAN = [
80+
'gup' => 'GUP',
81+
'kkp' => 'KKP',
82+
];
83+
84+
7985
const JENIS_KEGIATAN = [
8086
'Libur' => 'Libur',
8187
'Deadline' => 'Deadline',

app/Models/UangPersediaan.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,27 @@
33
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Mostafaznv\LaraCache\CacheEntity;
7+
use Mostafaznv\LaraCache\Traits\LaraCache;
68

79
class UangPersediaan extends Model
810
{
9-
//
11+
use LaraCache;
12+
13+
protected function casts(): array
14+
{
15+
return [
16+
'tanggal' => 'date',
17+
];
18+
}
19+
20+
public static function cacheEntities(): array
21+
{
22+
return [
23+
CacheEntity::make('all')
24+
->cache(function () {
25+
return UangPersediaan::all();
26+
}),
27+
];
28+
}
1029
}

app/Nova/UangPersediaan.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ class UangPersediaan extends Resource
1515

1616
public static function label()
1717
{
18-
return 'UangPersediaan';
18+
return 'Uang Persediaan';
1919
}
2020

2121
/**
2222
* The single value that should be used to represent the resource when being displayed.
2323
*
2424
* @var string
2525
*/
26-
public static $title = 'id';
26+
public function title()
27+
{
28+
return Helper::JENIS_UANG_PERSEDIAAN[$this->jenis] ?? '';
29+
}
2730

2831
public function subtitle(){
29-
return $this->id;
32+
return $this->limit ? 'Nilai GUP: '.Helper::formatUang($this->limit) : null;
3033
}
3134

3235
/**
@@ -35,7 +38,7 @@ public function subtitle(){
3538
* @var array
3639
*/
3740
public static $search = [
38-
'id',
41+
'jenis',
3942
];
4043

4144
/**
@@ -47,7 +50,19 @@ public function subtitle(){
4750
public function fields(NovaRequest $request)
4851
{
4952
return [
50-
53+
Date::make('Tanggal', 'tanggal')
54+
->sortable()
55+
->displayUsing(fn ($tanggal) => Helper::terbilangTanggal($tanggal))
56+
->rules('required'),
57+
Select::make('Jenis', 'jenis')
58+
->options(Helper::JENIS_UANG_PERSEDIAAN)
59+
->displayUsingLabels()
60+
->sortable()
61+
->rules('required'),
62+
Numeric::make('Nilai GUP', 'limit')
63+
->sortable()
64+
->rules('required', 'integer', 'gte:1'),
65+
5166
];
5267
}
5368

app/Providers/NovaServiceProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
use App\Nova\TataNaskah;
5959
use App\Nova\Template;
6060
use App\Nova\TindakLanjut;
61+
use App\Nova\UangPersediaan;
6162
use App\Nova\UnitKerja;
6263
use App\Nova\User;
6364
use App\Nova\UserEksternal;
@@ -195,6 +196,7 @@ public function boot()
195196
MenuItem::resource(PerjanjianKinerja::class),
196197
MenuItem::resource(SkTranslok::class),
197198
MenuItem::resource(TataNaskah::class),
199+
MenuItem::resource(UangPersediaan::class),
198200
// MenuItem::resource(UserEksternal::class),
199201
])
200202
->collapsable()

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
|
133133
*/
134134

135-
'initialyear' => env('NOVA_INITIAL_YEAR', 2024),
135+
'initialyear' => env('INITIAL_YEAR', 2024),
136136

137137
/*
138138
|--------------------------------------------------------------------------

database/migrations/2025_08_29_022533_create_uang_persediaans_table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ public function up(): void
1313
{
1414
Schema::create('uang_persediaans', function (Blueprint $table) {
1515
$table->id();
16+
$table->date('tanggal')->nullable();
17+
$table->string('jenis', 20)->nullable();
18+
$table->integer('limit')->nullable()->unsigned();
1619
$table->timestamps();
1720
});
1821
}

public/images/logo.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)