- Add Task model with subtasks, priorities, status transitions, dates, hours - Add Comment polymorphic model for tasks/issues/projects - Livewire components: TaskManager (list+filters), TaskForm (modal), TaskDetail, TaskKanban (drag&drop), TaskCalendar (FullCalendar) - TaskPolicy with permissions (view/create/edit/delete/assign/manage all) - Notifications: assigned, status change, overdue, comment added - Daily overdue notification job scheduled - Dashboard widget unifies IssueTask + Task - i18n: en/es/fr/ru (393 keys each) - Routes, navigation, offline sync support - 101 tests passing, Pint compliant on new files
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Common;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class LanguageSwitcher extends Component
|
|
{
|
|
public string $currentLocale;
|
|
|
|
/** Idiomas disponibles con nombre y bandera. */
|
|
public array $languages = [
|
|
'en' => ['name' => 'English', 'flag' => 'gb.svg'],
|
|
'es' => ['name' => 'Español', 'flag' => 'es.svg'],
|
|
'fr' => ['name' => 'Français', 'flag' => 'fr.svg'],
|
|
'ru' => ['name' => 'Русский', 'flag' => 'ru.svg'],
|
|
];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->currentLocale = App::getLocale();
|
|
}
|
|
|
|
public function updatedCurrentLocale(string $locale): void
|
|
{
|
|
if (!in_array($locale, ['en', 'es', 'fr', 'ru'])) {
|
|
return;
|
|
}
|
|
|
|
Session::put('locale', $locale);
|
|
|
|
if (Auth::check()) {
|
|
$user = Auth::user();
|
|
$user->locale = $locale;
|
|
$user->save();
|
|
}
|
|
|
|
// Dispatch a browser event — JavaScript reloads the page.
|
|
$this->dispatch('locale-changed');
|
|
}
|
|
|
|
public function switchLanguage(string $locale): void
|
|
{
|
|
$this->updatedCurrentLocale($locale);
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.common.language-switcher');
|
|
}
|
|
} |