title: laravel blade template printing recursive tree
body: <p>tree.blade.php</p>
  
  <pre><code>&lt;ul&gt;
  
  @foreach($places as $p)
      &lt;li&gt;
       &lt;a href=""&gt;{{ $p-&gt;name }}&lt;/a&gt;
  
      @if($p-&gt;children-&gt;count())
  
            @include ('tree', ['places' =&gt; $p-&gt;children]) //recursion
      @endif
      &lt;/li&gt;
  @endforeach
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>I have 2 rows in my database, so the 2 is child to 1, the problem is that when the first tree is printed, it returns back to the second iteration, but this second iteration is the child one to the first, so it should not be printed again, it created duplication, how should I prevent this in my blade template</p>
  
  <p><strong>updated:</strong></p>
  
  <p>controller method:</p>
  
  <pre><code>public function index()
  {
      $data = [];
      $data['places'] = Place::with(['children', 'parent'])-&gt;get();
  
      return view('places/index', $data);
  }
  </code></pre>