first commit
This commit is contained in:
40
app/Http/Controllers/DashboardController.php
Normal file
40
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user