install
This commit is contained in:
35
app/Modules/BaseLocale/base-locale-helpers.php
Normal file
35
app/Modules/BaseLocale/base-locale-helpers.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
if (! function_exists('baseLocales')) {
|
||||
/**
|
||||
* Application locales
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
function baseLocales(): array
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
$locales = config()->array('module.base-locale.locales');
|
||||
|
||||
return $locales;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('safe_back')) {
|
||||
/**
|
||||
* Safe back
|
||||
*/
|
||||
function safe_back(string $fallback = '/'): RedirectResponse
|
||||
{
|
||||
$back = url()->previous();
|
||||
|
||||
// Allow only your own domain
|
||||
if (! str_starts_with($back, config()->string('app.url'))) {
|
||||
return redirect($fallback);
|
||||
}
|
||||
|
||||
return redirect()->to($back);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user