title: Laravel Blade how to pass $attributes to component from controller
body: <p>I have a blade component containing <code>$attributes</code>; It would be a bag of attributes when the component called from another blade template but when from the controller via <code>view()</code> the <code>$attributes</code> is undefined! How can I pass data as <code>$attributes</code> from the controller?</p>
  <p>Component: <code>sample</code></p>
  <pre class="lang-php prettyprint-override"><code>&lt;div {{ $attributes-&gt;except('content') }}&gt;{{ $content }}&lt;/div&gt;
  </code></pre>
  <p>Template: works well.</p>
  <pre class="lang-php prettyprint-override"><code>...
  &lt;x-sample class=&quot;test&quot; content=&quot;test&quot;/&gt;
  ...
  </code></pre>
  <p>Controller: Error <strong>Undefined variable $attributes</strong></p>
  <pre class="lang-php prettyprint-override"><code>$attributes = ['class' =&gt; 'test', 'content' =&gt; 'test'];
  view('components.sample', $attributes)-&gt;render();
  view('components.sample', ['attributes' =&gt; $attributes])-&gt;render();
  view('components.sample')-&gt;with($attributes)-&gt;render();
  </code></pre>
  <p><strong>UPDATE (Solution):</strong></p>
  <p>It works:</p>
  <pre class="lang-php prettyprint-override"><code>view('components.sample', [
      'prop1' =&gt; '...',
      'prop2' =&gt; '...',
      'attributes' =&gt; new ComponentAttributeBag(['attr1' =&gt; '...', 'attr2' =&gt; '...']),
  ])-&gt;render();
  </code></pre>