title: In Laravel 5, what does this do: $this->{$var}
body: <p>I have the following code in an api endpoint, which checks there are no relationships on a model to be deleted (and returns true to show it's in use):</p>
  
  <p>CONTROLLER</p>
  
  <pre><code>public function destroy(Group $group)
      {
          if ($group-&gt;inUse()) {
              return response(
                  ['message' =&gt; 'This group cannot be deleted because it has either associated 
                  catalogue items, users or organisations'],
                  409
              );
          }
  
          $group-&gt;delete();
      }
  </code></pre>
  
  <p>MODEL</p>
  
  <pre><code>public function inUse()
  {
      $models = [
          'categories',
          'items',
          'organisations',
      ];
  
      foreach ($models as $model) {
          if (count($this-&gt;{$model}) &gt; 0 ){
              return true;
          }
      }
  
      return false;
  }
  </code></pre>
  
  <p>The line which I don't fully understand is where we check the number of relations for each model: <code>count($this-&gt;{$model})</code></p>
  
  <p><a href="https://secure.php.net/manual/en/language.variables.variable.php" rel="nofollow noreferrer">I read on php.net</a> that $this->{$var} is a variable variable, but that can't be the case here, the first run through of the loop would return an undefined variable $categories:</p>
  
  <pre><code>if($this-&gt;$categories) {
      //
  }
  </code></pre>
  
  <p>Is this a laravel feature or special syntax? I did a quick search but nothing came up I could see.</p>
  
  <p>Thanks in advance.</p>