Skip to content

Commit

Permalink
Merge pull request #333 from inmass/master
Browse files Browse the repository at this point in the history
Add the possibility to have custom routes without having to edit AppServiceProvider
  • Loading branch information
munafio authored Mar 17, 2024
2 parents c7d3c63 + cee2e13 commit 33f9ca4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/ChatifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ protected function setPublishes()
// CSS
__DIR__ . '/assets/sounds' => public_path('sounds/chatify'),
], 'chatify-assets');

// Routes (API and Web)
$this->publishes([
__DIR__ . '/routes' => base_path('routes/chatify')
], 'chatify-routes');
}

/**
Expand All @@ -102,12 +107,21 @@ protected function setPublishes()
*/
protected function loadRoutes()
{
Route::group($this->routesConfigurations(), function () {
$this->loadRoutesFrom(__DIR__ . '/routes/web.php');
});
Route::group($this->apiRoutesConfigurations(), function () {
$this->loadRoutesFrom(__DIR__ . '/routes/api.php');
});
if (config('chatify.routes.custom')) {
Route::group($this->routesConfigurations(), function () {
$this->loadRoutesFrom(base_path('routes/chatify/web.php'));
});
Route::group($this->apiRoutesConfigurations(), function () {
$this->loadRoutesFrom(base_path('routes/chatify/api.php'));
});
} else {
Route::group($this->routesConfigurations(), function () {
$this->loadRoutesFrom(__DIR__ . '/routes/web.php');
});
Route::group($this->apiRoutesConfigurations(), function () {
$this->loadRoutesFrom(__DIR__ . '/routes/api.php');
});
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function handle()
'assets' => public_path('css/chatify'),
'models' => app_path(($this->isV8 ? 'Models/' : '').'ChMessage.php'),
'migrations' => database_path('migrations/2019_09_22_192348_create_messages_table.php'),
'routes' => base_path('routes/chatify'),
];

foreach ($assetsToBePublished as $target => $path) {
Expand Down
1 change: 1 addition & 0 deletions src/config/chatify.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
|-------------------------------------
*/
'routes' => [
'custom' => env('CHATIFY_CUSTOM_ROUTES', false),
'prefix' => env('CHATIFY_ROUTES_PREFIX', 'chatify'),
'middleware' => env('CHATIFY_ROUTES_MIDDLEWARE', ['web','auth']),
'namespace' => env('CHATIFY_ROUTES_NAMESPACE', 'Chatify\Http\Controllers'),
Expand Down

0 comments on commit 33f9ca4

Please sign in to comment.