I'm working on a system where users are able to create pages and give those pages custom URLs.
I need to be able to protect certain URLs, however. Particularly those that I have defined in the routes.php files in my packages.
I've tried this, but it returns an empty array:
$collection = new \Illuminate\Routing\RouteCollection();
dd($collection->getRoutes());
How do I get my routes (located in various routes.php files) to register in the RouteCollection class so I can check against those routes when a user creates a page and sets the URL?
Nevermind - Got this one solved. The problem was that I was newing up the RouteCollection class.
This appears to work:
use Illuminate\Foundation\Application;
class SomeController extends BaseController {
public function __construct(Application $application)
{
$this->application = $application;
dd($this->application->router->getRoutes());
}
}