Passing an array from controller to view laravel using compact
<p>I'm using laravel 5.3 (make:auth automatic register and user authentication generator), and I would like to let user choose their tags in the registration form.</p>

<p>I wanna pass <code>$tags = App\Tag::all();</code> to the <code>register.blade.php</code> file located in <code>views\auth\register.blade.php</code>.</p>

<p>I found this method:</p>

<pre><code>public function showRegistrationForm()
{
    return view('auth.register');
}
</code></pre>

<p>and I would like to do:</p>

<pre><code>public function showRegistrationForm()
{
    $tags = App\Tag::all();
    return view('auth.register', compact($tags));
}
</code></pre>

<p>but I get undefined variable <code>'tags'</code> when trying to reach the <code>register.blade.php</code> file.</p>