Non static method 'get' should not be called statically
obink opened this issue · comments
- Laravel 7
- PHP 7.3.12
- finished setting up the config and also I put an aliases 'Location' => 'Stevebauman\Location\Facades\Location',
- published vendor
in my controller
use Stevebauman\Location\Location;
public function show($product)
{
$product = Product::find($product);
views($product)->record();
$images = $product->images;
$whoIsIp = request()->ip();
$position = Location::get($whoIsIp);
dd($position);
$dbLatestView = DB::table('views')->orderBy('id', 'DESC')->where('viewable_id', $product->id)->limit(1);
$dbLatestView->update(['ip_address'=>$whoIsIp] );
return view('product', compact('product', 'images'));
}
and I'm getting this kind of error
ErrorException
Non-static method Stevebauman\Location\Location::get() should not be called statically
http://127.0.0.1:8000/catalogue/2
don't import it with
use Stevebauman\Location\Location;
comment out this line and run your code again, its sort of declared globally
Hi there!
You must use the facade:
use Stevebauman\Location\Facades\Location;
Not:
use Stevebauman\Location\Location;
Hope this helps!
the mistake I made was, I used a static local IP. And it works now with facades, sorry for the late reply. thanks.