From c8f0b46a3c0a1799908e14b7c4a1b346b2dafe41 Mon Sep 17 00:00:00 2001 From: Antoine Le Gonidec Date: Fri, 12 Jul 2024 12:58:38 +0200 Subject: [PATCH] Improve routes overrides --- Http/Controllers/CrmController.php | 2 +- Http/routes.php | 4 +-- README.md | 46 ++---------------------------- module.json | 2 +- 4 files changed, 5 insertions(+), 49 deletions(-) diff --git a/Http/Controllers/CrmController.php b/Http/Controllers/CrmController.php index 817069b..13d9f99 100644 --- a/Http/Controllers/CrmController.php +++ b/Http/Controllers/CrmController.php @@ -68,7 +68,7 @@ class CrmController extends BaseCrmController { } if ($fail || $validator->fails()) { - return redirect()->route('mmfrestrictedcustomers.create_customer') + return redirect()->route('crm.create_customer') ->withErrors($validator) ->withInput(); } diff --git a/Http/routes.php b/Http/routes.php index 52dd5ce..0834314 100644 --- a/Http/routes.php +++ b/Http/routes.php @@ -14,10 +14,8 @@ Route::group(['middleware' => 'web', 'prefix' => \Helper::getSubdirectory(), 'na Route::post('/customers/ajax', ['uses' => CustomersController::class . '@ajax', 'laroute' => true])->name('customers.ajax'); // Crm module Route::group([ 'roles' => ['user', 'admin'] ], function() { - Route::get('/customers/new', CrmController::class . '@createCustomer')->name('mmfrestrictedcustomers.create_customer'); + Route::get('/customers/new', CrmController::class . '@createCustomer')->name('crm.create_customer'); Route::post('/customers/new', CrmController::class . '@createCustomerSave'); - Route::get('/crm/ajax-html/{action}/{param?}', ['uses' => CrmController::class . '@ajaxHtml'])->name('crm.ajax_html'); - Route::get('/customers/fields/ajax-search', ['uses' => CrmController::class . '@ajaxSearch', 'laroute' => true])->name('crm.ajax_search'); Route::post('/crm/ajax', ['uses' => CrmController::class . '@ajax', 'laroute' => true])->name('crm.ajax'); }); }); diff --git a/README.md b/README.md index 23e23c4..134086d 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,8 @@ git clone https://port.numenaute.org/MMF/freescout-restricted-customers.git Modu ### Edit the application routes -Routes set in other modules or in Freescout itself can not be automatically overridden. -Overriding them has to be done manually, in the three following files. +Routes set in Freescout itself can not be automatically overridden. +Overriding them has to be done manually, in the following file: #### routes/web.php @@ -80,48 +80,6 @@ Route::get('/customers/ajax-search', ['uses' => '\Modules\MMFRestrictedCustomers Route::post('/customers/ajax', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@ajax', 'laroute' => true])->name('customers.ajax'); ``` -#### Modules/Crm/Http/routes.php - -The following list of routes: - -```php -Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['user', 'admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'Modules\Crm\Http\Controllers'], function() -{ - Route::get('/customers/new', 'CrmController@createCustomer')->name('crm.create_customer'); - Route::post('/customers/new', 'CrmController@createCustomerSave'); - Route::get('/crm/ajax-html/{action}/{param?}', ['uses' => 'CrmController@ajaxHtml'])->name('crm.ajax_html'); - Route::get('/customers/fields/ajax-search', ['uses' => 'CrmController@ajaxSearch', 'laroute' => true])->name('crm.ajax_search'); - Route::post('/crm/ajax', ['uses' => 'CrmController@ajax', 'laroute' => true])->name('crm.ajax'); -}); -``` - -should be replaced with: - -```php -Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['user', 'admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'Modules\MMFRestrictedCustomers\Http\Controllers'], function() -{ - Route::get('/customers/new', 'CrmController@createCustomer')->name('mmfrestrictedcustomers.create_customer'); - Route::post('/customers/new', 'CrmController@createCustomerSave'); - Route::get('/crm/ajax-html/{action}/{param?}', ['uses' => '\Modules\Crm\Http\Controllers\CrmController@ajaxHtml'])->name('crm.ajax_html'); - Route::get('/customers/fields/ajax-search', ['uses' => 'CrmController@ajaxSearch', 'laroute' => true])->name('crm.ajax_search'); - Route::post('/crm/ajax', ['uses' => 'CrmController@ajax', 'laroute' => true])->name('crm.ajax'); -}); -``` - -#### Modules/Crm/Providers/CrmServiceProvider.php - -At line 173, this route call: - -```php - $html = __('Customers').' \' class="btn btn-bordered btn-xs" style="position:relative;top:-1px;margin-left:4px;">'; -``` - -should be replaced with: - -```php - $html = __('Customers').' \' class="btn btn-bordered btn-xs" style="position:relative;top:-1px;margin-left:4px;">'; -``` - ### Edit the artisan commands Console commands set in other modules or in Freescout itself can not be automatically overridden. diff --git a/module.json b/module.json index 1037560..d17f7bf 100644 --- a/module.json +++ b/module.json @@ -10,7 +10,7 @@ "license": "AGPL-3.0-only", "keywords": [], "active": 0, - "order": 0, + "order": 1, "providers": [ "Modules\\MMFRestrictedCustomers\\Providers\\MMFRestrictedCustomersServiceProvider" ],