title: how can I resolve this while working with for else loop and compact function in Laravel?
body: <p>I'm using laravel version 7.30.1. it shows the error undefined variable $services.<br/>
  code for home controller.<br/></p>
  <pre><code>class HelloController extends Controller
  {
    public function services()
     {
        $services = [
            'service 1',
            'service 2'
        ];
  
          return view('/services',compact('services'));
     }
  
  }
  </code></pre>
  <p>code for blade file.<br/></p>
  <pre><code>@section('content')
  
      &lt;H1&gt;welcome to laravel 6 from services&lt;/H1&gt;
      &lt;ul&gt;
          @forelse($services as $service)
  
          &lt;li&gt;{{ $service }}&lt;/li&gt;
  
        @empty
  
          &lt;li&gt;this list is empty&lt;/li&gt;
  
          @endforelse
      &lt;/ul&gt;
  @endsection
  </code></pre>
  <p>code for route file </p>
  <pre><code>route::view('/services','services');
  </code></pre>