Call to undefined method Route::name()
<p>im trying to set a name for my route </p>

<pre><code>Route::get('test/show/{id}' , 'TestController@show');
</code></pre>

<p>accourding to documentation </p>

<blockquote>
  <p>Instead of specifying the route name in the route array definition,
  you may chain the name method onto the end of the route definition:</p>

<pre><code>Route::get('user/profile','UserController@showProfile')-&gt;name('profile');
</code></pre>
</blockquote>

<p>so i wrote </p>

<pre><code>Route::get('test/show/{id}' , 'TestController@show')-&gt;name('testShow');
</code></pre>

<p>but i get </p>

<pre><code>FatalErrorException in routes.php line 28:
Call to undefined method Illuminate\Routing\Route::name()
in routes.php line 28
at FatalErrorException-&gt;__construct() in compiled.php line 1743
at HandleExceptions-&gt;fatalExceptionFromError() in compiled.php line 1738
at HandleExceptions-&gt;handleShutdown() in compiled.php line 0
in compiled.php line 17158
at RouteServiceProvider-&gt;App\Providers\{closure}() in compiled.php line 6819
at call_user_func() in compiled.php line 6819
at Router-&gt;group() in compiled.php line 17159
at RouteServiceProvider-&gt;map() in compiled.php line 925
at call_user_func_array() in compiled.php line 925
at Container-&gt;call() in compiled.php line 4858
at RouteServiceProvider-&gt;loadRoutes() in compiled.php line 4840
at RouteServiceProvider-&gt;boot() in compiled.php line 17153
at RouteServiceProvider-&gt;boot() in compiled.php line 925
at call_user_func_array() in compiled.php line 925
at Container-&gt;call() in compiled.php line 1518
at Application-&gt;bootProvider() in compiled.php line 1510
at Application-&gt;Illuminate\Foundation\{closure}() in compiled.php line 1511
at array_walk() in compiled.php line 1511
at Application-&gt;boot() in compiled.php line 1785
at BootProviders-&gt;bootstrap() in compiled.php line 1311
at Application-&gt;bootstrapWith() in compiled.php line 1928
at Kernel-&gt;bootstrap() in compiled.php line 1890
at Kernel-&gt;sendRequestThroughRouter() in compiled.php line 1880
at Kernel-&gt;handle() in index.php line 53
in index.php line 21
at {main}() in index.php line 0
</code></pre>