Convert the PHP package into a Laravel Module

cf. https://laravelmodules.com/
This commit is contained in:
Antoine Le Gonidec 2024-07-10 17:16:13 +02:00
parent 21d7bbf158
commit c0244f24ef
Signed by: vv221
GPG key ID: 636B78F91CEB80D8
26 changed files with 267 additions and 126 deletions

View file

@ -1,3 +1,8 @@
0.7.0
* Convert the PHP package into a Laravel module,
cf. https://laravelmodules.com/
0.6.1
* Fix the ability to rollback migrations.

5
Config/config.php Normal file
View file

@ -0,0 +1,5 @@
<?php
return [
'name' => 'MMFRestrictedCustomers'
];

View file

@ -4,10 +4,10 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers\Console\Commands;
namespace Modules\MMFRestrictedCustomers\Console\Commands;
use App\Conversation;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer;
use Modules\MMFRestrictedCustomers\Customer;
use App\Events\CustomerCreatedConversation;
use App\Events\CustomerReplied;
use App\Thread;
@ -21,7 +21,7 @@ class FetchEmails extends BaseFetchEmails {
*
* @var string
*/
protected $signature = 'freescout-restricted-customers:fetch-emails {--days=3} {--unseen=1} {--identifier=dummy} {--mailboxes=0}';
protected $signature = 'mmfrestrictedcustomers:fetch-emails {--days=3} {--unseen=1} {--identifier=dummy} {--mailboxes=0}';
/**
* Save email from customer as thread.

View file

@ -0,0 +1,21 @@
<?php
namespace Modules\MMFRestrictedCustomers\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class MMFRestrictedCustomersDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call("OthersTableSeeder");
}
}

View file

@ -4,14 +4,14 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers;
namespace Modules\MMFRestrictedCustomers;
use App\CustomerChannel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Watson\Rememberable\Rememberable;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Mailbox;
use Modules\MMFRestrictedCustomers\Mailbox;
use App\Customer as BaseCustomer;
class Customer extends BaseCustomer {

View file

@ -4,7 +4,7 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers;
namespace Modules\MMFRestrictedCustomers;
use Illuminate\Database\Eloquent\Model;
use Watson\Rememberable\Rememberable;

View file

@ -4,9 +4,9 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers;
namespace Modules\MMFRestrictedCustomers;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer;
use Modules\MMFRestrictedCustomers\Customer;
use App\Mailbox as BaseMailbox;
class Mailbox extends BaseMailbox {

View file

@ -4,13 +4,13 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers;
namespace Modules\MMFRestrictedCustomers\Http\Controllers;
use App\Conversation;
use App\User;
use Illuminate\Http\Request;
use App\Http\Controllers\ConversationsController as BaseConversationsController;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer;
use Modules\MMFRestrictedCustomers\Customer;
class ConversationsController extends BaseConversationsController {
/**
@ -91,7 +91,7 @@ class ConversationsController extends BaseConversationsController {
$search_mailbox = $mailboxes[0];
}
return view('freescout-restricted-customers::conversations/search', [
return view('mmfrestrictedcustomers::conversations/search', [
'folder' => $folder,
'q' => $request->q,
'filters' => $filters,

View file

@ -4,7 +4,7 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers;
namespace Modules\MMFRestrictedCustomers\Http\Controllers;
use App\Conversation;
use Modules\Crm\Entities\CustomerField;
@ -14,9 +14,9 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Modules\Crm\Http\Controllers\CrmController as BaseCrmController;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Email;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Mailbox;
use Modules\MMFRestrictedCustomers\Customer;
use Modules\MMFRestrictedCustomers\Email;
use Modules\MMFRestrictedCustomers\Mailbox;
class CrmController extends BaseCrmController {
public function createCustomer(Request $request) {
@ -26,7 +26,7 @@ class CrmController extends BaseCrmController {
$user = auth()->user();
$mailboxes = $user->mailboxesCanView();
return view('freescout-restricted-customers::create_customer', [
return view('mmfrestrictedcustomers::create_customer', [
'customer' => $customer,
'mailboxes' => $mailboxes,
'emails' => [''],
@ -68,7 +68,7 @@ class CrmController extends BaseCrmController {
}
if ($fail || $validator->fails()) {
return redirect()->route('freescout-restricted-customers.create_customer')
return redirect()->route('mmfrestrictedcustomers.create_customer')
->withErrors($validator)
->withInput();
}

View file

@ -4,14 +4,14 @@
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers;
namespace Modules\MMFRestrictedCustomers\Http\Controllers;
use App\Conversation;
use App\Email;
use Illuminate\Http\Request;
use Validator;
use App\Http\Controllers\CustomersController as BaseCustomersController;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Customer;
use Modules\MMFRestrictedCustomers\Customer;
class CustomersController extends BaseCustomersController {
/**
@ -36,7 +36,7 @@ class CustomersController extends BaseCustomersController {
$emails = [''];
}
return view('freescout-restricted-customers::customers/update', [
return view('mmfrestrictedcustomers::customers/update', [
'customer' => $customer,
'mailboxes' => $mailboxes,
'emails' => $emails,
@ -382,11 +382,11 @@ class CustomersController extends BaseCustomersController {
// Conversations navigation
case 'customers_pagination':
$customers = app('MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\ConversationsController')->searchCustomers($request, $user);
$customers = app('Modules\MMFRestrictedCustomers\Http\Controllers\ConversationsController')->searchCustomers($request, $user);
$response['status'] = 'success';
$response['html'] = view('freescout-restricted-customers::customers/partials/customers_table', [
$response['html'] = view('mmfrestrictedcustomers::customers/partials/customers_table', [
'customers' => $customers,
])->render();
break;

33
Http/routes.php Normal file
View file

@ -0,0 +1,33 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
use Illuminate\Support\Facades\Route;
use Modules\MMFRestrictedCustomers\Http\Controllers\ConversationsController;
use Modules\MMFRestrictedCustomers\Http\Controllers\CrmController;
use Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController;
Route::group(['middleware' => 'web', 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'Modules\MMFRestrictedCustomers\Http\Controllers'], function() {
// Customers
Route::get('/customers/{id}/edit', CustomersController::class . '@update')->name('customers.update');
Route::post('/customers/{id}/edit', CustomersController::class . '@updateSave');
Route::get('/customers/{id}/', CustomersController::class . '@conversations')->name('customers.conversations');
Route::get('/customers/ajax-search', ['uses' => CustomersController::class . '@ajaxSearch', 'laroute' => true])->name('customers.ajax_search');
Route::post('/customers/ajax', ['uses' => CustomersController::class . '@ajax', 'laroute' => true])->name('customers.ajax');
// Conversations
Route::get('/search', ConversationsController::class . '@search')->name('conversations.search');
// Crm module
Route::group([ 'roles' => ['user', 'admin'] ], function() {
Route::get('/customers/new', CrmController::class . '@createCustomer')->name('mmfrestrictedcustomers.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');
});
Route::group([ 'roles' => ['admin'] ], function() {
Route::post('/customers/export', ['uses' => CrmController::class . '@export'])->name('crm.export');
Route::post('/crm/ajax-admin', ['uses' => CrmController::class . '@ajaxAdmin', 'laroute' => true])->name('crm.ajax_admin');
});
});

View file

@ -0,0 +1,109 @@
<?php
namespace Modules\MMFRestrictedCustomers\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Modules\MMFRestrictedCustomers\Console\Commands\FetchEmails;
class MMFRestrictedCustomersServiceProvider extends ServiceProvider {
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Boot the application events.
*
* @return void
*/
public function boot() {
$this->registerConfig();
$this->registerViews();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->commands([
FetchEmails::class,
]);
$this->hooks();
}
/**
* Module hooks.
*/
public function hooks() {
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register() {
$this->registerTranslations();
}
/**
* Register config.
*
* @return void
*/
protected function registerConfig() {
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('mmfrestrictedcustomers.php'),
], 'config');
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', 'mmfrestrictedcustomers'
);
}
/**
* Register views.
*
* @return void
*/
public function registerViews() {
$viewPath = resource_path('views/modules/mmfrestrictedcustomers');
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath
],'views');
$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/mmfrestrictedcustomers';
}, \Config::get('view.paths')), [$sourcePath]), 'mmfrestrictedcustomers');
}
/**
* Register translations.
*
* @return void
*/
public function registerTranslations() {
$this->loadJsonTranslationsFrom(__DIR__ .'/../Resources/lang');
}
/**
* Register an additional directory of factories.
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories() {
if (! app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/../Database/factories');
}
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides() {
return [];
}
}

View file

@ -19,7 +19,7 @@ You have been warned.
### Install the package with composer
```
composer require "millions-missing-france/freescout-restricted-customers" "0.6.1"
composer require "millions-missing-france/mmfrestrictedcustomers" "0.6.1"
```
### Edit the application routes
@ -44,11 +44,11 @@ should be replaced with:
```php
// Customers
Route::get('/customers/{id}/edit', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController@update')->name('customers.update');
Route::post('/customers/{id}/edit', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController@updateSave');
Route::get('/customers/{id}/', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController@conversations')->name('customers.conversations');
Route::get('/customers/ajax-search', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController@ajaxSearch', 'laroute' => true])->name('customers.ajax_search');
Route::post('/customers/ajax', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController@ajax', 'laroute' => true])->name('customers.ajax');
Route::get('/customers/{id}/edit', '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@update')->name('customers.update');
Route::post('/customers/{id}/edit', '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@updateSave');
Route::get('/customers/{id}/', '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@conversations')->name('customers.conversations');
Route::get('/customers/ajax-search', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@ajaxSearch', 'laroute' => true])->name('customers.ajax_search');
Route::post('/customers/ajax', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CustomersController@ajax', 'laroute' => true])->name('customers.ajax');
```
This other section should be edited too:
@ -78,7 +78,7 @@ Route::get('/mailbox/{mailbox_id}/new-ticket', 'ConversationsController@create')
Route::get('/mailbox/{mailbox_id}/clone-ticket/{from_thread_id}', 'ConversationsController@cloneConversation')->name('conversations.clone_conversation');
//Route::get('/conversation/draft/{id}', 'ConversationsController@draft')->name('conversations.draft');
Route::get('/conversation/ajax-html/{action}', ['uses' => 'ConversationsController@ajaxHtml', 'laroute' => true])->name('conversations.ajax_html');
Route::get('/search', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\ConversationsController@search')->name('conversations.search');
Route::get('/search', '\Modules\MMFRestrictedCustomers\Http\Controllers\ConversationsController@search')->name('conversations.search');
Route::get('/conversation/undo-reply/{thread_id}', 'ConversationsController@undoReply')->name('conversations.undo');
Route::get('/mailbox/{mailbox_id}/chats', 'ConversationsController@chats')->name('conversations.chats');
```
@ -107,19 +107,19 @@ Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['admin'], 'p
should be replaced with:
```php
Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['user', 'admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers'], function()
Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['user', 'admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => 'Modules\MMFRestrictedCustomers\Http\Controllers'], function()
{
Route::get('/customers/new', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@createCustomer')->name('freescout-restricted-customers.create_customer');
Route::post('/customers/new', '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@createCustomerSave');
Route::get('/crm/ajax-html/{action}/{param?}', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@ajaxHtml'])->name('crm.ajax_html');
Route::get('/customers/fields/ajax-search', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@ajaxSearch', 'laroute' => true])->name('crm.ajax_search');
Route::post('/crm/ajax', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@ajax', 'laroute' => true])->name('crm.ajax');
Route::get('/customers/new', '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@createCustomer')->name('mmfrestrictedcustomers.create_customer');
Route::post('/customers/new', '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@createCustomerSave');
Route::get('/crm/ajax-html/{action}/{param?}', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@ajaxHtml'])->name('crm.ajax_html');
Route::get('/customers/fields/ajax-search', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@ajaxSearch', 'laroute' => true])->name('crm.ajax_search');
Route::post('/crm/ajax', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@ajax', 'laroute' => true])->name('crm.ajax');
});
Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers'], function()
Route::group(['middleware' => ['web', 'auth', 'roles'], 'roles' => ['admin'], 'prefix' => \Helper::getSubdirectory(), 'namespace' => '\Modules\MMFRestrictedCustomers\Http\Controllers'], function()
{
Route::post('/customers/export', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@export'])->name('crm.export');
Route::post('/crm/ajax-admin', ['uses' => '\MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController@ajaxAdmin', 'laroute' => true])->name('crm.ajax_admin');
Route::post('/customers/export', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@export'])->name('crm.export');
Route::post('/crm/ajax-admin', ['uses' => '\Modules\MMFRestrictedCustomers\Http\Controllers\CrmController@ajaxAdmin', 'laroute' => true])->name('crm.ajax_admin');
});
```
@ -134,7 +134,7 @@ At line 173, this route call:
should be replaced with:
```php
$html = __('Customers').' <a href="#" data-trigger="modal" data-modal-title="'.__('Add Customer').'" data-modal-size="lg" data-modal-no-footer="true" data-modal-body=\'<iframe src="'.route('freescout-restricted-customers.create_customer', ['x_embed' => 1]).'" frameborder="0" class="modal-iframe"></iframe>\' class="btn btn-bordered btn-xs" style="position:relative;top:-1px;margin-left:4px;"><i class="glyphicon glyphicon-plus" title="'.__('Add Customer').'" data-toggle="tooltip"></i></a>';
$html = __('Customers').' <a href="#" data-trigger="modal" data-modal-title="'.__('Add Customer').'" data-modal-size="lg" data-modal-no-footer="true" data-modal-body=\'<iframe src="'.route('mmfrestrictedcustomers.create_customer', ['x_embed' => 1]).'" frameborder="0" class="modal-iframe"></iframe>\' class="btn btn-bordered btn-xs" style="position:relative;top:-1px;margin-left:4px;"><i class="glyphicon glyphicon-plus" title="'.__('Add Customer').'" data-toggle="tooltip"></i></a>';
```
### Edit the artisan commands
@ -151,8 +151,8 @@ At the lines 107-108, this:
should be replaced with:
```php
$fetch_command_identifier = \Helper::getWorkerIdentifier('freescout-restricted-customers:fetch-emails');
$fetch_command_name = 'freescout-restricted-customers:fetch-emails'
$fetch_command_identifier = \Helper::getWorkerIdentifier('mmfrestrictedcustomers:fetch-emails');
$fetch_command_name = 'mmfrestrictedcustomers:fetch-emails'
```
### Update the database schema

View file

@ -1,7 +1,7 @@
{
"name": "millions-missing-france/freescout-restricted-customers",
"description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes",
"version": "0.6.1",
"version": "0.7.0",
"type": "library",
"license": ["AGPL-3.0-only"],
"authors": [
@ -10,19 +10,19 @@
"email": "info@millionsmissing.fr"
}
],
"require": {
"laravel/framework": "v5.5.40"
},
"autoload": {
"psr-4": {
"MillionsMissingFrance\\FreescoutRestrictedCustomers\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"MillionsMissingFrance\\FreescoutRestrictedCustomers\\FreescoutRestrictedCustomersServiceProvider"
]
"Modules\\MMFRestrictedCustomers\\Providers\\MMFRestrictedCustomersServiceProvider"
],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\MMFRestrictedCustomers\\": ""
}
}
}

25
module.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "MMFRestrictedCustomers",
"alias": "mmfrestrictedcustomers",
"description": "Freescout restricted customers - Restrict access to Freescout customers to specific mailboxes",
"version": "0.7.0",
"detailsUrl": "",
"author": "Millions Missing FRANCE",
"authorUrl": "info@millionsmissing.fr",
"requiredAppVersion": "1.8.117",
"license": "AGPL-3.0-only",
"keywords": [],
"active": 0,
"order": 0,
"providers": [
"Modules\\MMFRestrictedCustomers\\Providers\\MMFRestrictedCustomersServiceProvider"
],
"aliases": {},
"files": [
"start.php"
],
"requires": [],
"requiredModules": {
"crm": "1.0.46"
}
}

View file

@ -1,36 +0,0 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
use Illuminate\Support\Facades\Route;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\ConversationsController;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CrmController;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Http\Controllers\CustomersController;
// FIXME: Routes are not correctly exposed to the main application,
// routes/web.php and Modules/Crm/Http/routes.php must be manually edited.
// Customers
Route::get('/customers/{id}/edit', CustomersController::class . '@update')->name('customers.update');
Route::post('/customers/{id}/edit', CustomersController::class . '@updateSave');
Route::get('/customers/{id}/', CustomersController::class . '@conversations')->name('customers.conversations');
Route::get('/customers/ajax-search', ['uses' => CustomersController::class . '@ajaxSearch', 'laroute' => true])->name('customers.ajax_search');
Route::post('/customers/ajax', ['uses' => CustomersController::class . '@ajax', 'laroute' => true])->name('customers.ajax');
// Conversations
Route::get('/search', ConversationsController::class . '@search')->name('conversations.search');
// Crm module
Route::group([ 'roles' => ['user', 'admin'] ], function() {
Route::get('/customers/new', CrmController::class . '@createCustomer')->name('freescout-restricted-customers.create_customer');
// The Crm module initialization will crash if no route named "crm.create_customer" is set.
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');
});
Route::group([ 'roles' => ['admin'] ], function() {
Route::post('/customers/export', ['uses' => CrmController::class . '@export'])->name('crm.export');
Route::post('/crm/ajax-admin', ['uses' => CrmController::class . '@ajaxAdmin', 'laroute' => true])->name('crm.ajax_admin');
});

View file

@ -1,38 +0,0 @@
<?php
/*
SPDX-License-Identifier: AGPL-3.0-only
SPDX-FileCopyrightText: © 2024 Millions Missing FRANCE <info@millionsmissing.fr>
*/
namespace MillionsMissingFrance\FreescoutRestrictedCustomers;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use MillionsMissingFrance\FreescoutRestrictedCustomers\Console\Commands\FetchEmails;
class FreescoutRestrictedCustomersServiceProvider extends ServiceProvider {
public function register() {
//
}
public function boot() {
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
$this->registerRoutes();
$this->loadViewsFrom(__DIR__.'/../resources/views', 'freescout-restricted-customers');
$this->commands([
FetchEmails::class,
]);
}
protected function registerRoutes() {
Route::group($this->routeConfiguration(), function () {
$this->loadRoutesFrom(__DIR__ . '/../routes/web.php');
});
}
protected function routeConfiguration() {
return [
'middleware' => ['web', 'auth', 'roles'],
];
}
}

17
start.php Normal file
View file

@ -0,0 +1,17 @@
<?php
/*
|--------------------------------------------------------------------------
| Register Namespaces And Routes
|--------------------------------------------------------------------------
|
| When a module starting, this file will executed automatically. This helps
| to register some namespaces like translator or view. Also this file
| will load the routes file for each module. You may also modify
| this file as you want.
|
*/
if (!app()->routesAreCached()) {
require __DIR__ . '/Http/routes.php';
}