Guest User

Untitled

a guest
Oct 18th, 2019
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $url = "https://api.vkdonate.ru?key={$key}&action=donates&count=15";
  2. $json = file_get_contents($url);
  3.  
  4. $result = json_decode($json, true);
  5.  
  6. if ($result['success'] && $result['count'] > 0) {
  7. foreach ($result['donates'] as $key => $donate) {
  8. if (Pay::where('pay_id', $donate['id'])->exists()) {
  9. continue;
  10. } else {
  11. Pay::create([
  12. 'pay_id' => $donate['id'],
  13. 'vk_id' => $donate['uid'],
  14. 'sum' => $donate['sum'],
  15. 'date' => $donate['date'],
  16. 'anon' => $donate['anon']
  17. ]);
  18. if (Player::where('vk_id', $donate['uid'])->exists()) {
  19. $player = Player::where('vk_id', $donate['uid'])->first();
  20. $add_count = intdiv($donate['sum'], 10);
  21. $player->count += $add_count;
  22. $player->save();
  23. }
  24. }
  25. }
  26. }
RAW Paste Data