File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -258,14 +258,35 @@ public function resetPreferenceToDefault($id)
258
258
* @param $keyName The keyname of the action you are checking
259
259
* @return bool
260
260
*/
261
- public function checkPermission ($ actions )
261
+ public function checkPermission ($ actions, $ matchAll = false )
262
262
{
263
263
if (Auth::user ()->roles ->contains (\BaseModel::ROLE_DEVELOPER )) {
264
264
return true ;
265
265
}
266
266
267
- // If the user has the permission or is a developer return true.
268
- return in_array ($ actions , $ this ->actions ->keyName ->toArray () );
267
+ if (!is_array ($ actions )) {
268
+ $ actions = array ($ actions );
269
+ }
270
+
271
+ $ matchedActions = 0 ;
272
+
273
+ if ($ this ->actions && $ this ->actions ->count () > 0 ) {
274
+ $ userActions = $ this ->actions ->keyName ->toArray ();
275
+
276
+ foreach ($ actions as $ action ) {
277
+ if (in_array ($ action , $ userActions )) {
278
+ if (!$ matchAll ) {
279
+ return true ;
280
+ }
281
+
282
+ $ matchedActions ++;
283
+ }
284
+ }
285
+
286
+ if ($ matchedActions ) {
287
+ if (count ($ actions ) == $ matchedActions ) return true ;
288
+ }
289
+ }
269
290
270
291
return false ;
271
292
}
You can’t perform that action at this time.
0 commit comments