mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-14 17:25:01 +00:00
controller refactoring part 4
This commit is contained in:
+3
-2
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Users\Actions\CreateNewUserAction;
|
||||
use Domain\Homepage\Controllers\SendContactMessageController;
|
||||
use Domain\Sharing\Controllers\ShareController;
|
||||
use Domain\Items\Controllers\EditItemsController;
|
||||
use Domain\Trash\Controllers\DumpTrashController;
|
||||
@@ -22,7 +23,7 @@ use Domain\Browsing\Controllers\BrowseParticipantsUploadsController;
|
||||
|
||||
// Pages
|
||||
Route::get('/content', [AppFunctionsController::class, 'get_setting_columns']);
|
||||
Route::post('/contact', [AppFunctionsController::class, 'contact_form']);
|
||||
Route::post('/contact', SendContactMessageController::class);
|
||||
Route::get('/page/{page}', [AppFunctionsController::class, 'get_page']);
|
||||
Route::get('/pricing', [AppFunctionsController::class, 'get_storage_plans']);
|
||||
|
||||
@@ -70,7 +71,7 @@ Route::group(['middleware' => ['auth:sanctum']], function () {
|
||||
Route::post('/upload', [EditItemsController::class, 'upload']);
|
||||
Route::post('/move', [EditItemsController::class, 'move']);
|
||||
|
||||
Route::group(['prefix' => ''], function () {
|
||||
Route::group(['prefix' => '/zip'], function () {
|
||||
Route::post('/files', ZipFilesController::class);
|
||||
Route::get('/folder/{id}', ZipFolderController::class);
|
||||
});
|
||||
|
||||
+5
-2
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Domain\Admin\Controllers\InvoiceController;
|
||||
use Domain\Homepage\Controllers\IndexController;
|
||||
use Domain\Localization\Controllers\CurrentLocalizationController;
|
||||
use Domain\Sharing\Controllers\BrowseShareController;
|
||||
use Domain\Homepage\Controllers\AppFunctionsController;
|
||||
use Domain\SetupWizard\Controllers\SetupWizardController;
|
||||
@@ -9,7 +11,7 @@ use Domain\Subscriptions\Controllers\StripeWebhookController;
|
||||
Route::post('/stripe/webhook', [StripeWebhookController::class, 'handleWebhook']);
|
||||
Route::post('/admin-setup', [SetupWizardController::class, 'create_admin_account']);
|
||||
|
||||
Route::get('/translations/{lang}', [AppFunctionsController::class, 'get_translations']);
|
||||
Route::get('/translations/{lang}', CurrentLocalizationController::class);
|
||||
|
||||
// Get user invoice from stripe service
|
||||
Route::get('/invoice/{customer}/{token}', [InvoiceController::class, 'show'])->middleware(['auth:sanctum']);
|
||||
@@ -22,4 +24,5 @@ if (Crawler::isCrawler()) {
|
||||
}
|
||||
|
||||
// Show index.blade
|
||||
Route::get('/{any?}', [AppFunctionsController::class, 'index'])->where('any', '.*');
|
||||
Route::get('/{any?}', IndexController::class)
|
||||
->where('any', '.*');
|
||||
|
||||
@@ -37,35 +37,6 @@ class AppFunctionsController extends Controller
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show index page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
// Try to connect to database
|
||||
\DB::getPdo();
|
||||
|
||||
// Get setup status
|
||||
$setup_status = get_setup_status();
|
||||
|
||||
// Get app pages
|
||||
$pages = Page::all();
|
||||
|
||||
// Get all settings
|
||||
$settings = get_settings_in_json();
|
||||
} catch (PDOException $e) {
|
||||
$setup_status = 'setup-database';
|
||||
}
|
||||
|
||||
return view('index')
|
||||
->with('settings', $settings ?? null)
|
||||
->with('legal', $pages ?? null)
|
||||
->with('installation', $setup_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get og site for web crawlers
|
||||
*
|
||||
@@ -102,23 +73,6 @@ class AppFunctionsController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send contact message from pages
|
||||
*
|
||||
* @param SendContactMessageRequest $request
|
||||
* @return ResponseFactory|Response
|
||||
*/
|
||||
public function contact_form(SendContactMessageRequest $request)
|
||||
{
|
||||
Mail::to(
|
||||
get_setting('contact_email')
|
||||
)->send(
|
||||
new SendContactMessage($request->all())
|
||||
);
|
||||
|
||||
return response('Done', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single page content
|
||||
*
|
||||
@@ -179,25 +133,4 @@ class AppFunctionsController extends Controller
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language translations for frontend app
|
||||
*/
|
||||
public function get_translations($lang)
|
||||
{
|
||||
$translations = cache()
|
||||
->rememberForever("language-translations-$lang", function () use ($lang) {
|
||||
try {
|
||||
return Language::whereLocale($lang)
|
||||
->firstOrFail()
|
||||
->languageTranslations;
|
||||
} catch (QueryException | ModelNotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return $translations
|
||||
? map_language_translations($translations)
|
||||
: get_default_language_translations();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Homepage\Controllers;
|
||||
|
||||
|
||||
use Doctrine\DBAL\Driver\PDOException;
|
||||
use Domain\Pages\Models\Page;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class IndexController
|
||||
{
|
||||
/**
|
||||
* Show index page
|
||||
*/
|
||||
public function __invoke(): View
|
||||
{
|
||||
try {
|
||||
// Try to connect to database
|
||||
\DB::getPdo();
|
||||
|
||||
// Get setup status
|
||||
$setup_status = get_setup_status();
|
||||
|
||||
// Get app pages
|
||||
$pages = Page::all();
|
||||
|
||||
// Get all settings
|
||||
$settings = get_settings_in_json();
|
||||
} catch (PDOException $e) {
|
||||
$setup_status = 'setup-database';
|
||||
}
|
||||
|
||||
return view('index')
|
||||
->with('settings', $settings ?? null)
|
||||
->with('legal', $pages ?? null)
|
||||
->with('installation', $setup_status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Homepage\Controllers;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Homepage\Mail\SendContactMessage;
|
||||
use Domain\Homepage\Requests\SendContactMessageRequest;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendContactMessageController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send contact message from homepage
|
||||
*/
|
||||
public function __invoke(
|
||||
SendContactMessageRequest $request
|
||||
): Response {
|
||||
Mail::to(
|
||||
get_setting('contact_email')
|
||||
)->send(
|
||||
new SendContactMessage($request->all())
|
||||
);
|
||||
|
||||
return response('Done', 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Localization\Controllers;
|
||||
|
||||
|
||||
use Domain\Localization\Models\Language;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CurrentLocalizationController
|
||||
{
|
||||
/**
|
||||
* Get language translations for frontend app
|
||||
*/
|
||||
public function __invoke(
|
||||
string $lang
|
||||
): Collection {
|
||||
|
||||
$translations = cache()
|
||||
->rememberForever("language-translations-$lang", function () use ($lang) {
|
||||
try {
|
||||
return Language::whereLocale($lang)
|
||||
->firstOrFail()
|
||||
->languageTranslations;
|
||||
} catch (QueryException | ModelNotFoundException $e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
return $translations
|
||||
? map_language_translations($translations)
|
||||
: get_default_language_translations();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user