public static function setFromURL(Request $request)
    {
        if(!\Request::route('lang')) {
            // language may be present in url without {param} defined
            $detectLanguageFromRequest = \App\Models\Language::detectLanguageFromRequest($request);
            if ($detectLanguageFromRequest) {
                $request->route()->setParameter('lang', $detectLanguageFromRequest);
                return $detectLanguageFromRequest;
            }
        }
        return null;
    }
public static function setFromURL(Request $request)
    {
        if(!\Request::route('lang')) {
            // language may be present in url without {param} defined
            $detectLanguageFromRequest = \App\Models\Language::detectLanguageFromRequest($request);
            if ($detectLanguageFromRequest) {
                $request->route()->setParameter('lang', $detectLanguageFromRequest);
                return $detectLanguageFromRequest;
            }
        }
        return null;
    }
public static function setFromURL ( Request $ request ) { if ( ! \ Request :: route ( 'lang' ) ) { // language may be present in url without {param} defined $ detectLanguageFromRequest = \ App \ Models \ Language :: detectLanguageFromRequest ( $ request ) ; if ( $ detectLanguageFromRequest ) { $ request -> route ( ) -> setParameter ( 'lang' , $ detectLanguageFromRequest ) ; return $ detectLanguageFromRequest ; } } return null ; }
Detect language form url and set it as route parameter.

@param  \Illuminate\Http\Request $request
@return string|null
Detect language form url and set it as route parameter .