2021-07-30 18:38:43 +02:00
|
|
|
<?php
|
|
|
|
|
2021-09-07 13:37:18 +02:00
|
|
|
/** @noinspection UnusedFunctionResultInspection */
|
|
|
|
|
2021-12-07 16:35:14 +01:00
|
|
|
use App\Http\Controllers\AuthController;
|
2021-12-14 11:58:10 +01:00
|
|
|
use App\Http\Controllers\PasswordController;
|
2021-11-10 17:20:20 +01:00
|
|
|
use App\Http\Controllers\SetupController;
|
2021-07-30 18:38:43 +02:00
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Web Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
| Here is where you can register web routes for your application. These
|
|
|
|
| routes are loaded by the RouteServiceProvider within a group which
|
|
|
|
| contains the "web" middleware group. Now create something great!
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-12-07 16:35:14 +01:00
|
|
|
Route::get('/', static function () {
|
2021-11-16 17:00:44 +01:00
|
|
|
if (empty(DB::connection()->getDatabaseName())) {
|
2021-12-07 16:35:14 +01:00
|
|
|
return redirect()->route('setup');
|
2021-11-12 16:59:04 +01:00
|
|
|
}
|
|
|
|
|
2021-12-13 19:44:46 +01:00
|
|
|
if (auth()->hasUser()) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
|
2021-12-07 16:35:14 +01:00
|
|
|
return redirect()->route('auth.login');
|
|
|
|
});
|
|
|
|
|
2021-12-13 19:44:46 +01:00
|
|
|
Route::inertia('dashboard', 'Dashboard')
|
|
|
|
->middleware('auth')
|
|
|
|
->name('dashboard');
|
|
|
|
|
|
|
|
Route::name('auth.')
|
|
|
|
->middleware('guest')
|
|
|
|
->group(static function () {
|
|
|
|
Route::inertia('login', 'LoginPage')
|
2021-12-14 11:55:23 +01:00
|
|
|
->name('login');
|
2021-12-14 12:34:17 +01:00
|
|
|
|
2021-12-13 19:44:46 +01:00
|
|
|
Route::post('login', [AuthController::class, 'authenticate'])
|
2021-12-14 11:55:23 +01:00
|
|
|
->name('authenticate');
|
|
|
|
|
2021-12-14 12:34:17 +01:00
|
|
|
Route::post('logout', [AuthController::class, 'logout'])
|
|
|
|
->name('logout');
|
2021-12-13 19:44:46 +01:00
|
|
|
});
|
2021-08-03 19:43:16 +02:00
|
|
|
|
2021-12-14 11:55:23 +01:00
|
|
|
Route::name('password.')
|
|
|
|
->middleware('guest')
|
|
|
|
->group(static function () {
|
2021-12-14 11:58:10 +01:00
|
|
|
Route::post('forgot', [PasswordController::class, 'forgotPassword'])
|
2021-12-14 11:55:23 +01:00
|
|
|
->name('forgot');
|
|
|
|
|
|
|
|
Route::inertia('reset', 'ResetPasswordPage')
|
|
|
|
->name('reset');
|
|
|
|
|
2021-12-14 11:58:10 +01:00
|
|
|
Route::post('reset', [PasswordController::class, 'resetPassword'])
|
2021-12-14 11:55:23 +01:00
|
|
|
->name('resetPassword');
|
|
|
|
});
|
|
|
|
|
2021-12-07 19:26:59 +01:00
|
|
|
Route::name('setup.')->group(static function () {
|
|
|
|
Route::inertia('setup', 'SetupPage', [
|
|
|
|
'languages' => cache()->rememberForever('app.languages', fn () => array_map(
|
|
|
|
static fn ($file) => basename($file, '.json'),
|
|
|
|
glob(resource_path('lang').'/*.json', GLOB_NOSORT)
|
|
|
|
)),
|
|
|
|
'license' => cache()->rememberForever('app.license', fn () => file_get_contents(base_path('LICENSE'))),
|
|
|
|
]);
|
|
|
|
|
2021-12-09 19:45:06 +01:00
|
|
|
Route::inertia('setup/admin', 'AdminSetupPage')
|
|
|
|
->name('admin');
|
|
|
|
|
2021-12-07 19:26:59 +01:00
|
|
|
Route::options('setup/test', [SetupController::class, 'testDatabase'])
|
|
|
|
->name('test')
|
|
|
|
->withoutMiddleware('csrf');
|
|
|
|
|
|
|
|
Route::put('setup/save', [SetupController::class, 'save'])
|
|
|
|
->name('save');
|
2021-12-09 19:45:06 +01:00
|
|
|
|
|
|
|
Route::put('setup/admin', [SetupController::class, 'saveAdmin'])
|
|
|
|
->name('admin.save');
|
2021-12-07 19:26:59 +01:00
|
|
|
});
|
|
|
|
|
2021-12-07 16:35:14 +01:00
|
|
|
Route::get('lang/{language}', static function ($language) {
|
2021-08-03 19:17:43 +02:00
|
|
|
app()->setLocale($language);
|
|
|
|
|
|
|
|
return redirect()->back();
|
2021-11-10 18:41:25 +01:00
|
|
|
})->name('app.language');
|