AdminLogsServer.php 688 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Servers\Logs;
  3. use App\Models\SysModels\AdminLog;
  4. use App\Servers\Common\CommonServer;
  5. class AdminLogsServer
  6. {
  7. /**
  8. * 后台日志记录
  9. * @param string $msg
  10. * @param string $u_id
  11. * @return mixed
  12. */
  13. static public function write($msg='',$u_id='')
  14. {
  15. $url = request()->url();
  16. $data=request()->all();
  17. $ip = CommonServer::creatServer()->getClientIp();
  18. return AdminLog::create(
  19. [
  20. 'u_id' => $u_id,
  21. 'url' => $url,
  22. 'msg' => $msg,
  23. 'ip' => $ip,
  24. 'data' => http_build_query($data),
  25. ]
  26. );
  27. }
  28. }