new ExtJsonDecoder(true)] ); // First we need to fill user_addresses table with json data, then find user id matching addressable_id and fill user options with {"address": "$data"} foreach ($items as $data) { try { DB::table($table)->insert([ 'id' => $data['id'], 'user_id' => $data['addressable_id'], 'street_address' => $data['address'], 'title' => $data['title'], 'building' => $data['building'], 'floor' => $data['floor'], 'door' => $data['door'], 'location' => $data['location'], 'type' => $data['type'], 'created_at' => $data['created_at'], 'updated_at' => $data['updated_at'], 'is_default' => false, ]); } catch (Exception $e) { continue; } $user = User::where('id', $data['addressable_id'])->first(); if ($user) { info($user); $user->options->set('address', $data['address']); $user->save(); } } }); } }