0

I have controllers under the Panel namespace in "App\Htpp\Controllers" directory, so my namespace is : App\Http\Controllers\Panel

I overrided the routeScans() function like below, but did not help!

  public function routeScans() {
    $classes = parent::routeScans();

    $classes = array_merge(
        $classes,
        $this->getClassesFromNamespace('App\Http\Controllers\Panel')
     );

     return $classes;
   }

How can I scan them for routes ?

Mahdi Younesi
  • 6,889
  • 2
  • 20
  • 51

1 Answers1

0

I have created a function for listing all available routes like this, you can use it and modify as per your need

function routelist () {
        $allRoutes = Route::getRoutes()->getRoutes();
        $availableRoutes = [];
        foreach ($allRoutes as $route) {
            $availableRoutes['availableAPI'][$route->getName()] = [
                'method' => $route->getMethods()[0],
                "uri" => $route->getUri(),
                "name" => $route->getName(),
                "controller" => $route->getAction()['uses'],
            ];
        }

        $table = "<table>";
        foreach ($availableRoutes['availableAPI'] as $key => $entry) {
            //dd($entry['controller']);
            $table .= "<tr>";
            $table .= "<td>" . @$entry['method'] . "</td>";
            $table .= "<td>" . @$entry['uri'] . "</td>";
            $table .= "<td>" . @$entry['name'] . "</td>";

            if (is_string($entry['controller'])) {
                $table .= "<td>" . @$entry['controller'] . "</td>";
            } else {
                $table .= "<td>closure function(){}</td>";
            }
            $table .= "</tr>";
        }
        $table .= "</table>";
        return $table;
    }
Bhavesh B
  • 1,121
  • 12
  • 25