PHP code example of divineomega / laravel-geolocation-request

1. Go to this page and download the library: Download divineomega/laravel-geolocation-request library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

divineomega / laravel-geolocation-request example snippets




namespace App\Http\Controllers;

//use Illuminate\Http\Request;
use DivineOmega\LaravelGeolocationRequest\Http\Requests\GeolocationRequest as Request;

class UserController extends Controller
{
    /**
     * Store a new user.
     *
     * @param  Request  $request
     * @return Response
     */
    public function store(Request $request)
    {
        // Perform geolocation, and return a country object.
        $country = $request->country();
        
        $user = new \App\User();
        $user->name = $request->name;
        $user->countryName = $country->name;
        $user->countryCode = $country->isoCodeAlpha3;
        
        $user->save();
        
        // ...
    }
}