app/maguttiCms/Permission/GFEntrustUserTrait.php
/**
     * Check if user has a permission by its name.
     *
     * @param string|array $permission Permission string or array of permissions.
     * @param bool         $requireAll All permissions in the array are required.
     *
     * @return bool
     */
Check if user has a permission by its name.
@param string|array $permission Permission string or array of permissions.
@param bool         $requireAll All permissions in the array are required.

@return bool
Check if user has a permission by its name . @param string|array $permission Permission string or array of permissions . @param bool $requireAll All permissions in the array are required . @return bool
public function can($permission, $requireAll = false)
    {
        if (is_array($permission)) {
            foreach ($permission as $permName) {
                $hasPerm = $this->can($permName);
                if ($hasPerm && !$requireAll) {
                    return true;
                } elseif (!$hasPerm && $requireAll) {
                    return false;
                }
            }
            return $requireAll;
        } else {
            foreach ($this->cachedRoles() as $role) {
                foreach ($role->cachedPermissions() as $perm) {
                    if (Str::is( $permission, $perm->name) ) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
public function can ( $ permission , $ requireAll = false ) { if ( is_array ( $ permission ) ) { foreach ( $ permission as $ permName ) { $ hasPerm = $ this -> can ( $ permName ) ; if ( $ hasPerm && ! $ requireAll ) { return true ; } elseif ( ! $ hasPerm && $ requireAll ) { return false ; } } return $ requireAll ; } else { foreach ( $ this -> cachedRoles ( ) as $ role ) { foreach ( $ role -> cachedPermissions ( ) as $ perm ) { if ( Str :: is ( $ permission , $ perm -> name ) ) { return true ; } } } } return false ; }
Check if user has a permission by its name.
Check if user has a permission by its name .
// If we've made it this far and $requireAll is FALSE, then NONE of the perms were found // If we've made it this far and $requireAll is TRUE, then ALL of the perms were found. // Return the value of $requireAll; // Validate against the Permission table