I'm new to the DigitalOcean API and I'm trying to get something done. When a user completes a step program, a new droplet will be created in the code. Now I need the login credentials for this newly created droplet. These are automatically sent via Email. I need these so I can connect with the created droplet and perform commands on it. How can I achieve the above? I tried doing $droplet->user_data()
but unfortunately that does not work.
Code
public function store(Request $request, $id)
{
$order = Order::find($id);
$payment = Mollie::api()->payments()->get($order->mollie_transaction_id);
$mainsettings = Session::get('main_settings');
$webshop = $this->_webshopRepository->createWebshop();
$addressData = [$mainsettings['region'], $mainsettings['city'], $mainsettings['postal_code'], $mainsettings['street_name'], $mainsettings['house_number']];
$adres = $this->_addressRepository->createAddress($addressData);
$mainsettingData = [$adres->id, $webshop->id, $mainsettings['store_name'], $mainsettings['store_tel'], $mainsettings['store_hoo'], $mainsettings['vat_number']];
$mainsetting = $this->_mainsettingRepository->createMainSetting($mainsettingData);
$images = DigitalOcean::image()->getAll(['private' => true]);
$storeName = str_replace(' ', '-', $mainsetting['store_name']);
// Here is where I am creating the droplet
$droplet = DigitalOcean::droplet()->create($storeName, 'ams3', 's-1vcpu-1gb', $images[0]->id);
$droplet->user_data();
$commands = ["cd /home/", "rmdir test"];
\SSH::run($commands, function($line){
\Log::debug($line);
});
session()->forget('main_settings');
session()->forget('chosen_theme');
session()->forget('chosen_plugins');
return $this->show($order, $payment);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire