Illuminate\Routing\Router::resource PHP Method

resource() public method

Route a resource to a controller.
public resource ( string $name, string $controller, array $options = [] ) : void
$name string
$controller string
$options array
return void
    public function resource($name, $controller, array $options = [])
    {
        if ($this->container && $this->container->bound('Illuminate\\Routing\\ResourceRegistrar')) {
            $registrar = $this->container->make('Illuminate\\Routing\\ResourceRegistrar');
        } else {
            $registrar = new ResourceRegistrar($this);
        }
        $registrar->register($name, $controller, $options);
    }

Usage Example

 public function map(Router $router)
 {
     $router->group(['prefix' => 'andersonef'], function () use($router) {
         $router->resource('componentes/animal', 'Andersonef\\Componentes\\Animal\\Controllers\\AnimalServiceController', ['only' => ['index']]);
         $router->resource('server/componentes/animal', 'Andersonef\\Componentes\\Animal\\Controllers\\Server\\AnimalServiceController', ['only' => ['index']]);
     });
 }
All Usage Examples Of Illuminate\Routing\Router::resource