Skip to content

Commit

Permalink
recursive function added
Browse files Browse the repository at this point in the history
  • Loading branch information
shraddha404 committed Apr 19, 2024
1 parent 28e31cd commit e5aa40f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions resources/views/document-details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,19 @@ function showDeleteDialog(){
@endif

@php
$all_collections = \App\Collection::all();
$all_collections = \App\Collection::whereNull('parent_id')->get();
$level = '';
function listChildren($c,$level){
$level = $level.'- ';
foreach($c->children as $ch){
echo '<option value="'.$ch->id.'">'.$level.$ch->name.'</option>';
if($ch->children->count()){
listChildren($ch, $level);
}
}
}
@endphp

@if(Auth::user() && Auth::user()->hasRole('admin'))
<div class="col-md-12" id="accordion">
<h3>Actions</h3>
Expand All @@ -446,11 +457,13 @@ function showDeleteDialog(){
<option value="">Move to - </option>
@foreach ($all_collections as $c)
<option value="{{ $c->id }}">
@if ($c->parent)
{{ $c->parent->name }} -
@endif
{{ $c->name }}
</option>
@php
if ($c->children->count()){
listChildren($c, $level);
}
@endphp
@endforeach
</select>
</div>
Expand Down

0 comments on commit e5aa40f

Please sign in to comment.