Announcement

Collapse
No announcement yet.

Get role from team_user table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 ?

  • #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


    • #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...
      X