From 373b5c057949692ab7d411d742a092a6c830a40d Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski Date: Fri, 21 Aug 2026 11:15:24 +0200 Subject: [PATCH] refactor(platform): rewrite legacy-era regions of the mail request, template command, storage provider and routes in place --- .../CompanyMailConfigurationRequest.php | 4 ++-- app/Platform/Mail/routes/company.php | 10 +++++---- .../Pdf/Console/CreateTemplateCommand.php | 21 +++++++++---------- .../Storage/StorageServiceProvider.php | 15 ++++++------- app/Platform/Storage/routes/company.php | 9 +++++--- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/app/Platform/Mail/Http/Requests/CompanyMailConfigurationRequest.php b/app/Platform/Mail/Http/Requests/CompanyMailConfigurationRequest.php index 8bfe9003..5b582c36 100644 --- a/app/Platform/Mail/Http/Requests/CompanyMailConfigurationRequest.php +++ b/app/Platform/Mail/Http/Requests/CompanyMailConfigurationRequest.php @@ -9,7 +9,7 @@ use Illuminate\Validation\Rule; class CompanyMailConfigurationRequest extends FormRequest { /** - * Determine if the user is authorized to make this request. + * Authorization is enforced by the controller, so let the request past. */ public function authorize(): bool { @@ -17,7 +17,7 @@ class CompanyMailConfigurationRequest extends FormRequest } /** - * Get the validation rules that apply to the request. + * Rule set for the submitted payload, keyed off the custom-config toggle. */ public function rules(): array { diff --git a/app/Platform/Mail/routes/company.php b/app/Platform/Mail/routes/company.php index 652b9613..95469f85 100644 --- a/app/Platform/Mail/routes/company.php +++ b/app/Platform/Mail/routes/company.php @@ -4,10 +4,12 @@ use App\Platform\Mail\Http\Admin\MailConfigurationController; use App\Platform\Mail\Http\Company\CompanyMailConfigurationController; use Illuminate\Support\Facades\Route; -Route::get('/mail/drivers', [MailConfigurationController::class, 'getMailDrivers']); -Route::get('/mail/config', [MailConfigurationController::class, 'getMailEnvironment']); -Route::post('/mail/config', [MailConfigurationController::class, 'saveMailEnvironment']); -Route::post('/mail/test', [MailConfigurationController::class, 'testEmailConfig']); +Route::controller(MailConfigurationController::class)->group(function () { + Route::get('/mail/drivers', 'getMailDrivers'); + Route::get('/mail/config', 'getMailEnvironment'); + Route::post('/mail/config', 'saveMailEnvironment'); + Route::post('/mail/test', 'testEmailConfig'); +}); Route::get('/company/mail/config', [CompanyMailConfigurationController::class, 'getDefaultConfig']); Route::get('/company/mail/company-config', [CompanyMailConfigurationController::class, 'getMailConfig']); diff --git a/app/Platform/Pdf/Console/CreateTemplateCommand.php b/app/Platform/Pdf/Console/CreateTemplateCommand.php index 0a49f347..6dfb7922 100644 --- a/app/Platform/Pdf/Console/CreateTemplateCommand.php +++ b/app/Platform/Pdf/Console/CreateTemplateCommand.php @@ -8,6 +8,14 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; +/** + * Scaffolds a custom PDF template by cloning one of the designs the + * application ships, along with the partials and the repeating + * header/footer that come with it. + * + * Whether the name is yours to choose or has to match the document being + * replaced depends on the type; the two constants below spell that out. + */ class CreateTemplateCommand extends Command { /** @@ -37,22 +45,13 @@ class CreateTemplateCommand extends Command return array_merge(self::SELECTABLE_TYPES, array_keys(self::OVERRIDE_TYPES)); } - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'make:template {name} {--type=}'; - /** - * The console command description. - * - * @var string - */ protected $description = 'Create estimate or invoice pdf template.'; /** - * Execute the console command. + * Clone a shipped design into the custom-template area, where it can be + * edited without disturbing the one the application ships. */ public function handle(): int { diff --git a/app/Platform/Storage/StorageServiceProvider.php b/app/Platform/Storage/StorageServiceProvider.php index d53f5e39..153f9db9 100644 --- a/app/Platform/Storage/StorageServiceProvider.php +++ b/app/Platform/Storage/StorageServiceProvider.php @@ -12,14 +12,11 @@ use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Storage; use Illuminate\Support\ServiceProvider; use League\Flysystem\Filesystem; -use Spatie\Dropbox\Client as DropboxClient; +use Spatie\Dropbox\Client; use Spatie\FlysystemDropbox\DropboxAdapter; class StorageServiceProvider extends ServiceProvider { - /** - * Register services. - */ public function register(): void { $this->app->singleton(FileDiskService::class); @@ -41,16 +38,16 @@ class StorageServiceProvider extends ServiceProvider MigrateMediaToPrivateDisk::class, ]); - Storage::extend('dropbox', function ($app, $config) { - $client = new DropboxClient( - $config['token'] - ); + $dropboxDriver = function ($app, $config) { + $client = new Client($config['token']); $root = trim($config['root'] ?? '', '/'); $adapter = new DropboxAdapter($client, $root); $flysystem = new Filesystem($adapter); return new FilesystemAdapter($flysystem, $adapter, $config); - }); + }; + + Storage::extend('dropbox', $dropboxDriver); } } diff --git a/app/Platform/Storage/routes/company.php b/app/Platform/Storage/routes/company.php index 31498bfb..4dccac6f 100644 --- a/app/Platform/Storage/routes/company.php +++ b/app/Platform/Storage/routes/company.php @@ -4,11 +4,14 @@ use App\Platform\Storage\Http\BackupsController; use App\Platform\Storage\Http\DiskController; use Illuminate\Support\Facades\Route; -Route::apiResource('backups', BackupsController::class); -Route::apiResource('/disks', DiskController::class); +// Both registries take the API resource set, so no create/edit form routes are minted. +Route::apiResources([ + 'backups' => BackupsController::class, + 'disks' => DiskController::class, +]); Route::get('download-backup', [BackupsController::class, 'download']); -Route::get('/disk/drivers', [DiskController::class, 'getDiskDrivers']); +Route::get('disk/drivers', [DiskController::class, 'getDiskDrivers']); Route::get('/disk/purposes', [DiskController::class, 'getDiskPurposes']); Route::put('/disk/purposes', [DiskController::class, 'updateDiskPurposes']);