A
A
Abc Edc2015-11-12 20:33:53
recursion
Abc Edc, 2015-11-12 20:33:53

Blade in laravel not able to work with recursion?

@if (Form::closureTags($item))
    @if(isset($item['closureTag']))
        @include('tags-closure.widgets.edit-form', $item['closureTag']))
    @endif
@else
    @foreach($item as $el)
        @include('tags-closure.widgets.edit-form', $el)
    @endforeach
@endif

We are at tags-closure.widgets.edit-form'
Initial tree
array:8 [▼
  "id" => 247
  "name" => "saddsd"
  "parent_id" => null
  "description" => "Adasd"
  "weight" => 1.0
  "is_sealed" => 0
  "closure" => array:4 [▶]
  "closureTag" => array:1 [▼
    0 => & array:8 [▼
      "id" => 248
      "name" => "dsadsa"
      "parent_id" => 247
      "description" => "dsadsd"
      "weight" => 1.0
      "is_sealed" => 0
      "closure" => array:4 [▶]
      "closureTag" => array:1 [▼

etc.
The process just crashes and that's it, but the code also works (when writing to the database)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2015-11-12
@gleber1

Maybe infinity turned out? Is that why it's falling?

V
Vyacheslav Plisko, 2015-11-13
@AmdY

When you include in a scope, you throw the content of the elements, and do not redefine it. Accordingly, it works with the same $item and falls into an endless recursion.
need
@include('tags-closure.widgets.edit-form', ['item' => $item['closureTag']]))
@include('tags-closure.widgets.edit-form', ['item ' => $el])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question