v0.5.7 - Made multi language option
This commit is contained in:
parent
358e47b703
commit
7cc871ae90
|
@ -13,6 +13,7 @@ class ContactController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:contact.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:contact.show" ])->only("show");
|
||||
|
|
|
@ -15,6 +15,7 @@ class EventController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:event.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:event.show" ])->only("show");
|
||||
|
|
|
@ -13,6 +13,7 @@ class FeedbackController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:feedback.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:feedback.show" ])->only("show");
|
||||
|
|
|
@ -13,6 +13,7 @@ class GuideController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:guides.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:guides.show" ])->only("show");
|
||||
|
|
|
@ -11,6 +11,7 @@ class LocationController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:locations.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:locations.show" ])->only("show");
|
||||
|
|
|
@ -17,6 +17,7 @@ class MenuPlanController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:menuplan.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:menuplan.show" ])->only("show");
|
||||
|
|
|
@ -8,6 +8,12 @@ use Spatie\Permission\Models\Permission;
|
|||
|
||||
class PermissionController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(["auth"]);
|
||||
$this->middleware(["lang"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,12 @@ use Illuminate\Http\Response;
|
|||
|
||||
class PhoneController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(["auth"]);
|
||||
$this->middleware(["lang"]);
|
||||
}
|
||||
|
||||
function index() {
|
||||
return Response::detect("vagttelefons.index");
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ class ResourceCategoryController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.category.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.category.show" ])->only("show");
|
||||
|
|
|
@ -12,6 +12,7 @@ class ResourceController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.show" ])->only("show");
|
||||
|
|
|
@ -11,6 +11,7 @@ class ResourceExtensionController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:resource.extension.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:resource.extension.show" ])->only("show");
|
||||
|
|
|
@ -12,6 +12,7 @@ class rolesController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:roles.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:roles.show" ])->only("show");
|
||||
|
|
|
@ -10,6 +10,7 @@ class RootController extends Controller
|
|||
function __construct()
|
||||
{
|
||||
$this->middleware("auth");
|
||||
$this->middleware([ "lang" ]);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Helpers\Detector;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
@ -20,6 +21,7 @@ class UserController extends Controller
|
|||
{
|
||||
$this->middleware([ "auth" ])->only("logout");
|
||||
$this->middleware([ "guest" ])->only("login");
|
||||
$this->middleware([ "lang" ])->except(["login", "showLogin"]);
|
||||
|
||||
$this->middleware([ "check.auth:user.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:user.show" ])->only("show");
|
||||
|
@ -462,4 +464,23 @@ class UserController extends Controller
|
|||
return Response($output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setLanguages(Request $request){
|
||||
if($request->ajax()){
|
||||
if($request->lang === "en"){
|
||||
$response = new Response('Set Cookie');
|
||||
$response->withCookie(cookie('languagesSetting', $request->lang, 5259488));
|
||||
|
||||
return $response;
|
||||
}elseif($request->lang === "dk"){
|
||||
$response = new Response('Set Cookie');
|
||||
$response->withCookie(cookie('languagesSetting', $request->lang, 5259488));
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,11 @@ use Illuminate\Http\Response;
|
|||
|
||||
class UserEventController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware(["auth"]);
|
||||
$this->middleware(["lang"]);
|
||||
}
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
|
|
|
@ -17,6 +17,7 @@ class WashingMachineController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:washing.machine.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:washing.machine.show" ])->only("show");
|
||||
|
|
|
@ -19,6 +19,7 @@ class WashingReservationController extends Controller
|
|||
public function __construct()
|
||||
{
|
||||
$this->middleware([ "auth" ]);
|
||||
$this->middleware([ "lang" ]);
|
||||
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.list" ])->only(["index", "appindex"]);
|
||||
$this->middleware([ "check.auth:washing.machine.reservation.show" ])->only("show");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\SetLocale;
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
|
@ -67,7 +68,7 @@ class Kernel extends HttpKernel
|
|||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
|
||||
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
|
||||
|
||||
'lang' => \App\Http\Middleware\SetLocale::class,
|
||||
"check.auth" => \App\Http\Middleware\CheckAuth::class
|
||||
];
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
namespace App;
|
||||
|
||||
//allows the use of many libraries.
|
||||
use http\Env\Request;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
@ -52,4 +53,8 @@ class User extends Authenticatable
|
|||
public function setPasswordAttribute($password) {
|
||||
$this->attributes["password"] = Hash::make($password);
|
||||
}
|
||||
|
||||
public function getLocale(\Illuminate\Http\Request $request) {
|
||||
return $request->cookie('languagesSetting');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
'locale' => 'dk',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -93,7 +93,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'en',
|
||||
'fallback_locale' => 'dk',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
@section("content")
|
||||
<main>
|
||||
<h1 class="text-center sde-blue mb-0">Aktiviteter</h1>
|
||||
<h1 class="text-center sde-blue mb-0">{{ __('msg.aktiviteter') }}</h1>
|
||||
@if(!$events->isEmpty())
|
||||
@foreach($events as $event)
|
||||
<form method="get" action="{{ route("userevents.create") }}">
|
||||
|
@ -19,8 +19,8 @@
|
|||
</form>
|
||||
@endforeach
|
||||
@else
|
||||
<p class="text-center">Der er ingen aktiviteter!</p>
|
||||
<p class="text-center">{{__('msg.dereringenaktiviteter')}}!</p>
|
||||
@endif
|
||||
<a href="{{ route("userevents.index") }}" type="submit" class="mt-2 btn text-center btn-sde-blue" id="tilmeld">Se Tilmeldte Aktiviteter</a>
|
||||
<a href="{{ route("userevents.index") }}" type="submit" class="mt-2 btn text-center btn-sde-blue" id="tilmeld">{{__('msg.setilmeldteaktiviteter')}}</a>
|
||||
</main>
|
||||
@endsection
|
||||
|
|
|
@ -20,15 +20,15 @@
|
|||
|
||||
<a href="{{ route("menu-plans.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/Menuplan.svg')}}" alt="Menuplan">
|
||||
Menuplan
|
||||
{{ __('msg.menuplan') }}
|
||||
</a>
|
||||
<a href="{{ route("events.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/Aktiviteter.svg')}}" alt="Aktiviteter">
|
||||
Aktiviteter
|
||||
{{ __('msg.aktiviteter') }}
|
||||
</a>
|
||||
<a href="{{ route("washing-reservations.appindex") }}">
|
||||
<img src="{{URL::asset('/images/icons/Vaske booking liste.svg')}}" alt="Reservationer">
|
||||
Reservationer
|
||||
{{ __('msg.reservationer') }}
|
||||
</a>
|
||||
{{-- MÅ IKKE SLETTES!!!! --}}
|
||||
{{-- <a href="# ">--}}
|
||||
|
@ -37,23 +37,23 @@
|
|||
{{-- </a>--}}
|
||||
<a href="{{ route("contacts.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/Kontoret.svg')}}" alt="Kontoret">
|
||||
Kontoret
|
||||
{{ __('msg.kontoret') }}
|
||||
</a>
|
||||
<a href="{{ route("phones.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/Vagttelefon-hvid.svg')}}" alt="Vagttelefon">
|
||||
Vagttelefon
|
||||
{{ __('msg.vagttelefon') }}
|
||||
</a>
|
||||
<a href="{{ route("guides.index") }}">
|
||||
<img src="{{URL::asset('/images/icons/Vejledninger.svg')}}" alt="Guide">
|
||||
Vejledninger
|
||||
{{ __('msg.vejledning') }}
|
||||
</a>
|
||||
<a href="{{ route("users.account") }}">
|
||||
<img src="{{URL::asset('/images/icons/user-hvid.svg')}}" alt="Konto">
|
||||
Konto
|
||||
{{ __('msg.konto') }}
|
||||
</a>
|
||||
<a href="{{ route('users.logout') }}">
|
||||
<img src="{{URL::asset('/images/icons/Logout.svg')}}" alt="Logud">
|
||||
Log Ud
|
||||
{{ __('msg.logud') }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -11,31 +11,31 @@
|
|||
@if($menuPlans->contains('week', $Week)) {{-- If any of the menues in the menu table has the number of the week in the 'week' column, do this --}}
|
||||
@foreach($menuPlans as $menuplan)
|
||||
@if($menuplan->week == $Week)
|
||||
<h1 class="text-center sde-blue mb-0">Menuplan</h1>
|
||||
<span class="text-center sde-black-80 bold">Uge: {{$menuplan->week}}</span>
|
||||
<h1 class="text-center sde-blue mb-0">{{ __('msg.menuplan') }}</h1>
|
||||
<span class="text-center sde-black-80 bold">{{ __('msg.uge') }}: {{$menuplan->week}}</span>
|
||||
<div class="col w-100 mt-auto text-center">
|
||||
<div class="w-100" id="mandag">
|
||||
<h3 class="sde-blue bold mb-0">Mandag</h3>
|
||||
<h3 class="sde-blue bold mb-0">{{ __('msg.mandag') }}</h3>
|
||||
<p>{{$menuplan->monday}}</p>
|
||||
</div>
|
||||
<div class="w-100" id="tirsdag">
|
||||
<h3 class="sde-blue bold mb-0">Tirsdag</h3>
|
||||
<h3 class="sde-blue bold mb-0">{{ __('msg.tirsdag') }}</h3>
|
||||
<p>{{$menuplan->tuesday}}</p>
|
||||
</div>
|
||||
<div class="w-100" id="onsdag">
|
||||
<h3 class="sde-blue bold mb-0">Onsdag</h3>
|
||||
<h3 class="sde-blue bold mb-0">{{ __('msg.onsdag') }}</h3>
|
||||
<p>{{$menuplan->wednesday}}</p>
|
||||
</div>
|
||||
<div class="w-100" id="torsdag">
|
||||
<h3 class="sde-blue bold mb-0">Torsdag</h3>
|
||||
<h3 class="sde-blue bold mb-0">{{ __('msg.torsdag') }}</h3>
|
||||
<p>{{$menuplan->thursday}}</p>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
@else
|
||||
<h1 class="text-center sde-blue mb-0">Menuplan</h1>
|
||||
<p class="text-center">Der er ingen menuplaner denne uge!</p>
|
||||
<h1 class="text-center sde-blue mb-0">{{ __('msg.menuplan') }}</h1>
|
||||
<p class="text-center">{{__('msg.dereringenmenuplanerdenneuge')}}!</p>
|
||||
@endif
|
||||
</main>
|
||||
{{ $menuPlans->links() }}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
@endsection
|
||||
|
||||
@section("content")
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<main>
|
||||
<h1 class="text-center sde-blue mt-0">Konto</h1>
|
||||
<h4 class="mt-0">Navn: {{ Auth::user()->name_first . " " . Auth::user()->name_last }}</h4>
|
||||
|
@ -13,5 +14,43 @@
|
|||
{!! session()->get('success#credentialschanged') !!}
|
||||
<a class="btn text-center btn-sde-blue mt-1" href="{{ route("users.accountedit") }}">Rediger Oplysninger</a>
|
||||
<a class="btn text-center btn-sde-blue mt-1" href="{{ route("users.accounteditpass") }}">Ændre Password</a>
|
||||
|
||||
<label for="langu">Sprog / Languages:</label>
|
||||
<select name="langName" id="lang">
|
||||
@if(request()->cookie('languagesSetting') == "dk")
|
||||
<option selected name="langDK" value="dk">Dansk</option>
|
||||
@else
|
||||
<option name="langDK" value="dk">Dansk</option>
|
||||
@endif
|
||||
@if(request()->cookie('languagesSetting') == "en")
|
||||
<option selected name="langEN" value="en">English</option>
|
||||
@else
|
||||
<option name="langEN" value="en">English</option>
|
||||
@endif
|
||||
|
||||
</select>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
$(document).ready(function (){
|
||||
$('#lang').change(function () {
|
||||
$value = $('#lang').find(":selected").val();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '{{route('users.setLanguages')}}',
|
||||
data: {'lang':$value},
|
||||
success:function (data) {
|
||||
console.log($value);
|
||||
location.reload();
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@endsection
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
@section('content')
|
||||
<main id="main" style="justify-content: space-between;">
|
||||
<div class="d-flex col block-container mt-2">
|
||||
<a href="{{ route('menu-plans.index') }}" class="block text-center mb-1">Menuplan</a>
|
||||
<a href="{{ route('events.index') }}" class="block text-center mb-1">Aktiviteter</a>
|
||||
<a href="{{ route('washing-reservations.appindex') }}" class="block text-center mb-1">Reservationer</a>
|
||||
<a href="{{ route('contacts.index') }}" class="block text-center mb-1">Kontoret</a>
|
||||
<a href="{{ route('phones.index') }}" class="block text-center mb-1">Vagttelefon</a>
|
||||
<a href="{{ route('guides.index') }}" class="block text-center mb-1">Vejledninger</a>
|
||||
<a href="{{ route('menu-plans.index') }}" class="block text-center mb-1">{{ __('msg.menuplan') }}</a>
|
||||
<a href="{{ route('events.index') }}" class="block text-center mb-1">{{ __('msg.aktiviteter') }}</a>
|
||||
<a href="{{ route('washing-reservations.appindex') }}" class="block text-center mb-1">{{ __('msg.reservationer') }}</a>
|
||||
<a href="{{ route('contacts.index') }}" class="block text-center mb-1">{{ __('msg.kontoret') }}</a>
|
||||
<a href="{{ route('phones.index') }}" class="block text-center mb-1">{{ __('msg.vagttelefon') }}</a>
|
||||
<a href="{{ route('guides.index') }}" class="block text-center mb-1">{{ __('msg.vejledning') }}</a>
|
||||
</div>
|
||||
<div class="row" style="align-self: center; margin: 8px 0 8px 0;">
|
||||
<a href="https://www.facebook.com" target="_blank" class="link">
|
||||
|
|
|
@ -39,6 +39,8 @@ Route::get("/userapi", "UserController@search")->name("users.search");
|
|||
Route::get("/vaskeapi", "WashingReservationController@search")->name("washing-reservations.search");
|
||||
Route::get("/risrosapi", "FeedbackController@search")->name("feedbacks.search");
|
||||
|
||||
//languages
|
||||
Route::get("/languages", "UserController@setLanguages")->name("users.setLanguages");
|
||||
|
||||
|
||||
Route::resource("contacts", "ContactController");
|
||||
|
|
Loading…
Reference in New Issue