1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace App\Servers;
- use App\Models\AdminLog;
- class AdminLogsServer
- {
- /**
- * 后台日志记录
- * @param string $msg
- * @return AdminLog|\Illuminate\Database\Eloquent\Model
- */
- static public function write($msg='')
- {
- $user = app('auth')->user();
- $m_id=empty($user->{'id'})?0:$user->{'id'};
- $url = request()->url();
- $data=request()->all();
- $ip=CommonServer::creatServer()->getClientIp();
- return AdminLog::create(
- [
- 'm_id' => $m_id,
- 'url' => $url,
- 'msg' => $msg,
- 'ip' => $ip,
- 'data' => http_build_query($data),
- ]
- );
- }
- }
|