I need to save the data in a table if they do not already exist or update them if they exist. I have this code so far that you only create them in the table, the table is called Coin.php
$client = new Client([
'base_uri' => 'https://api.coinmarketcap.com/v1/',
'timeout' => 2.0,
]);
$response = $client->request('GET', 'ticker');
$coins = json_decode($response->getBody()->getContents());
foreach ($coins as $res) {
$datos = new Coin;
$datos->name = $res->name;
$datos->symbol = $res->symbol;
$datos->rank = $res->rank;
$datos->save();
}
This method is a command that runs every 5 minutes and has to check whether or not they exist in the table to be able to do the operations I mentioned above.
I'm occupying Laravel 5.6 Any ideas?