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