ApiTrait.php 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CatchAdmin [Just Like ~ ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
  8. // +----------------------------------------------------------------------
  9. // | Author: JaguarJack [ njphper@gmail.com ]
  10. // +----------------------------------------------------------------------
  11. namespace catchAdmin\domain\support\driver;
  12. use catcher\facade\Http;
  13. use catchAdmin\domain\support\CommonParams;
  14. trait ApiTrait
  15. {
  16. public function get(array $params)
  17. {
  18. $name = config('catch.domains.default');
  19. $apiDomain = config('catch.domains.' . $name . '.api_domain');
  20. if (strpos($apiDomain, 'https') === false &&
  21. strpos($apiDomain, 'http') === false) {
  22. $apiDomain = 'https://' . $apiDomain . '/v2/index.php';
  23. }
  24. return Http::ignoreSsl()->query(CommonParams::{$name}($params))
  25. ->get($apiDomain)->json();
  26. }
  27. }