41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\SourceDatabase;
|
|
use App\Models\TargetDatabase;
|
|
use App\Models\Table;
|
|
use App\Models\MigrationSchedule;
|
|
use App\Models\MigrationRun;
|
|
use Inertia\Inertia;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$stats = [
|
|
'source_databases' => SourceDatabase::count(),
|
|
'target_databases' => TargetDatabase::count(),
|
|
'tables' => Table::count(),
|
|
'schedules' => MigrationSchedule::where('is_active', true)->count(),
|
|
];
|
|
|
|
$recentMigrations = MigrationRun::with('schedule')
|
|
->orderBy('created_at', 'desc')
|
|
->limit(10)
|
|
->get()
|
|
->map(fn($run) => [
|
|
'id' => $run->id,
|
|
'schedule_name' => $run->schedule->name ?? 'N/A',
|
|
'status' => $run->status,
|
|
'started_at' => $run->started_at?->format('Y-m-d H:i:s'),
|
|
'completed_at' => $run->completed_at?->format('Y-m-d H:i:s'),
|
|
]);
|
|
|
|
return Inertia::render('Dashboard', [
|
|
'stats' => $stats,
|
|
'recentMigrations' => $recentMigrations,
|
|
]);
|
|
}
|
|
}
|