Recursive display of data with blade, laravel
You are approaching the views in a wrong way, as blade templates are not meant to use functions, it's better to follow the below recommendations.
The best way for that is to place the function code inside a blade file, for example recursive.blade.php
:
recursive.blade.php
@foreach($comments as $comment)//place your code here@endforeach
Then in your main blade you can call it several times:
main.blade.php
<div> @include('recursive', ['comments' => $comments])</div>