36 lines
738 B
PHP
36 lines
738 B
PHP
<?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);
|
|
}
|
|
}
|