title: Query AncestryOf with Laravel-nestedset in Laravel 5.8
body: <p>I am using <a href="https://github.com/lazychaser/laravel-nestedset" rel="nofollow noreferrer">Laravel-nestedset</a> and am having a hard time querying the <code>ancestrosOf</code> my category model.</p>
  
  <p>This is what I am trying to do:</p>
  
  <p><strong>Works</strong></p>
  
  <p><a href="http://carnival-experts.test/categories" rel="nofollow noreferrer">http://carnival-experts.test/categories</a> (this gives me a list of all categories)</p>
  
  <p><a href="http://carnival-experts.test/categories/carnival-games" rel="nofollow noreferrer">http://carnival-experts.test/categories/carnival-games</a> (this gives me a list of all Carnival Games)</p>
  
  <p><strong>Does Not Work</strong></p>
  
  <p><a href="http://carnival-experts.test/categories/carnival-games/large-scale-games" rel="nofollow noreferrer">http://carnival-experts.test/categories/carnival-games/large-scale-games</a> (this shows me a list of Carnival Games and not the Large Scale Games category)</p>
  
  <p>I am sure this is just my lack of understanding--any help appreciated.</p>
  
  <p><strong>web.php</strong></p>
  
  <pre><code>...
  Route::get('/', 'CategoryController@index')-&gt;name('categories');
  Route::get('/{category}/{slug?}', 'CategoryController@show')-&gt;name('show');
  ...
  </code></pre>
  
  <p><strong>CategoryController.php</strong></p>
  
  <pre><code>...
  class CategoryController extends Controller
  {
      public function index()
  
      {
          $categories = Category::get()-&gt;toTree();
  
          return view('categories.index', compact('categories'));
      }
  
      public function show(Category $category, $slug = null)
      {
          if (!is_null($slug)) {
              $categories = Category::ancestorsOf($category);
              return view('categories.show_subcategory', compact('categories', 'category', 'slug'));
          } else {
              return view('categories.show', compact('category'));
          }
  
      }
  
  }
  </code></pre>
  
  <p><strong>show_category.blade.php</strong></p>
  
  <pre><code>...
  @foreach($category['children']-&gt;chunk(3) as $chunk)
      &lt;div class="row"&gt;
          @foreach($chunk as $category)
              &lt;div class="col-md-4" style="margin-bottom: 2rem"&gt;
                  &lt;div class="feature-box center media-box fbox-bg"&gt;
                      &lt;div class="fbox-media"&gt;
                          &lt;a href="/categories/{{$category-&gt;slug}}"&gt;
                              &lt;img class="image_fade"
                                   src="https://*****.s3-us-west-1.amazonaws.com/{{ $category-&gt;photo }}"
                                   alt="Featured Box Image"
                                   style="opacity: 1;"&gt;&lt;/a&gt;
                      &lt;/div&gt;
                      &lt;div class="fbox-desc"&gt;
                          &lt;h3&gt;{{$category-&gt;name}}&lt;/h3&gt;
                          &lt;span&gt;&lt;a href="/categories/{{$category-&gt;slug}}"&gt;Learn More&lt;/a&gt;&lt;/span&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              Products
              @if(count($category-&gt;products) &gt; 0)
                  @foreach($category-&gt;products as $product)
                      {{$product-&gt;title}}
                  @endforeach
              @endif
          @endforeach
      &lt;/div&gt;
  @endforeach
  ...
  </code></pre>