File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -196,4 +196,37 @@ function checkPermission(string $permission) : bool
196196 return true ;
197197 }
198198 return false ;
199+ }
200+
201+ function checkPermissions (array $ permissions ) : bool
202+ {
203+ if (auth ()->check ())
204+ {
205+ $ auth = auth ()->user ();
206+ $ user_roles = \Obrainwave \AccessTree \Models \UserRole::where ('user_id ' , $ auth ->id )->get ();
207+
208+ if (isRootUser ($ auth ->id ))
209+ {
210+ return true ;
211+ }
212+
213+ }else {
214+ return false ;
215+ }
216+
217+ $ role_permissions = [];
218+ foreach ($ user_roles as $ role )
219+ {
220+ $ rolePermissions = \Obrainwave \AccessTree \Models \RoleHasPermission::where ('role_id ' , $ role ->role_id )->get ();
221+
222+ foreach ($ rolePermissions as $ rolePermission )
223+ {
224+ $ role_permissions [] = $ rolePermission ->permission ->slug ;
225+ }
226+ }
227+ if (array_intersect ($ permissions , $ role_permissions ))
228+ {
229+ return true ;
230+ }
231+ return false ;
199232}
You can’t perform that action at this time.
0 commit comments