title: Laravel 5.2 to 5.3 - converting routes.php to web and api route files?
body: <p>I am upgrading my guitar lessons site from 5.2 to 5.3. My previous developer has a full time job so now I am the site owner and developer... I am a better guitarist than developer...</p>
  
  <p>My site has a backend for adding guitar lesson content. The routes.php file, among other things,  had these lines:</p>
  
  <pre><code>function RegisterResourceRoute($route, $name) {
      Route::get($route,              'Api\\'.$name.'Controller@getAll');
      Route::get($route.'/{id}',      'Api\\'.$name.'Controller@get');
      Route::post($route,             'Api\\'.$name.'Controller@post');
      Route::put($route.'/{id}',      'Api\\'.$name.'Controller@put');
      Route::delete($route.'/{id}',   'Api\\'.$name.'Controller@delete');
  }
  
  // Api
  Route::group(['middleware' =&gt; ['api', 'auth', 'admin']], function () {
      Route::group(array('prefix' =&gt; 'api'), function() {
          RegisterResourceRoute('file', 'File');
          RegisterResourceRoute('photo', 'Photo');
          RegisterResourceRoute('category', 'Category');
          RegisterResourceRoute('tag', 'Tag');
          RegisterResourceRoute('lesson', 'Lesson');
          RegisterResourceRoute('exercise', 'Exercise');
          RegisterResourceRoute('user', 'User');
      });
      Route::post('/api/email', 'Api\\EmailController@send');
  
  });
  </code></pre>
  
  <p>Then I see in the angular related js used in the view, this for the Exercise resource:</p>
  
  <pre><code>// Exercise
          .when('/exercise', {
              templateUrl: 'views/dashboard/exercise/view-all.html',
              controller: 'ExerciseViewAllController'
          })
          .when('/exercise/create/:lessonId?', {
              templateUrl: 'views/dashboard/exercise/create.html',
              controller: 'ExerciseCreateController'
          })
          .when('/exercise/view/:id', {
              templateUrl: 'views/dashboard/exercise/view.html',
              controller: 'ExerciseViewController'
          })
          .when('/exercise/edit/:id', {
              templateUrl: 'views/dashboard/exercise/edit.html',
              controller: 'ExerciseEditController'
          })
          .when('/exercise/edit/:id/details', {
              templateUrl: 'views/dashboard/exercise/edit-details.html',
              controller: 'ExerciseDetailsController'
          })
          .when('/exercise/edit/:id/photos', {
              templateUrl: 'views/dashboard/exercise/edit-photos.html',
              controller: 'ExercisePhotosController'
          })
          .when('/exercise/delete/:id', {
              templateUrl: 'views/dashboard/exercise/delete.html',
              controller: 'ExerciseDeleteController'
          })
  </code></pre>
  
  <p>The ViewAllController, for instance, looks like this:</p>
  
  <pre><code>angular.module('dashboard')
      .controller('ExerciseViewAllController', ['$scope', '$http', function ($scope, $http) {
          $scope.exercises = [];
  
          $scope.refresh = function () {
              $scope.exercises = [];
              load();
          };
  
          var load = function () {
              $scope.busy = true;
              $http.get('/api/exercise').then(function (response) {
                  $scope.busy = false;
                  $scope.exercises = response.data;
              }, function (response) {
                  $scope.busy = false;
              });
          };
  
          load();
      }]);
  </code></pre>
  
  <p>I am trying to figure out how 5.3 handles such routing. In my backend dashboard, when I try and view the list of exercises, for instance, I was getting a 404 error for api/exercise.</p>
  
  <p>So I created web.php with this under admin routes:</p>
  
  <pre><code>Route::resource('api/exercise', 'Api\ExerciseController');
  </code></pre>
  
  <p>And in api.php</p>
  
  <pre><code>Route::group(['prefix' =&gt; 'api'], function () { Route::resource('exercise', 'Api\ExerciseController'); });
  </code></pre>
  
  <p>It now works, but I had to change what was previously a getAll() function in the Exercise controller to index(), otherwise there was a error since laravel was looking for the default index method.</p>
  
  <p>I would rather get it working using default route names, and also I have no idea if what I added to web.php and api.php is really the correct way. I see things seem to work but I am worried I am not seeing the whole picture...</p>
  
  <p>Can someone explain what I would do to get these routes working in the true laravel 5.3 way?</p>
  
  <p>thanks!</p>