| 1 | <?php |
||
| 8 | class Factory |
||
| 9 | { |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Logging Action |
||
| 13 | * |
||
| 14 | * @param \Sco\ActionLog\LogInfo $info |
||
| 15 | * |
||
| 16 | * @return bool |
||
| 17 | */ |
||
| 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 | |||
| 42 | |||
| 43 | public function __call($method, $parameters) |
||
| 47 | |||
| 48 | |||
| 49 | public static function __callStatic($method, $parameters) |
||
| 53 | } |
||
| 54 |