From 44f3e7349e3dd73ac34afdf276e1928af913262e Mon Sep 17 00:00:00 2001 From: Gustavo Novaro Date: Mon, 2 Oct 2023 13:20:28 +0200 Subject: [PATCH] refactor(global): Routes file by module. Fixes - Login page with refresh - Fix image helper --- app/Helpers/ImageHelper.php | 2 +- resources/views/auth/login.blade.php | 2 +- routes/partials/calendar.php | 12 ++++++++ routes/partials/campaign.php | 8 +++++ routes/partials/email.php | 18 ++++++++++++ routes/partials/notification.php | 12 ++++++++ routes/partials/user.php | 9 ++++++ routes/web.php | 44 ++++------------------------ version.php | 2 +- 9 files changed, 67 insertions(+), 42 deletions(-) create mode 100644 routes/partials/calendar.php create mode 100644 routes/partials/campaign.php create mode 100644 routes/partials/email.php create mode 100644 routes/partials/notification.php create mode 100644 routes/partials/user.php diff --git a/app/Helpers/ImageHelper.php b/app/Helpers/ImageHelper.php index a6230894..cba3d0a9 100644 --- a/app/Helpers/ImageHelper.php +++ b/app/Helpers/ImageHelper.php @@ -8,6 +8,6 @@ class ImageHelper { public static function render(string $path): string { - return isset($path) ? 'data:image/png;base64,'.base64_encode(file_get_contents($path)) : ''; + return file_exists($path) ? 'data:image/png;base64,'.base64_encode(file_get_contents($path)) : ''; } } diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 039bed6a..ffd516ba 100755 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,4 +1,4 @@ -@extends('layouts.app') +@extends('layouts.basic') @section('content') diff --git a/routes/partials/calendar.php b/routes/partials/calendar.php new file mode 100644 index 00000000..60ca8e96 --- /dev/null +++ b/routes/partials/calendar.php @@ -0,0 +1,12 @@ +name('calendar.index'); +Route::post('/calendar/event/save', [\App\Http\Controllers\Calendar\SaveCalendarEventController::class, 'save']) + ->name('calendar.save'); +Route::get('/calendar/event/update/{id}', + [\App\Http\Controllers\Calendar\UpdateCalendarEventController::class, 'update'])->name('calendar.update'); +Route::delete('/calendar/event/delete/{id}', + [\App\Http\Controllers\Calendar\DeleteCalendarEventController::class, 'delete'])->name('calendar.delete'); diff --git a/routes/partials/campaign.php b/routes/partials/campaign.php new file mode 100644 index 00000000..6446e30b --- /dev/null +++ b/routes/partials/campaign.php @@ -0,0 +1,8 @@ +name('email.duplicate'); +Route::get('/email/download-attachment/{attachmentId}', + [\App\Http\Controllers\Email\EmailDownloadAttachmentController::class, 'downloadAttachment']) + ->name('downloadAttachment'); +Route::get('/email/tracking/{uuid}', [\App\Http\Controllers\Email\EmailTrackingController::class, 'track_email']); diff --git a/routes/partials/notification.php b/routes/partials/notification.php new file mode 100644 index 00000000..f114d07e --- /dev/null +++ b/routes/partials/notification.php @@ -0,0 +1,12 @@ +middleware('auth'); +Route::get('/notification/read/{id}', + [\App\Http\Controllers\Notification\SetNotificationReadAjaxController::class, 'setRead']) + ->middleware('auth'); +Route::get('/notification/delete/{id}', + [\App\Http\Controllers\Notification\DeleteNotificationController::class, 'delete']); diff --git a/routes/partials/user.php b/routes/partials/user.php new file mode 100644 index 00000000..3d57d359 --- /dev/null +++ b/routes/partials/user.php @@ -0,0 +1,9 @@ +name('calendar.index'); -Route::post('/calendar/event/save', [\App\Http\Controllers\Calendar\SaveCalendarEventController::class, 'save']) - ->name('calendar.save'); -Route::get('/calendar/event/update/{id}', - [\App\Http\Controllers\Calendar\UpdateCalendarEventController::class, 'update'])->name('calendar.update'); -Route::delete('/calendar/event/delete/{id}', - [\App\Http\Controllers\Calendar\DeleteCalendarEventController::class, 'delete'])->name('calendar.delete'); +require __DIR__.'/partials/calendar.php'; // Email -Route::match(['get', 'post'], '/email', [\App\Http\Controllers\Email\EmailIndexController::class, 'index']); -Route::get('/email/create', [\App\Http\Controllers\Email\EmailCreateController::class, 'create']); -Route::get('/email/view/{id}', [\App\Http\Controllers\Email\EmailViewController::class, 'view']); -Route::get('/email/update/{id}', [\App\Http\Controllers\Email\EmailUpdateController::class, 'update']); -Route::post('/email/save', [\App\Http\Controllers\Email\EmailSaveController::class, 'save']); -Route::get('/email/send/{id}', [\App\Http\Controllers\Email\EmailSendController::class, 'send']); -Route::get('/email/delete/{id}', [\App\Http\Controllers\Email\EmailDeleteController::class, 'delete']); -Route::match(['get', 'post'], '/email/duplicate', - [\App\Http\Controllers\Email\EmailDuplicateController::class, 'duplicate']) - ->name('email.duplicate'); -Route::get('/email/download-attachment/{attachmentId}', - [\App\Http\Controllers\Email\EmailDownloadAttachmentController::class, 'downloadAttachment']) - ->name('downloadAttachment'); -Route::get('/email/tracking/{uuid}', [\App\Http\Controllers\Email\EmailTrackingController::class, 'track_email']); +require __DIR__.'/partials/email.php'; // Email template Route::match(['get', 'post'], '/email-template', [\App\Http\Controllers\EmailTemplate\EmailTemplateIndexController::class, 'index']); // Campaign -Route::match(['get', 'post'], '/campaign', [\App\Http\Controllers\Campaign\CampaignIndexController::class, 'index']); -Route::get('/campaign/create', [\App\Http\Controllers\Campaign\CampaignCreateController::class, 'create']); -Route::get('/campaign/update/{id}', [\App\Http\Controllers\Campaign\CampaignUpdateController::class, 'update']); -Route::post('/campaign/save', [\App\Http\Controllers\Campaign\CampaignSaveController::class, 'save']); +require __DIR__.'/partials/campaign.php'; // Supplier require __DIR__.'/partials/supplier.php'; @@ -122,14 +95,7 @@ Route::get('/web-form', [\App\Http\Controllers\WebForm\WebFormIndexController::class, 'index']); // Notifications -Route::get('/notification', [\App\Http\Controllers\Notification\NotificationIndexController::class, 'index']); -Route::get('/ajax/notification', [\App\Http\Controllers\Notification\GetLatestAjaxController::class, 'getLatest']) - ->middleware('auth'); -Route::get('/notification/read/{id}', - [\App\Http\Controllers\Notification\SetNotificationReadAjaxController::class, 'setRead']) - ->middleware('auth'); -Route::get('/notification/delete/{id}', - [\App\Http\Controllers\Notification\DeleteNotificationController::class, 'delete']); +require __DIR__.'/partials/notification.php'; // Unsubscribe Route::get('/unsubscribe', [\App\Http\Controllers\Unsubscribe\UnsubscribeUpdateController::class, 'update']); diff --git a/version.php b/version.php index 41bc76cc..c9c41d56 100644 --- a/version.php +++ b/version.php @@ -1,3 +1,3 @@