creation of a method for changing the language on the project pages q updating the first test page which was the Dashboard
This commit is contained in:
parent
9fa08d54a7
commit
58ea954d98
21
app/Http/Controllers/LanguageController.php
Normal file
21
app/Http/Controllers/LanguageController.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class LanguageController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
public function switchLanguage(Request $request)
|
||||||
|
{
|
||||||
|
$locale = $request->input('locale');
|
||||||
|
|
||||||
|
if (!in_array($locale, ['en', 'pt'])) {
|
||||||
|
abort(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
session(['locale' => $locale]);
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -36,6 +36,7 @@ class Kernel extends HttpKernel
|
||||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
\App\Http\Middleware\Language::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
|
|
|
||||||
25
app/Http/Middleware/Language.php
Normal file
25
app/Http/Middleware/Language.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class Language
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
// return $next($request);
|
||||||
|
if (session('locale')) {
|
||||||
|
app()->setLocale(session('locale'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -83,9 +83,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 'locale' => 'en',
|
'locale' => 'en',
|
||||||
'locale' => 'pt',
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
28
resources/lang/en/messages.php
Normal file
28
resources/lang/en/messages.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
|
||||||
|
'dashboard' => [
|
||||||
|
'planning' => [
|
||||||
|
'description' => 'In planning',
|
||||||
|
'text' => 'In planning for 2023'
|
||||||
|
],
|
||||||
|
'prepared' => [
|
||||||
|
'description' => 'Prepared',
|
||||||
|
'text' => 'Waiting for the work to start.'
|
||||||
|
],
|
||||||
|
'on_going' => [
|
||||||
|
'description' => 'On going',
|
||||||
|
'text' => 'Work in progress.'
|
||||||
|
],
|
||||||
|
'finished' => [
|
||||||
|
'description' => 'Finished.',
|
||||||
|
'text' => 'Last projects 2023.'
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
'welcome' => 'Welcome to our application!',
|
||||||
|
];
|
||||||
0
resources/lang/en/validation.php
Normal file
0
resources/lang/en/validation.php
Normal file
29
resources/lang/pt/messages.php
Normal file
29
resources/lang/pt/messages.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
'dashboard' => [
|
||||||
|
'planning' => [
|
||||||
|
'description' => 'Em planeamento',
|
||||||
|
'text' => 'Em planeamento de 2023'
|
||||||
|
],
|
||||||
|
'prepared' => [
|
||||||
|
'description' => 'Preparadas',
|
||||||
|
'text' => 'Aguarda o início da obra.'
|
||||||
|
],
|
||||||
|
'on_going' => [
|
||||||
|
'description' => 'Em execução',
|
||||||
|
'text' => 'Obra em curso.'
|
||||||
|
],
|
||||||
|
'finished' => [
|
||||||
|
'description' => 'Concluídas',
|
||||||
|
'text' => 'Últimas obras de 2023.'
|
||||||
|
],
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
|
'welcome' => 'Bem-vindo à nossa aplicação!',
|
||||||
|
// outras traduções
|
||||||
|
];
|
||||||
|
|
@ -32,11 +32,11 @@
|
||||||
<div class="card-header info-box bg-secondary">
|
<div class="card-header info-box bg-secondary">
|
||||||
<span class="info-box-icon"><i class="fas fa-file-edit"></i></span>
|
<span class="info-box-icon"><i class="fas fa-file-edit"></i></span>
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">Em planeamento</span>
|
<span class="info-box-text">{{__('messages.dashboard.planning.description')}}</span>
|
||||||
<span
|
<span
|
||||||
class="info-box-number">{{ $CompanyProject->where('order_project', 1)->count() }}</span>
|
class="info-box-number">{{ $CompanyProject->where('order_project', 1)->count() }}</span>
|
||||||
<span class="progress-description">
|
<span class="progress-description">
|
||||||
Em planeamento de 2023
|
{{__('messages.dashboard.planning.text')}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
<!-- /.info-box-content -->
|
||||||
|
|
@ -71,12 +71,13 @@ class="btn btn-tool">
|
||||||
<span class="info-box-icon"><i class="fas fa-file"></i></span>
|
<span class="info-box-icon"><i class="fas fa-file"></i></span>
|
||||||
|
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">Preparadas</span>
|
<span class="info-box-text">{{__('messages.dashboard.prepared.description')}}</span>
|
||||||
<span
|
<span
|
||||||
class="info-box-number">{{ $CompanyProject->where('order_project', 2)->count() }}</span>
|
class="info-box-number">{{ $CompanyProject->where('order_project', 2)->count() }}</span>
|
||||||
|
|
||||||
<span class="progress-description">
|
<span class="progress-description">
|
||||||
Aguardam o início da obra.
|
{{__('messages.dashboard.prepared.text')}}
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
<!-- /.info-box-content -->
|
||||||
|
|
@ -111,11 +112,11 @@ class="btn btn-tool">
|
||||||
<span class="info-box-icon"><i class="fas fa-file-alt"></i></span>
|
<span class="info-box-icon"><i class="fas fa-file-alt"></i></span>
|
||||||
|
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">Em execução</span>
|
<span class="info-box-text">{{__('messages.dashboard.on_going.description')}}</span>
|
||||||
<span
|
<span
|
||||||
class="info-box-number">{{ $CompanyProject->where('order_project', 3)->count() }}</span>
|
class="info-box-number">{{ $CompanyProject->where('order_project', 3)->count() }}</span>
|
||||||
<span class="progress-description">
|
<span class="progress-description">
|
||||||
Obras em curso.
|
{{__('messages.dashboard.on_going.text')}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
<!-- /.info-box-content -->
|
||||||
|
|
@ -150,11 +151,11 @@ class="btn btn-tool">
|
||||||
<span class="info-box-icon"><i class="fas fa-check-circle"></i></span>
|
<span class="info-box-icon"><i class="fas fa-check-circle"></i></span>
|
||||||
|
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">Concluídas</span>
|
<span class="info-box-text">{{__('messages.dashboard.finished.description')}}</span>
|
||||||
<span
|
<span
|
||||||
class="info-box-number">{{ $CompanyProject->where('order_project', 4)->count() }}</span>
|
class="info-box-number">{{ $CompanyProject->where('order_project', 4)->count() }}</span>
|
||||||
<span class="progress-description">
|
<span class="progress-description">
|
||||||
Últimas obras de 2023
|
{{__('messages.dashboard.finished.text')}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
<!-- /.info-box-content -->
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,14 @@ class="fas fa-bars"></i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<form id="language-form" action="{{ route('language.switch') }}" method="post">
|
||||||
|
@csrf
|
||||||
|
<select name="locale" onchange="this.form.submit()">
|
||||||
|
<option value="en" {{ app()->getLocale() == 'en' ? 'selected' : '' }}>English</option>
|
||||||
|
<option value="pt" {{ app()->getLocale() == 'pt' ? 'selected' : '' }}>Português</option>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
|
||||||
<!-- Right navbar links -->
|
<!-- Right navbar links -->
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@
|
||||||
<h3 class="card-title mb-0">Enviar Formulário:</h3>
|
<h3 class="card-title mb-0">Enviar Formulário:</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{{-- <h1>{{ __('messages.welcome') }}</h1> --}}
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{ route('enviar.formulario') }}" method="post">
|
<form action="{{ route('enviar.formulario') }}" method="post">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
@ -43,15 +47,15 @@
|
||||||
<i class="fa-sharp fa-solid fa-tag" style="color: #00B0EA;"></i>
|
<i class="fa-sharp fa-solid fa-tag" style="color: #00B0EA;"></i>
|
||||||
</span>
|
</span>
|
||||||
<div class="has-float-label">
|
<div class="has-float-label">
|
||||||
<input type="text" name="email" class="form-control card_inputs"
|
<input type="text" name="email" class="form-control card_inputs" id="email"
|
||||||
id="email" placeholder="Digite o email..." aria-label="Tag Equipment"
|
placeholder="Digite o email..." aria-label="Tag Equipment"
|
||||||
aria-describedby="form-tagEquipment">
|
aria-describedby="form-tagEquipment">
|
||||||
{{-- <label>Email </label> --}}
|
{{-- <label>Email </label> --}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-4 text-center">
|
<div class="col-sm-4 text-center">
|
||||||
<button type="submit" class="btn btn-light">Enviar</button>
|
<button type="submit" class="btn btn-light">Enviar</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -1221,7 +1221,8 @@ class="btn btn-info">Baixar Template</a>
|
||||||
{{-- ./table-responsive --}}
|
{{-- ./table-responsive --}}
|
||||||
|
|
||||||
@foreach ($listEquipmentsProjects as $listEquipmentsProject)
|
@foreach ($listEquipmentsProjects as $listEquipmentsProject)
|
||||||
<div class="modal fade" id="modal-showEquipment-{{ $listEquipmentsProject->equipment_id }}">
|
|
||||||
|
|
||||||
<div class="modal-dialog modal-xl">
|
<div class="modal-dialog modal-xl">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header bg-light">
|
<div class="modal-header bg-light">
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
use App\Http\Controllers\PreparedProjectController;
|
use App\Http\Controllers\PreparedProjectController;
|
||||||
use App\Http\Controllers\ExecutionProjectController;
|
use App\Http\Controllers\ExecutionProjectController;
|
||||||
use App\Http\Controllers\WorkstationsJobsController;
|
use App\Http\Controllers\WorkstationsJobsController;
|
||||||
|
use App\Http\Controllers\LanguageController;
|
||||||
|
|
||||||
|
|
||||||
// Esta rota so pode aceder quem tiver o link atravez do email
|
// Esta rota so pode aceder quem tiver o link atravez do email
|
||||||
|
|
@ -35,6 +36,10 @@
|
||||||
return view('email/FormAdmin');
|
return view('email/FormAdmin');
|
||||||
})->name('formulario');
|
})->name('formulario');
|
||||||
|
|
||||||
|
Route::post('language/switch', [LanguageController::class, 'switchLanguage'])->name('language.switch');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Email
|
// Email
|
||||||
Route::get('/your-verification-route/{id}/{hash}', [UserController::class, 'yourVerificationMethod'])
|
Route::get('/your-verification-route/{id}/{hash}', [UserController::class, 'yourVerificationMethod'])
|
||||||
->middleware(['auth', 'signed', 'throttle:6,1'])
|
->middleware(['auth', 'signed', 'throttle:6,1'])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user