SyncChetsJsonTool.php 938 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Module\GameItems\AdminControllers\Tools;
  3. use App\Module\Game\DCache\ChestJsonConfig;
  4. use App\Module\Game\DCache\ItemJsonConfig;
  5. use Dcat\Admin\Grid\Tools\AbstractTool;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Log;
  8. class SyncChetsJsonTool extends AbstractTool
  9. {
  10. protected $style = 'btn btn-danger waves-effect';
  11. public function title()
  12. {
  13. return '立即同步';
  14. }
  15. public function confirm()
  16. {
  17. return '确定要立即同步JSON数据吗?';
  18. }
  19. public function handle(Request $request)
  20. {
  21. try {
  22. $json =ChestJsonConfig::getData([],true);
  23. return $this->response()->success('同步成功')->refresh();
  24. } catch (\Exception $e) {
  25. Log::error('Sync items.json exception: '.$e->getMessage());
  26. return $this->response()->error('同步失败:'.$e->getMessage());
  27. }
  28. }
  29. }