i use library city , country ip.
so, when user register, add data request, insert in db.
$location = geoip::getlocation(config::get('constants.client_ip')); // simulating ip in mexico df if (!is_null($location)){ $country = countries::where("name", $location['country'])->first(); if (is_null($country)){ $country_id = config::get('constants.country_id_default'); }else{ $country_id = $country->id; } $request->request->add(['country_id' => $country_id ]); $request->request->add(['city' => $location['city'] ]); $request->request->add(['latitude' => $location['lat'] ]); $request->request->add(['longitude' => $location['lon'] ]); }else{ $request->request->add(['country_id' => config::get('constants.country_id_default') ]); $request->request->add(['city' => "paris" ]); $request->request->add(['latitude' => "48.858222" ]); $request->request->add(['longitude' => "2.2945" ]); }
thing must run in different places (authrequest, userrequest, etc) must authrequest , userrequest differs on validation, process not same.
admin can add user userrequests, authrequest register process.
what should best way add data when user
you can use eloquent events automatically run code when events fired. in case can use created
method.
this way define once process.
the docs eloquent model can found here.
if have lot of processes this, i'd advise create model observers classes can define automated processes.
Comments
Post a Comment