Skip to content

Commit 319abff

Browse files
Update MariaDB client installation and improve unit kerja ID retrieval in policies
1 parent b71054f commit 319abff

File tree

8 files changed

+40
-16
lines changed

8 files changed

+40
-16
lines changed

.devcontainer/setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
sudo apt update -y && sudo apt install -y mariadb-client
2+
sudo apt update -y && sudo apt upgrade -y && sudo apt install -y mariadb-client
33

44
echo --- Copy the environment file ...
55
cp .env.example .env

app/Nova/HonorKegiatan.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function indexQuery(NovaRequest $request, $query)
7373
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm')->get()) {
7474
return $query;
7575
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
76-
return $query->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
76+
return $query->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
7777
}
7878

7979
return $query;
@@ -344,7 +344,7 @@ public function cards(NovaRequest $request)
344344
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm')->get()) {
345345
$model = $model;
346346
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
347-
$model = $model->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
347+
$model = $model->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
348348
}
349349

350350
return [

app/Nova/KerangkaAcuan.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function indexQuery(NovaRequest $request, $query)
4747
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm')->get()) {
4848
return $query;
4949
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
50-
return $query->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
50+
return $query->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
5151
}
5252

5353
return $query;
@@ -158,7 +158,7 @@ public function cards(NovaRequest $request)
158158
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm')->get()) {
159159
$model = $model;
160160
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
161-
$model = $model->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
161+
$model = $model->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
162162
}
163163

164164
return [

app/Nova/PulsaKegiatan.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static function indexQuery(NovaRequest $request, $query)
6969
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm,pbj')->get()) {
7070
return $query;
7171
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
72-
return $query->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
72+
return $query->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
7373
}
7474

7575
return $query;
@@ -176,7 +176,7 @@ public function cards(NovaRequest $request)
176176
if (Policy::make()->allowedFor('ppk,arsiparis,bendahara,kpa,ppspm')->get()) {
177177
$model = $model;
178178
} elseif (Policy::make()->allowedFor('koordinator,anggota')->get()) {
179-
$model = $model->where('unit_kerja_id', Helper::getDataPegawaiByUserId($request->user()->id, now())->unit_kerja_id);
179+
$model = $model->where('unit_kerja_id', optional(Helper::getDataPegawaiByUserId($request->user()->id, now()))->unit_kerja_id);
180180
}
181181

182182
return [

app/Policies/HonorKegiatanPolicy.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function update(User $user, HonorKegiatan $honor): bool
4646
return Policy::make()
4747
->allowedFor('koordinator,anggota')
4848
->withYear($honor->tahun)
49-
->andEqual($honor->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
49+
->andEqual(
50+
$honor->unit_kerja_id,
51+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
52+
)
5053
->get();
5154
}
5255

@@ -58,7 +61,10 @@ public function delete(User $user, HonorKegiatan $honor): bool
5861
return Policy::make()
5962
->allowedFor('koordinator,anggota')
6063
->withYear($honor->tahun)
61-
->andEqual($honor->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
64+
->andEqual(
65+
$honor->unit_kerja_id,
66+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
67+
)
6268
->get();
6369
}
6470

app/Policies/KerangkaAcuanPolicy.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public function update(User $user, KerangkaAcuan $kerangkaAcuan): bool
4949
return Policy::make()
5050
->allowedFor('koordinator,anggota')
5151
->withYear(Helper::getYearFromDate($kerangkaAcuan->tanggal))
52-
->andEqual($kerangkaAcuan->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
52+
->andEqual(
53+
$kerangkaAcuan->unit_kerja_id,
54+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
55+
)
5356
->get();
5457
}
5558

@@ -67,7 +70,10 @@ public function delete(User $user, KerangkaAcuan $kerangkaAcuan): bool
6770
return Policy::make()
6871
->allowedFor('koordinator,anggota')
6972
->withYear(Helper::getYearFromDate($kerangkaAcuan->tanggal))
70-
->andEqual($kerangkaAcuan->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
73+
->andEqual(
74+
$kerangkaAcuan->unit_kerja_id,
75+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
76+
)
7177
->get();
7278
}
7379

@@ -79,7 +85,10 @@ public function replicate(User $user, KerangkaAcuan $kerangkaAcuan): bool
7985
return Policy::make()
8086
->allowedFor('koordinator,anggota')
8187
->withYear(Helper::getYearFromDate($kerangkaAcuan->tanggal))
82-
->andEqual($kerangkaAcuan->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
88+
->andEqual(
89+
$kerangkaAcuan->unit_kerja_id,
90+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
91+
)
8392
->get();
8493
}
8594

app/Policies/PulsaKegiatanPolicy.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function update(User $user, PulsaKegiatan $pulsa): bool
4646
return Policy::make()
4747
->allowedFor('koordinator,anggota')
4848
->withYear($pulsa->tahun)
49-
->andEqual($pulsa->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
49+
->andEqual(
50+
$pulsa->unit_kerja_id,
51+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
52+
)
5053
->get();
5154
}
5255

@@ -58,7 +61,10 @@ public function delete(User $user, PulsaKegiatan $pulsa): bool
5861
return Policy::make()
5962
->allowedFor('koordinator,anggota')
6063
->withYear($pulsa->tahun)
61-
->andEqual($pulsa->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
64+
->andEqual(
65+
$pulsa->unit_kerja_id,
66+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
67+
)
6268
->get();
6369
}
6470

@@ -82,7 +88,10 @@ public function runAction(User $user, PulsaKegiatan $pulsa): bool
8288
return Policy::make()
8389
->allowedFor('koordinator,anggota')
8490
->withYear($pulsa->tahun)
85-
->andEqual($pulsa->unit_kerja_id, Helper::getDataPegawaiByUserId($user->id, now())->unit_kerja_id)
91+
->andEqual(
92+
$pulsa->unit_kerja_id,
93+
optional(Helper::getDataPegawaiByUserId($user->id, now()))->unit_kerja_id
94+
)
8695
->get();
8796
}
8897
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,5 @@
100100
},
101101
"minimum-stability": "dev",
102102
"prefer-stable": true,
103-
"version": "2.14.2"
103+
"version": "2.14.3"
104104
}

0 commit comments

Comments
 (0)