mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
added loging
This commit is contained in:
@@ -34,9 +34,6 @@ class ActivityLogModel extends Model
|
||||
// Log an activity
|
||||
public function logActivity($data)
|
||||
{
|
||||
// Disable events to prevent any recursive logging
|
||||
$this->skipEvents();
|
||||
|
||||
if (!isset($data['id'])) {
|
||||
$data['id'] = $this->generateUuid();
|
||||
}
|
||||
@@ -44,12 +41,9 @@ class ActivityLogModel extends Model
|
||||
$data['created_at'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$result = $this->insert($data);
|
||||
|
||||
// Re-enable events
|
||||
$this->skipEvents(false);
|
||||
|
||||
return $result;
|
||||
// Use builder directly to avoid triggering events
|
||||
$builder = $this->db->table($this->table);
|
||||
return $builder->insert($data);
|
||||
}
|
||||
|
||||
// Get logs by user
|
||||
|
||||
@@ -6,8 +6,6 @@ use CodeIgniter\Model;
|
||||
|
||||
class CategoryModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
protected $table = 'categories';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = false;
|
||||
@@ -30,9 +28,4 @@ class CategoryModel extends Model
|
||||
'user_id' => 'required',
|
||||
'name' => 'required|max_length[255]',
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'category';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ trait LoggableTrait
|
||||
{
|
||||
try {
|
||||
$request = \Config\Services::request();
|
||||
return $request->getUserAgent()->toString();
|
||||
return $request->getUserAgent()->getAgentString();
|
||||
} catch (\Exception $e) {
|
||||
return 'CLI/Script';
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ use CodeIgniter\Model;
|
||||
|
||||
class ProjectModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
protected $table = 'projects';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = false;
|
||||
@@ -30,9 +28,4 @@ class ProjectModel extends Model
|
||||
'user_id' => 'required',
|
||||
'name' => 'required|max_length[255]',
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'project';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ use CodeIgniter\Model;
|
||||
|
||||
class RecurringTaskModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
protected $table = 'recurring_tasks';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = false;
|
||||
@@ -35,11 +33,6 @@ class RecurringTaskModel extends Model
|
||||
'schedule' => 'required|in_list[daily,weekly,monthly,custom]',
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'recurring_task';
|
||||
}
|
||||
|
||||
// Get recurring tasks with categories
|
||||
public function getWithCategories($taskId = null)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@ use CodeIgniter\Model;
|
||||
|
||||
class TodoModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
protected $table = 'todos';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = false;
|
||||
@@ -39,11 +37,6 @@ class TodoModel extends Model
|
||||
'status' => 'permit_empty|in_list[open,in_progress,completed,archived]',
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'todo';
|
||||
}
|
||||
|
||||
// Get todos with categories
|
||||
public function getWithCategories($todoId = null)
|
||||
{
|
||||
|
||||
@@ -6,8 +6,6 @@ use CodeIgniter\Model;
|
||||
|
||||
class UserModel extends Model
|
||||
{
|
||||
use LoggableTrait;
|
||||
|
||||
protected $table = 'users';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = false;
|
||||
@@ -40,9 +38,4 @@ class UserModel extends Model
|
||||
'is_unique' => 'This email is already registered',
|
||||
],
|
||||
];
|
||||
|
||||
protected function getEntityType(): string
|
||||
{
|
||||
return 'user';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user