AdminLogsServer.php 726 B

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