mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
added API and login
This commit is contained in:
45
app/Controllers/Api/V1/ActivityLogController.php
Normal file
45
app/Controllers/Api/V1/ActivityLogController.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Api\V1;
|
||||
|
||||
use App\Controllers\Api\BaseController;
|
||||
use App\Models\ActivityLogModel;
|
||||
|
||||
class ActivityLogController extends BaseController
|
||||
{
|
||||
protected $activityLogModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->activityLogModel = new ActivityLogModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activity logs for the authenticated user
|
||||
* GET /api/v1/activity-logs
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$userId = $this->getUserId();
|
||||
$limit = $this->request->getVar('limit') ?? 50;
|
||||
$logs = $this->activityLogModel->getByUser($userId, $limit);
|
||||
|
||||
return $this->successResponse($logs, 'Activity logs retrieved successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific activity log
|
||||
* GET /api/v1/activity-logs/{id}
|
||||
*/
|
||||
public function show($id = null)
|
||||
{
|
||||
$userId = $this->getUserId();
|
||||
$log = $this->activityLogModel->where('id', $id)->where('user_id', $userId)->first();
|
||||
|
||||
if (!$log) {
|
||||
return $this->errorResponse('Activity log not found', 404);
|
||||
}
|
||||
|
||||
return $this->successResponse($log, 'Activity log retrieved successfully');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user