<?php

namespace App\Modules\BaseLocale\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;

class BaseLocaleController extends Controller
{
    /**
     * Invoke the controller
     */
    public function index(string $locale): RedirectResponse
    {
        if (array_key_exists($locale, baseLocales())) {
            session()->put('locale', $locale);
        }

        return safe_back();
    }
}
