title: Method [validate] does not exist error in laravel 5.2
body: <p>I have just started learning laravel.
  I am using laravel 5.2.29
  I am getting error when running the code:</p>
  
  <blockquote>
    <p>Whoops, looks like something went wrong.
    BadMethodCallException in Controller.php line 107:
    Method [validate] does not exist.</p>
  </blockquote>
  
  <p>Here is the error line displayed:</p>
  
  <pre><code>in Controller.php line 107
  2.at Controller-&gt;__call('validate', array(object(Request), array('action' =&gt;        'required', 'name' =&gt; 'required'))) in NiceActionController.php line 31
  3.at NiceActionController-&gt;validate(object(Request), array('action' =&gt; 'required', 'name' =&gt; 'required')) in NiceActionController.php line 31
  4.at NiceActionController-&gt;postNiceAction(object(Request))
  5.at call_user_func_array(array(object(NiceActionController), 'postNiceAction'), array(object(Request))) in Controller.php line 80
  6.at Controller-&gt;callAction('postNiceAction', array(object(Request))) in ControllerDispatcher.php line 146
  7.at ControllerDispatcher-&gt;call(object(NiceActionController), object(Route), 'postNiceAction') in ControllerDispatcher.php line 94
  8.at ControllerDispatcher-&gt;Illuminate\Routing\{closure}(object(Request))
  9.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
  10.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request))
  11.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  12.at Pipeline-&gt;then(object(Closure)) in ControllerDispatcher.php line 96
  13.at ControllerDispatcher-&gt;callWithinStack(object(NiceActionController), object(Route), object(Request), 'postNiceAction') in ControllerDispatcher.php line 54
  14.at ControllerDispatcher-&gt;dispatch(object(Route), object(Request), 'App\Http\Controllers\NiceActionController', 'postNiceAction') in Route.php line 174
  15.at Route-&gt;runController(object(Request)) in Route.php line 140
  16.at Route-&gt;run(object(Request)) in Router.php line 724
  17.at Router-&gt;Illuminate\Routing\{closure}(object(Request))
  18.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
  19.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
  20.at VerifyCsrfToken-&gt;handle(object(Request), object(Closure))
  21.at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  22.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  23.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  24.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
  25.at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure))
  26.at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  27.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  28.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  29.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
  30.at StartSession-&gt;handle(object(Request), object(Closure))
  31.at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  32.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  33.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  34.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
  35.at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure))
  36.at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  37.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  38.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  39.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
  40.at EncryptCookies-&gt;handle(object(Request), object(Closure))
  41.at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  42.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  43.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  44.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
  45.at VerifyCsrfToken-&gt;handle(object(Request), object(Closure))
  46.at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  47.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  48.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  49.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
  50.at ShareErrorsFromSession-&gt;handle(object(Request), object(Closure))
  51.at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  52.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  53.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  54.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
  55.at StartSession-&gt;handle(object(Request), object(Closure))
  56.at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  57.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  58.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  59.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
  60.at AddQueuedCookiesToResponse-&gt;handle(object(Request), object(Closure))
  61.at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  62.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  63.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  64.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
  65.at EncryptCookies-&gt;handle(object(Request), object(Closure))
  66.at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
  67.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  68.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  69.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request))
  70.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  71.at Pipeline-&gt;then(object(Closure)) in Router.php line 726
  72.at Router-&gt;runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
  73.at Router-&gt;dispatchToRoute(object(Request)) in Router.php line 675
  74.at Router-&gt;dispatch(object(Request)) in Kernel.php line 246
  75.at Kernel-&gt;Illuminate\Foundation\Http\{closure}(object(Request))
  76.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
  77.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
  78.at CheckForMaintenanceMode-&gt;handle(object(Request), object(Closure))
  79.at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'),         array(object(Request), object(Closure))) in Pipeline.php line 124
  80.at Pipeline-&gt;Illuminate\Pipeline\{closure}(object(Request))
  81.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
  82.at Pipeline-&gt;Illuminate\Routing\{closure}(object(Request))
  83.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
  84.at Pipeline-&gt;then(object(Closure)) in Kernel.php line 132
  85.at Kernel-&gt;sendRequestThroughRouter(object(Request)) in Kernel.php line 99
  86.at Kernel-&gt;handle(object(Request)) in index.php line 54
  </code></pre>
  
  <p>My route code:</p>
  
  <pre><code>&lt;?php
  
  
  Route::group(['middleware' =&gt; ['web']], function(){
  
  Route::get('/', function () {
      return view('home');
  })-&gt;name('home');
  
  Route::group(['prefix'=&gt;'do'], function(){
  
  
      Route::get('/{action}/{name?}', [
          'uses' =&gt; 'NiceActionController@getNiceAction', 
          'as' =&gt; 'niceaction'  //router name same as -&gt;name('routername')
      ]);
  
  
  
      Route::post('/', [
  
          'uses' =&gt; 'NiceActionController@postNiceAction',
          'as'   =&gt; 'benice'
  
      ]);
  
  });
  
  });
  </code></pre>
  
  <p>My Controller code is given below:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  
  
  use Illuminate\Routing\Controller;
  use \Illuminate\Http\Request;
  
  class NiceActionController extends Controller
  {
  public function getNiceAction($action, $name=null)
  {
      return view('actions.'.$action, ['name' =&gt; $name]);
  
  }
  
  public function postNiceAction(Request $request)
  {
  
      $this-&gt;validate($request, [
  
             'action' =&gt; 'required',
             'name' =&gt;'required'
  
         ]);
  
              return view('actions.nice',            ['action'=&gt;$request['action'],'name'=&gt;$this-&gt;transformName($request['name'])]);
  
  }
  private function transformName($name)
  {
      $prefix='KING';
      return $prefix.strtoupper($name);
  }
  }
  </code></pre>
  
  <p>My base main controller "controller" has following code:</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;
  use Illuminate\Foundation\Auth\Access\AuthorizesResources;
  
  
  class Controller extends BaseController
  {
  use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
  
  }
  </code></pre>
  
  <p>Am i missing anything????</p>