ziben69
107
2
Laravel

Hide if file doesn't exist

Posted 5 months ago by ziben69

Hello guys, I have file.blade.php.

I need to hide empty files records in view:

 <div class="row">
      @foreach($files as $file)
      <div class="col-md-4" style="margin-bottom:10px;">
             <div class="card">
                     <div class="card-body">
                            <strong>{{ $file->title }}</strong>
                            <p class="card-text">
                                    {{ $file->created_at->diffForHumans() }}
                            </p>
                            <a href="{{ route('downloadSenior', $file->id) }}"><i class="fa fa-download" aria-hidden="true"></i> Download</a>
                     </div>
             </div>
      </div>
      @endforeach
</div>

How can I hide this part of view when file doesn't exist. Now I have empty links because in my DB are 30 rows without files. I should change:

$file->id

?? Thanks for help!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.