dimanche 20 septembre 2015

Laravel 5 - get data from one table and insert into another table

I have this code in my Controller as I want to save UserParentInfo into UserInfo Table, I believe I am doing something wrong but can you please correct me with the reference so I can read the concept as well. thank in advance

$Ueserdata = UserInfo::where('ip_from',$iplive)->get();
if (!empty($data)) { 
$data = $Ueserdata;

UserInfo::where('ip_from',$iplive)->update(['last_visited' => $date]);
}
else{
$UserParentInfo = UserLocation::select('company_name', 'city_name', 'region_name', 'country_name', 'country_code_2','country_code_3', 'latitude', 'longitude' ,'time_zone')->where('ip_from',$iplive)->get();
$data = $UserParentInfo;
UserInfo::insert('ip_from', $iplive, $UserParentInfo );
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire