@@ -24,25 +24,10 @@ public function viewAny(): bool
2424 */
2525 public function view (User $ user , IzinKeluar $ izinKeluar ): bool
2626 {
27- if (Policy::make ()->allowedFor ('kepala ' )->get ()) {
28- return Policy::make ()
29- ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
30- ->get ();
31- }
32- if (Policy::make ()->allowedFor ('koordinator ' )->get ()) {
33- return Policy::make ()
34- ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
35- ->andEqual ($ user ->unit_kerja_id , $ izinKeluar ->user ->unit_kerja_id )
36- ->get ();
37- }
38- if (Policy::make ()->allowedFor ('anggota ' )->get ()) {
39- return Policy::make ()
40- ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
41- ->andEqual ($ user ->id , $ izinKeluar ->user_id )
42- ->get ();
43- }
44-
45- return false ;
27+ return Policy::make ()
28+ ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
29+ ->allowedFor ('kepala,anggota,koordinator ' )
30+ ->get ();
4631 }
4732
4833 /**
@@ -51,7 +36,7 @@ public function view(User $user, IzinKeluar $izinKeluar): bool
5136 public function create (): bool
5237 {
5338 return Policy::make ()
54- ->allowedFor ('kepala, anggota,koordinator ' )
39+ ->allowedFor ('anggota ' )
5540 ->get ();
5641 }
5742
@@ -61,6 +46,7 @@ public function create(): bool
6146 public function update (User $ user , IzinKeluar $ izinKeluar ): bool
6247 {
6348 return Policy::make ()
49+ ->allowedFor ('anggota ' )
6450 ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
6551 ->andEqual ($ user ->id , $ izinKeluar ->user_id )
6652 ->get ();
@@ -72,28 +58,7 @@ public function update(User $user, IzinKeluar $izinKeluar): bool
7258 public function delete (User $ user , IzinKeluar $ izinKeluar ): bool
7359 {
7460 return Policy::make ()
75- ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
76- ->andEqual ($ user ->id , $ izinKeluar ->user_id )
77- ->get ();
78- }
79-
80- /**
81- * Determine whether the user can restore the model.
82- */
83- public function restore (User $ user , IzinKeluar $ izinKeluar ): bool
84- {
85- return Policy::make ()
86- ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
87- ->andEqual ($ user ->id , $ izinKeluar ->user_id )
88- ->get ();
89- }
90-
91- /**
92- * Determine whether the user can permanently delete the model.
93- */
94- public function forceDelete (User $ user , IzinKeluar $ izinKeluar ): bool
95- {
96- return Policy::make ()
61+ ->allowedFor ('anggota ' )
9762 ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
9863 ->andEqual ($ user ->id , $ izinKeluar ->user_id )
9964 ->get ();
@@ -105,6 +70,7 @@ public function forceDelete(User $user, IzinKeluar $izinKeluar): bool
10570 public function replicate (User $ user , IzinKeluar $ izinKeluar ): bool
10671 {
10772 return Policy::make ()
73+ ->allowedFor ('anggota ' )
10874 ->withYear (Helper::getYearFromDate ($ izinKeluar ->tanggal ))
10975 ->andEqual ($ user ->id , $ izinKeluar ->user_id )
11076 ->get ();
0 commit comments