Skip to content

Commit 8dfd77c

Browse files
committed
update mata anggaran
1 parent 0af1ebd commit 8dfd77c

30 files changed

+564
-144
lines changed

app/Helpers/Helper.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,18 @@ class Helper
6464
* @var array
6565
*/
6666
public static $role = [
67-
'kepala' => 'kepala',
68-
'koordinator' => 'koordinator',
69-
'anggota' => 'anggota',
67+
'kepala' => 'Kepala',
68+
'ppk' => 'Pejabat Pembuat Komitmen',
69+
'bendahara' => 'Bendahara',
70+
'ppspm' => 'Pejabat PSPM',
71+
'pbj' => 'Pejabat PBJ',
72+
'bmn' => 'Pengelola BMN',
73+
'admin' => 'Administrator',
74+
'kpa' => 'Kuasa Pengguna Anggaran',
75+
'koordinator' => 'Ketua Tim',
76+
'anggota' => 'Pegawai',
77+
'kasubbag' => 'Kasubbag Umum',
78+
'arsiparis' => 'Arsiparis',
7079
];
7180

7281
/**

app/Http/Controllers/RoleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class RoleController extends Controller
1414
*/
1515
public function changeRole($role, Request $request)
1616
{
17-
if ((Pengelola::cache()->get('all')->where('user_id', Auth::user()->id)->where('role', $role)->first() !== null) || ($role === Auth::user()->role)) {
17+
if ((Pengelola::cache()->get('all')->where('user_id', Auth::user()->id)->where('role', $role)->whereNull('inactive')->first() !== null)) {
1818
session(['role' => $role]);
1919
}
2020

app/Models/DataPegawai.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use App\Helpers\Helper;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Database\Eloquent\Model;
8+
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9+
use Mostafaznv\LaraCache\CacheEntity;
10+
use Mostafaznv\LaraCache\Traits\LaraCache;
11+
12+
class DataPegawai extends Model
13+
{
14+
use HasFactory, LaraCache;
15+
16+
protected $casts = [
17+
'tanggal' => 'date',
18+
];
19+
20+
public function user(): BelongsTo
21+
{
22+
return $this->belongsTo(User::class);
23+
}
24+
/**
25+
* Get the unit kerja that owns the user.
26+
*/
27+
public function unitKerja(): BelongsTo
28+
{
29+
return $this->belongsTo(UnitKerja::class);
30+
}
31+
32+
public function setGolonganAttribute($value)
33+
{
34+
$this->attributes['golongan'] = $value;
35+
$this->attributes['pangkat'] = Helper::$pangkat[$value];
36+
}
37+
38+
public static function cacheEntities(): array
39+
{
40+
return [
41+
CacheEntity::make('all')
42+
->cache(function () {
43+
return DataPegawai::all();
44+
}),
45+
];
46+
}
47+
48+
}

app/Models/Pengelola.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ class Pengelola extends Model
1212
{
1313
use HasFactory, LaraCache;
1414

15+
protected $casts = [
16+
'active' => 'date',
17+
'inactive' => 'date',
18+
];
19+
1520
/**
1621
* Get the user that owns the pengelola.
1722
*/

app/Models/User.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Helpers\Helper;
66
use Illuminate\Database\Eloquent\Factories\HasFactory;
77
use Illuminate\Database\Eloquent\Relations\BelongsTo;
8+
use Illuminate\Database\Eloquent\Relations\HasMany;
89
use Illuminate\Foundation\Auth\User as Authenticatable;
910
use Illuminate\Notifications\Notifiable;
1011
use Mostafaznv\LaraCache\CacheEntity;
@@ -58,17 +59,27 @@ protected function casts(): array
5859
];
5960
}
6061

61-
public function setGolonganAttribute($value)
62+
/**
63+
* Get the unit kerja that owns the user.
64+
*/
65+
public function unitKerja(): BelongsTo
6266
{
63-
$this->attributes['golongan'] = $value;
64-
$this->attributes['pangkat'] = Helper::$pangkat[$value];
67+
return $this->belongsTo(UnitKerja::class);
6568
}
6669

6770
/**
6871
* Get the unit kerja that owns the user.
6972
*/
70-
public function unitKerja(): BelongsTo
73+
public function pengelola(): HasMany
7174
{
72-
return $this->belongsTo(UnitKerja::class);
75+
return $this->hasMany(Pengelola::class);
76+
}
77+
78+
/**
79+
* Get the unit kerja that owns the user.
80+
*/
81+
public function dataPegawai(): HasMany
82+
{
83+
return $this->hasMany(DataPegawai::class);
7384
}
7485
}

