@@ 45-58 (lines=14) @@ | ||
42 | * |
|
43 | * @return bool |
|
44 | */ |
|
45 | public function create($auth_type, $user_id, $ip, $user_agent) |
|
46 | { |
|
47 | $this->cleanup($user_id); |
|
48 | ||
49 | return $this->db |
|
50 | ->table(self::TABLE) |
|
51 | ->insert([ |
|
52 | 'auth_type' => $auth_type, |
|
53 | 'user_id' => $user_id, |
|
54 | 'ip' => $ip, |
|
55 | 'user_agent' => substr($user_agent, 0, 255), |
|
56 | 'date_creation' => time(), |
|
57 | ]); |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Cleanup login history. |
@@ 47-61 (lines=15) @@ | ||
44 | * |
|
45 | * @return bool |
|
46 | */ |
|
47 | public function createEvent($project_id, $task_id, $creator_id, $event_name, array $data) |
|
48 | { |
|
49 | $values = [ |
|
50 | 'project_id' => $project_id, |
|
51 | 'task_id' => $task_id, |
|
52 | 'creator_id' => $creator_id, |
|
53 | 'event_name' => $event_name, |
|
54 | 'date_creation' => time(), |
|
55 | 'data' => json_encode($data), |
|
56 | ]; |
|
57 | ||
58 | $this->cleanup(self::MAX_EVENTS - 1); |
|
59 | ||
60 | return $this->db->table(self::TABLE)->insert($values); |
|
61 | } |
|
62 | ||
63 | /** |
|
64 | * Get query. |