Laravel ErrorException & Undefined variable even though the variable is defined and has a value
<p>I am getting an Undefined Variable error even though I have passed the variable through the controller using <code>compact()</code>, and I even tried passing the variable to the blade view like so <code>return view('address/create', ['addresses' =&gt; $addresses]);</code></p>

<p>Route:</p>

<pre><code>Route::get('/addresses/create', function () {
    return view('address/create');
})-&gt;middleware(\App\Http\Middleware\CheckSuperUser::class);
</code></pre>

<p>Controller function:</p>

<pre><code>public function create()
    {
        $addresses = Address::all();
        return view('address/create', compact('addresses'));
    }
</code></pre>

<p>View code (address/create):</p>

<pre><code>&lt;div class="col-md-4"&gt;
        &lt;legend&gt;Available Addresses&lt;/legend&gt;
        @foreach($addresses as $address)
            {{ $address }}
        @endforeach
&lt;/div&gt;
</code></pre>

<p>Error message: </p>

<pre><code>ErrorException in 656cf590f275580a61ff680434f2a7bc0399cbdb.php line 51:
Undefined variable: addresses (View: C:\Users\xxx\xxx\xxx\dorf\resources\views\address\create.blade.php)
</code></pre>

<p>I tried clearing the cache and views, but that didn't help at all. Restarted the server and the computer and still same error. Any ideas what might be going on?</p>