title: Transform Raw Union Query into Eloquent Relationship
body: <p>i've a question about Laravel Relationships.</p>
  
  <p>I've a raw union query and i want to translate into a eloquent relationship.</p>
  
  <p>First of all... i have 4 tables involved:</p>
  
  <p><strong>roles</strong></p>
  
  <pre><code>id|name
  </code></pre>
  
  <p><strong>permissions</strong></p>
  
  <pre><code>id|name|code|description
  </code></pre>
  
  <p><strong>permission_role</strong></p>
  
  <pre><code>role_id|permission_id
  </code></pre>
  
  <p><strong>users</strong></p>
  
  <pre><code>id|...........|role_id
  </code></pre>
  
  <p><strong>permission_user</strong></p>
  
  <pre><code>user_id|permission_id
  </code></pre>
  
  <p>Inside my User model, i've this method:</p>
  
  <pre><code>/**
   * @TODO: Transform this into a eloquent relationship
   * 
   * @return Collection
   */
  public function permissions()
  {
      $query = sprintf('
          (
              SELECT permissions.*
              FROM permissions
              INNER JOIN permission_role ON permission_role.permission_id = permissions.id
              WHERE permission_role.role_id = %s
          ) UNION
          (
              SELECT permissions.*
              FROM permissions
              INNER JOIN permission_user ON permission_user.permission_id = permissions.id
              WHERE permission_user.user_id = %s
          )', $this-&gt;role_id, $this-&gt;id);
  
      return Permission::hydrate(DB::select($query));
  }
  </code></pre>
  
  <p>The point is, i want to fetch all permissions by the role that the user is associated, and the separated permissions associated to the user.</p>
  
  <p>Can i transform this in some eloquent relationship like hasMany, belongsToMany, etc... ?</p>