title: How to compare variables in blade template
body: <p>Hellow Guys,
  Im trying to compare 2 variables in my blade template </p>
  
  <p>My controller</p>
  
  <pre><code>$files = \File::files('images');
  
       foreach ($files as $file) {
            $info[] = pathinfo($file);
       }
  
  $books = File::where('status', 1)-&gt;select('name')-&gt;get();
  
  return view('cataloged.read', compact(['info','books']));
  </code></pre>
  
  <p>In my view
  trying some like this</p>
  
  <pre><code>@foreach($info as $inf)
   @if(isset($books))
       @if($inf['basename'] == $books-&gt;name)
           Match
       @else
           No Match
       @endif
   @endif  
  @endforeach
  </code></pre>
  
  <p>This work just for the last record - I have 2 records in my database - 
  so its only working for the second record in this case... </p>
  
  <p>What should I do? </p>
  
  <p>Thanks for the help guys!</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code> @foreach($books as $book)
             @foreach($info as $file)
                @if($book-&gt;name == $file['basename'])
                  &lt;p&gt;Book&lt;/p&gt;
                @else
                  &lt;p&gt;No Book&lt;/p&gt; 
                @endif
             @endforeach
    @endforeach
  </code></pre>
  
  <p>I only have 4 book in my database so this is working good </p>
  
  <pre><code>@if($book-&gt;name == $file['basename'])
         &lt;p&gt;Book&lt;/p&gt;
  @endif
  </code></pre>
  
  <p>Book 
  Book
  Book
  Book</p>
  
  <p>But when i use @else im gettin like this
  Book No book 6 times
  Book No book 6 times
  Book No book 6 times
  Book No book 6 times</p>