| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 17 | public static function info(LogInfo $info) |
||
| 18 | { |
||
| 19 | $log = new ActionLogModel(); |
||
| 20 | |||
| 21 | if (!$info->getUserId() && !config('actionlog.guest')) { |
||
| 22 | return false; |
||
| 23 | } |
||
| 24 | |||
| 25 | $content = $info->getContent(); |
||
| 26 | $client = $info->getClient(); |
||
| 27 | |||
| 28 | $userKey = config('actionlog.user_foreign_key'); |
||
| 29 | |||
| 30 | $log->$userKey = $info->getUserId(); |
||
| 31 | $log->type = $info->getType(); |
||
| 32 | $log->content = is_string($content) ? $content : json_encode($content); |
||
| 33 | $log->client_ip = $info->getClientIp(); |
||
| 34 | $log->client = is_string($client) ? $client : json_encode($client); |
||
| 35 | $log->save(); |
||
| 36 | |||
| 37 | return true; |
||
| 38 | } |
||
| 39 | |||
| 52 |