app/Nova/Actions/ImportMataAnggaran.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public function handle(ActionFields $fields, Collection $models)
3232
$model = $models->first();
3333
MataAnggaran::cache()->disable();
3434
KamusAnggaran::cache()->disable();
35-
MataAnggaran::where('tahun', session('year'))->where('dipa_id', $model->id)->update(['updated_at' => null]);
36-
KamusAnggaran::where('tahun', session('year'))->where('dipa_id', $model->id)->update(['updated_at' => null]);
35+
MataAnggaran::where('dipa_id', $model->id)->update(['updated_at' => null]);
36+
KamusAnggaran::where('dipa_id', $model->id)->update(['updated_at' => null]);
3737
Excel::import(new MataAnggaransImport($fields->satker, $fields->wilayah, $model->id), $fields->file);
3838
MataAnggaran::where('updated_at', null)->delete();
3939
KamusAnggaran::where('updated_at', null)->delete();

app/Nova/ArsipDokumen.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function fields(NovaRequest $request)
5858
->sortable()
5959
->rules('required'),
6060
File::make('File')
61-
->disk('templates')
61+
->disk('arsip')
6262
->rules('mimes:xlsx,pdf.docx')
6363
->acceptedTypes('.pdf,.docx,.xlsx')
6464
->rules('required')

app/Nova/Dashboards/Main.php

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

33
namespace App\Nova\Dashboards;
44

5+
use App\Helpers\Helper;
56
use App\Helpers\Inspiring;
67
use App\Models\Pengelola;
78
use DigitalCreative\NovaWelcomeCard\WelcomeCard;
@@ -31,10 +32,10 @@ public function cards()
3132
{
3233
return [
3334
GreeterCard::make()
34-
->user(name: Auth::user()->nama, title: Auth::user()->email)
35+
->user(name: Auth::user()->name, title: Auth::user()->email)
3536
->message(text: __('Welcome Back!'))
3637
->avatar(url: Storage::disk('avatars')->url(Auth::user()->avatar))
37-
->verified(text: (Pengelola::cache()->get('all')->where('role', session('role'))->first() !== null) ? Pengelola::cache()->get('all')->where('role', session('role'))->first()->jabatan : 'Pegawai')
38+
->verified(text: Helper::$role[session('role')])
3839
->width('1/2'),
3940
GreeterCard::make()
4041
->user(name: 'Quotes of the day', title: Inspiring::show())

app/Nova/DataPegawai.php

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

app/Nova/Pengelola.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace App\Nova;
44

5+
use App\Helpers\Helper;
56
use Laravel\Nova\Fields\BelongsTo;
7+
use Laravel\Nova\Fields\Date;
8+
use Laravel\Nova\Fields\Select;
69
use Laravel\Nova\Fields\Text;
710
use Laravel\Nova\Http\Requests\NovaRequest;
811

@@ -19,6 +22,7 @@ public static function label()
1922
}
2023

2124
public static $with = ['user'];
25+
public static $displayInNavigation = false;
2226

2327
/**
2428
* The model the resource corresponds to.
@@ -40,7 +44,7 @@ public static function label()
4044
* @var array
4145
*/
4246
public static $search = [
43-
'jabatan', 'role',
47+
'role',
4448
];
4549

4650
/**
@@ -51,12 +55,18 @@ public static function label()
5155
public function fields(NovaRequest $request)
5256
{
5357
return [
54-
Text::make('Jabatan')
55-
->rules('required'),
56-
Text::make('role')
58+
Select::make('role')
59+
->options(Helper::$role)
60+
->displayUsingLabels()
5761
->rules('required'),
62+
Date::make('Tanggal Aktivasi', 'active')
63+
->rules('required')
64+
->displayUsing(fn ($tanggal) => Helper::terbilangTanggal($tanggal)),
65+
Date::make('Tanggal Deaktivasi', 'inactive')
66+
->displayUsing(fn ($tanggal) => Helper::terbilangTanggal($tanggal)),
5867
BelongsTo::make('User')
59-
->rules('required'),
68+
->rules('required')
69+
->onlyOnForms(),
6070
];
6171
}
6272

0 commit comments

Comments
 (0)