Get role from team_user table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfonsatti
    Active Community Member
    • Jul 2018
    • 13

    Get role from team_user table

    Hi ,
    how can i get "role" from the table "team_user" having the user_id and team_id ? is there a way to do that without direct SQL ?
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hi,
    you can see this data with ORM
    I create custom reports and filter for teams. There are two new fields in the "team_user" table. Start and end dates. These two new areas need to be

    Comment

    • mfonsatti
      Active Community Member
      • Jul 2018
      • 13

      #3
      here my approach ...

      Code:
      /** @var Team $team */
      $team = $this->getEntityManager()->getEntity('Team','revisors');
      
      
      $entityCollection1 = $this->getEntityManager()
          ->getRepository('Team')
          ->findRelated(
              $team,
              'users',
              [
                  'additionalColumnsConditions' =>
                      [
                          'role' => 'financial',
                          'userId' => $data->userId,
                      ]
              ]
          );
      
      $entityCollection2 = $this->getEntityManager()
          ->getRepository('Team')
          ->findRelated(
              $team,
              'users',
              [
                  'additionalColumnsConditions' =>
                      [
                          'role' => 'operation',
                          'userId' => $data->userId,
                      ]
              ]
          );
      
      if($entityCollection1->count() > 0) { ... }
      
      if($entityCollection2->count() > 0) { ... }
      what i need to do is to check if the user related to a team with id "revisors" got the role "operation" or "financial" in the table team_user
      is there a way to load the role attribute to make a switch case on role attribute ?


      Comment

      Working...