Merge pull request #3 from sebathefox/Multi-language
v.0.5.8 - Multi language
This commit is contained in:
@@ -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", "showForgot", "forgot"]);
|
||||
|
||||
$this->middleware([ "check.auth:user.list" ])->only("index");
|
||||
$this->middleware([ "check.auth:user.show" ])->only("show");
|
||||
@@ -457,4 +459,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");
|
||||
|
||||
@@ -20,6 +20,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
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class SetLocale
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
app()->setLocale($request->user()->getLocale($request));
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user