title: Custom Route in Resource Controller
body: <p>I'm trying to build a CMS in Laravel 5.8 but got stuck in creating a custom route for my resource controller. I had used below code to try to achive this:</p>
  <pre><code>Route::post('/photo-gallery/status', 'backend\Photogallery@updStatus')-&gt;name('photo.status'); 
  Route::resource('/photo-gallery', 'backend\Photogallery');
  </code></pre>
  <p>Reloading the page gives me error as <strong>Route [photo.status] not defined</strong>.</p>
  <p>So, I cleared my route cache and tried to list my routes but got below error in terminal as <strong>ReflectionException : Class App\Http\Controllers\Users does not exist</strong></p>
  <p>My Users controller class is at this location &quot;App\Http\Controllers\backend&quot;.</p>
  <pre><code>//Auth::routes();
  </code></pre>
  <p>If the above route is uncommented, all the pages works fine but the route list method is not working. So, I just commented this route to check and voila things worked.</p>
  <p>My index page gets loaded without any error. But things took an ugly turn when I tried posting the form using ajax to this custom route page. The form is getting <strong>posted to my update method and not updStatus method</strong>. To resolve this issue, I modified the custom route method from POST to PUT but not worked. So i reverted back the route method to POST and now i'm back to square one with same error &quot;ReflectionException : Class App\Http\Controllers\Users does not exist&quot; in terminal and &quot; Route [photo.status] not defined.&quot; though <strong>&quot;Auth::routes();&quot; is still being commented</strong></p>
  <p>Below are the complete codes</p>
  <p>Routes:</p>
  <pre><code>//Auth::routes();
  Route::group(['as'=&gt;'cms.'  ,'prefix'=&gt;'cms'],function(){
      Route::get('/login', 'backend\Login@index')-&gt;name('login');
      Route::post('/login', 'backend\Login@doLogin')-&gt;name('login.do');
      Route::any('/logout', 'backend\Logout@index')-&gt;name('logout');
      Route::get('/', 'backend\Dashboard@index')-&gt;name('dashboard');
      Route::resource('/user-management', 'backend\Users');
      Route::resource('/menu-parent', 'backend\Menumanagement');
      Route::resource('/menu-child', 'backend\Submenumanagement');
      Route::resource('/privilege-management', 'backend\Privileges');
  
      Route::post('/photo-gallery/status', 'backend\Photogallery@updStatus')-&gt;name('photo.status'); 
      Route::resource('/photo-gallery', 'backend\Photogallery');
  });
  </code></pre>
  <p>Users controller</p>
  <pre><code>namespace App\Http\Controllers\backend;
  
  class Users extends Controller{
    ... other codes here
  }
  </code></pre>
  <p>Photogallery Controller</p>
  <pre><code>namespace App\Http\Controllers\backend;
  use Auth;
  
  class Photogallery extends Controller
  {
        // CUSTOM RESOURCE FUNCTIONS STARTS
        public function updStatus($request)
        {
        // THE AJAX FORM WILL BE POSTED HERE
        }
  }
  </code></pre>
  <p>index.blade.php</p>
  <pre><code>    $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name=&quot;csrf-token&quot;]').attr('content')
            }
        });
  
      $('.toggle-class').change(function() {
            var status = $(this).prop('checked') == true ? 1 : 0; 
            var rec_id = $(this).data('id'); 
  
          $.ajax({
              type: &quot;post&quot;,
              dataType: &quot;json&quot;,
              url: &quot;{{ route('photo.status') }}&quot;,
              data: {'newStatus': status, 'recordId': rec_id, '_method': 'PUT'},
              success: function(response){
                console.log(response)
              }
            });
       });
  </code></pre>
  <p>I hope I'm able to explain the issues which I'm facing. Can anyone help me in all this?</p>
  <p>Much Regards,</p>
  <p>Javed</p>