I am trying to get site visitors ip address & want to store that in table. This is my code to store data
public function store(Request $request)
{
$secretcode=str_random(10);
while(1)
{
$txnid=substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$txnstatus=Ticket::where('transactionid',$txnid)->get();
if($txnstatus->isEmpty())
break;
}
$request['ipaddress']=$request->ip();
$request['transactionid']=$txnid;
$request['secretcode']=$secretcode;
$input=$request->all();
Ticket::create($input);
return view('payment');
}
I am using this line to get ip address
$request['ipaddress']=$request->ip();
When this code inserts data into database table, it shows like this
Someone please help me to get this work done. I also used Request::ip() but even that didn't work.
Important is that I am working in localhost environment with active internet connection.