title: Laravel Undefined variable: Name
body: <p>hello I'm trying to pass the $Name to the view and i cant seem to get it to work and the video i followed line for line didn't seem to work any help would be great appreciated.</p>
  
  <p>Edit. I know this is Novice level but its giving the most trouble in my project right now. </p>
  
  <p>Controller</p>
  
  <pre><code>    &lt;?php
  
  namespace App\Http\Controllers;
  
  use Illuminate\Foundation\Bus\DispatchesJobs;
  use Illuminate\Routing\Controller as BaseController;
  use Illuminate\Foundation\Validation\ValidatesRequests;
  use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
  
  abstract class RequestController extends BaseController
  {
      public function GetName(){
          $name = ['one','two','three'];
          return view::make('home', ['name' =&gt; $name]);
      }
  } 
  </code></pre>
  
  <p>routes.php</p>
  
  <pre><code>&lt;?php
  
  /*
  |--------------------------------------------------------------------------
  | Application Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the controller to call when that URI is requested.
  |
  */
  
  Route::get('/', function () {
      return view('welcome');
  });
  
  Route::get('home', 'RequestController@GetName');
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@foreach( $name as $names)
  &lt;tr&gt;
  &lt;th&gt;{{ $names }}&lt;/th&gt;
  &lt;/tr&gt;
  @endForeach
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>ErrorException in d223bf579fc7c74c7e9ee61a6d17702e line 399:
  Undefined variable: name (View: D:\Xampp\htdocs\blog\resources\views\home.blade.php)
  in d223bf579fc7c74c7e9ee61a6d17702e line 399
  at CompilerEngine-&gt;handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
  at PhpEngine-&gt;evaluatePath('D:\Xampp\htdocs\blog\storage\framework\views/d223bf579fc7c74c7e9ee61a6d17702e', array('__env' =&gt; object(Factory), 'app' =&gt; object(Application), 'errors' =&gt; object(ViewErrorBag))) in CompilerEngine.php line 58
  at CompilerEngine-&gt;get('D:\Xampp\htdocs\blog\resources\views/home.blade.php', array('__env' =&gt; object(Factory), 'app' =&gt; object(Application), 'errors' =&gt; object(ViewErrorBag))) in View.php line 135
  at View-&gt;getContents() in View.php line 106
  at View-&gt;renderContents() in View.php line 80
  at View-&gt;render() in Response.php line 51
  at Response-&gt;setContent(object(View)) in Response.php line 198
  at Response-&gt;__construct(object(View)) in Router.php line 1229
  at Router-&gt;prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 113
  at ControllerDispatcher-&gt;Illuminate\Routing\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 45
  at Authenticate-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(Authenticate), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  at Pipeline-&gt;then(object(Closure)) in ControllerDispatcher.php line 114
  at ControllerDispatcher-&gt;callWithinStack(object(HomeController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 69
  at ControllerDispatcher-&gt;dispatch(object(Route), object(Request), '\Bestmomo\Scafold\Http\Controllers\HomeController', 'index') in Route.php line 203
  at Route-&gt;runWithCustomDispatcher(object(Request)) in Route.php line 134
  at Route-&gt;run(object(Request)) in Router.php line 708
  at Router-&gt;Illuminate\Routing\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  at Pipeline-&gt;then(object(Closure)) in Router.php line 710
  at Router-&gt;runRouteWithinStack(object(Route), object(Request)) in Router.php line 675
  at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 635
  at Router-&gt;dispatch(object(Request)) in Kernel.php line 236
  at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
  at VerifyCsrfToken-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
  at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
  at StartSession-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
  at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
  at EncryptCookies-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
  at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure))
  at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  at Pipeline-&gt;then(object(Closure)) in Kernel.php line 122
  at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 87
  at Kernel-&gt;handle(object(Request)) in index.php line 54
  </code></pre>