src/Http/Controllers/Controller.php
<?php
namespace DavideCasiraghi\LaravelColumns\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
// https://stackoverflow.com/questions/51611015/authuser-return-null-5-6
public function __construct()
{
$this->middleware(function ($request, $next) {
$this->user = Auth::user();
return $next($request);
});
}
// **********************************************************************
/**
* Get the language name from language code.
*
* @param string $languageCode
* @return string
*/
public function getSelectedLocaleName($languageCode)
{
$countriesAvailableForTranslations = LaravelLocalization::getSupportedLocales();
$ret = $countriesAvailableForTranslations[$languageCode]['name'];
return $ret;
}
}