- Create UserActivitiesTable migration for tracking user activities - Create UserActivityModel for managing activity data - Replace mock data in apiGetRecentActivity with real database data - Remove all mock/fake data from the project
31 lines
952 B
PHP
31 lines
952 B
PHP
<?php
|
|
namespace App\Core\Database\Migrations;
|
|
|
|
use App\Core\Database\Migration;
|
|
|
|
class CreateUserActivitiesTable extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$this->createTable('user_activities', function($table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('user_id');
|
|
$table->string('action', 100);
|
|
$table->string('description', 255);
|
|
$table->json('metadata')->nullable();
|
|
$table->string('ip_address', 45)->nullable();
|
|
$table->string('user_agent', 500)->nullable();
|
|
$table->timestamp('created_at')->useCurrent();
|
|
|
|
$table->index(['user_id', 'created_at']);
|
|
$table->index(['action', 'created_at']);
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$this->dropTable('user_activities');
|
|
}
|
|
}
|