original_string: public static function applyDefaultUserAppRole($user, $defaultRole)
      {
          $apps = App::all();
  
          if (count($apps) === 0) {
              return false;
          }
  
          foreach ($apps as $app) {
              if (!UserAppRole::whereUserId($user->id)->whereAppId($app->id)->exists()) {
                  $userAppRoleData = [
                      'user_id' => $user->id,
                      'app_id'  => $app->id,
                      'role_id' => $defaultRole
                  ];
  
                  UserAppRole::create($userAppRoleData);
              }
          }
  
          return true;
      }
code: public static function applyDefaultUserAppRole($user, $defaultRole)
      {
          $apps = App::all();
  
          if (count($apps) === 0) {
              return false;
          }
  
          foreach ($apps as $app) {
              if (!UserAppRole::whereUserId($user->id)->whereAppId($app->id)->exists()) {
                  $userAppRoleData = [
                      'user_id' => $user->id,
                      'app_id'  => $app->id,
                      'role_id' => $defaultRole
                  ];
  
                  UserAppRole::create($userAppRoleData);
              }
          }
  
          return true;
      }
code_tokens: public static function applyDefaultUserAppRole ( $ user , $ defaultRole ) { $ apps = App :: all ( ) ; if ( count ( $ apps ) === 0 ) { return false ; } foreach ( $ apps as $ app ) { if ( ! UserAppRole :: whereUserId ( $ user -> id ) -> whereAppId ( $ app -> id ) -> exists ( ) ) { $ userAppRoleData = [ 'user_id' => $ user -> id , 'app_id' => $ app -> id , 'role_id' => $ defaultRole ] ; UserAppRole :: create ( $ userAppRoleData ) ; } } return true ; }
docstring: Assigns a role to a user for all apps in the system.
  
  @param $user
  @param $defaultRole
  
  @return bool
  @throws \Exception
docstring_tokens: Assigns a role to a user for all apps in the system .