Skip to content

Commit

Permalink
[5.x] Auto-load addon routes (#10880)
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean authored Oct 1, 2024
1 parent dfc593a commit ca03ceb
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/Providers/AddonServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,35 @@ protected function bootPublishables()

protected function bootRoutes()
{
if ($web = Arr::get($this->routes, 'web')) {
$directory = $this->getAddon()->directory();

$web = Arr::get(
array: $this->routes,
key: 'web',
default: $this->app['files']->exists($path = $directory.'routes/web.php') ? $path : null
);

if ($web) {
$this->registerWebRoutes($web);
}

if ($cp = Arr::get($this->routes, 'cp')) {
$cp = Arr::get(
array: $this->routes,
key: 'cp',
default: $this->app['files']->exists($path = $directory.'routes/cp.php') ? $path : null
);

if ($cp) {
$this->registerCpRoutes($cp);
}

if ($actions = Arr::get($this->routes, 'actions')) {
$actions = Arr::get(
array: $this->routes,
key: 'actions',
default: $this->app['files']->exists($path = $directory.'routes/actions.php') ? $path : null
);

if ($actions) {
$this->registerActionRoutes($actions);
}

Expand Down

0 comments on commit ca03ceb

Please sign in to comment.