title: How to check if a variable has data in laravel blade
body: <p>I wanted to check if variable is there or not in blade ..for that i have used following lines:</p>
  
  <pre><code>@if(is_null($products))
      &lt;div class="alert alert-warning"&gt;
          &lt;strong&gt;Sorry!&lt;/strong&gt; No Product Found.
      &lt;/div&gt;                                      
  @else
  
      @foreach($products as $product)
          //
      @endforeach
  @endif
  </code></pre>
  
  <p>The problem is when there is <code>$products</code> on blade I could show inside of <code>foreach</code> loop but when i get empty variable.I couldn't show the message <code>No Data Found</code> instead it shows only empty space?
  is there any problem of checking variable inside of blade?</p>
  
  <p>Controller code :</p>
  
  <pre><code>public function productSearch(Request $request)
      {
          $name = $request-&gt;name; 
          $products = Product::where('name' , 'like', '%'.$name.'%')-&gt;get();
          return view('cart.product',compact('products'));
      }
  </code></pre>