Exemplo n.º 1
0
 /**
  * Checks if the supplied array of permissions exist within database
  *
  * @return array|null
  */
 public static function areValid($permissions)
 {
     if (!is_null($permissions)) {
         // Grab any permissions that are in that array
         $against = Permission::whereIn('id', $permissions)->get();
         // Compare the two counts, if different, some of the ones supplied don't exist
         if ($against->count() !== count($permissions)) {
             // in which case, supply new array of ones that do exist and were requested
             $permissions = array();
             foreach ($against as $permission) {
                 $permissions[] = $permission->id;
             }
         }
         return $permissions;
     }
     return null;
 }