version() public method

This method can be called without the third parameter, however, the callback should always be the last paramter.
public version ( string $version, array | callable $second, callable $third = null ) : void
$version string
$second array | callable
$third callable
return void
Example #1
0
 /**
  * Bootstrap any application services.
  *
  * @param Router $api
  */
 public function boot(Router $api)
 {
     $path = app_path('Api/routes.php');
     $api->version('v1', ['namespace' => $this->namespace], function ($api) use($path) {
         require $path;
     });
 }
 /**
  * Define the routes for the application.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function map(Router $router, ApiRouter $apiRouter)
 {
     $apiRouter->version($this->version, function ($apiRouter) use($router) {
         $apiRouter->group(['namespace' => $this->namespace], function ($api) use($router) {
             $router->group(['namespace' => $this->namespace], function ($router) use($api) {
                 require app_path('Http/routes.php');
             });
         });
     });
 }
 public function map(\Dingo\Api\Routing\Router $api)
 {
     $api->version(['version' => 'v1'], function ($api) {
         return require app_path('Api/v1/Http/routes.php');
     });
 }
 /**
  * Merge routes defined by packages into API router.
  *
  * @param  \Dingo\Api\Routing\Router  $api
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 protected function mergePackgeRoutes(ApiRouter &$api, Router $router)
 {
     foreach ($router->getRoutes() as $route) {
         $api->version(array_keys($api->getRoutes()), function ($api) use($route) {
             $action = $route->getAction();
             // Remove prefix if present
             if (isset($action['prefix'])) {
                 unset($action['prefix']);
             }
             $api->addRoute($route->getMethods(), $route->uri(), $action);
         });
     }
 }