title: Laravel 5.2 - How to echo a field from a relationship
body: <p>Im trying to echo the categoryid field from the with('categorys').</p>
  
  <p>My appserviceprovider:</p>
  
  <pre><code>view()-&gt;composer('welcome' , function($view){
         $view-&gt;with('homerings', Ring::where('homepage', '=', 1)-&gt;with('categorys')-&gt;get()-&gt;all());
      });
  </code></pre>
  
  <p>Where i'm trying to echo it in welcome.blade.php.</p>
  
  <pre><code>@foreach($homerings as $ring)
              {{ dd($ring-&gt;categorys) }}
              &lt;div class="col-md-3 col-sm-6 col-xs-6"&gt;
                  &lt;a href=""&gt;
                      &lt;img class="img-responsive homepage-ring" src="{{url($ring-&gt;image)}}" alt="{{$ring-&gt;title}}"&gt;
                  &lt;/a&gt;
              &lt;/div&gt;
              &lt;?php
                  $i++;
              ?&gt;
              @if($i == 4)
                  &lt;/div&gt;
                  &lt;div class="row"&gt;
              @endif
          @endforeach
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0fdrW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0fdrW.png" alt="enter image description here"></a></p>
  
  <p>Normal i think it should work like:</p>
  
  <pre><code>{{ dd($ring-&gt;categorys-&gt;categoryid) }}
  </code></pre>
  
  <p>But this is not working.
  the error:</p>
  
  <pre><code>Undefined property: Illuminate\Database\Eloquent\Collection::$categoryid (View: /resources/views/welcome.blade.php)
  </code></pre>