I am using the following code to get User's IP info dynamically :
public function index(Request $request)
{
        $userIp = $request->ip();
        $locationData = \Location::get($userIp);
        
        return view('welcome',compact('locationData'));
}
And Code in my view page :
{{$locationData->countryName}}  
But this returning the error :
ErrorException Trying to get property 'countryName' of non-object (View: E:\laravel3\Currency\resources\views\welcome.blade.php)
It works nicely for static IP though . For following code it's returning "United States" :
public function index(Request $request)
{
        $userIp = '100.10.0.5';
        $locationData = \Location::get($userIp);
        
        return view('welcome',compact('locationData'));
}
 
     
    