Route::resource PHP Метод

resource() публичный статический метод

Route a resource to a controller.
public static resource ( string $name, string $controller, array $options = [] ) : void
$name string
$controller string
$options array
Результат void
        public static function resource($name, $controller, $options = array())
        {
            \Illuminate\Routing\Router::resource($name, $controller, $options);
        }

Usage Example

Пример #1
1
 public static function run()
 {
     foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) {
         $file_parts = explode('/', $filename);
         $file = array_pop($file_parts);
         $file = rtrim($file, '.php');
         if ($file == 'Controller') {
             continue;
         }
         $controllerName = 'App\\Http\\Controllers\\' . $file;
         $controller = new $controllerName();
         if (isset($controller->exclude) && $controller->exclude === true) {
             continue;
         }
         $methods = [];
         $reflector = new \ReflectionClass($controller);
         foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) {
             // check whether method is explicitly defined in this class
             if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) {
                 $methods[] = $rMethod->getName();
             }
         }
         \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]);
     }
 }
All Usage Examples Of Route::resource