Skip to content

Commit

Permalink
Dynamic routes
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Nov 6, 2023
1 parent e382bac commit 7dc69fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"Thunk\\Verbs\\Examples\\Monopoly\\": "examples/Monopoly/src/",
"Thunk\\Verbs\\Examples\\Monopoly\\Tests\\": "examples/Monopoly/tests/",
"Thunk\\Verbs\\Examples\\Monopoly\\Database\\Factories\\": "examples/Monopoly/database/factories/",

"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
Expand Down
10 changes: 0 additions & 10 deletions src/VerbsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,5 @@ public function boot()
$this->app->make(Broker::class)->fire($event);
}
});

// $this->publishes([
// __DIR__.'/../config/verbs.php' => config_path('verbs.php'),
// ], 'verbs-config');

// $this->publishes([
// __DIR__.'/../database/migrations/create_verb_events_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_verb_events_table.php'),
// __DIR__.'/../database/migrations/create_verb_snapshots_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_verb_snapshots_table.php'),
// __DIR__.'/../database/migrations/create_verb_state_events_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_verb_state_events_table.php'),
// ], 'verbs-migrations');
}
}
15 changes: 12 additions & 3 deletions workbench/routes/web.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
<?php

use Illuminate\Support\Facades\Route;
use InterNACHI\Modular\Support\FinderCollection;
use Symfony\Component\Finder\SplFileInfo;

Route::prefix('monopoly')->group(function () {
require __DIR__.'/../../examples/Monopoly/routes/web.php';
});
// Dynamically load all examples into their own prefixes
FinderCollection::forDirectories()
->depth(0)
->inOrEmpty(__DIR__.'/../../examples')
->each(function (SplFileInfo $file) {
if (file_exists($routes = "{$file->getRealPath()}/routes/web.php")) {
Route::prefix(str($file->getBasename())->kebab()->toString())
->group(fn () => require $routes);
}
});

0 comments on commit 7dc69fe

Please sign in to comment.