LogApiController.php 987B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: hanle
  5. * Date: 2018/10/19
  6. * Time: 12:43
  7. */
  8. namespace App\Http\Controllers;
  9. use App\Common\Curl;
  10. use App\Common\Api;
  11. use Illuminate\Http\Request;
  12. class LogApiController extends Controller
  13. {
  14. public function __construct(){}
  15. /**
  16. * 日志收集接口
  17. * @param Request $request
  18. * @return string
  19. */
  20. public function getLogCollect(Request $request){
  21. $params = $request->all();
  22. if(empty(env('APP_LOG_URL')) || !env('APP_LOG_URL')){
  23. return Api::json(config('code.success'), trans('msg.success'));
  24. }
  25. $url = env('APP_LOG_URL').'/log/collect?admin_id='.$params['admin_id'].'&event='.$params['event'];
  26. $curl = new Curl($url);
  27. $res = json_decode($curl->httpGet(), true);
  28. if($res) {
  29. return Api::json($res['error'], $res['message']);
  30. } else {
  31. return Api::json(config('code.fail'), trans('msg.fail'));
  32. }
  33. }
  34. }
  35. ?>