- 修正所有模組 Controller 的 Model 引用路徑 (App\Modules\...) - 更新 ProductionOrder 與 ProductionOrderItem 模型結構以符合新版邏輯 - 修復 resources/js/utils/format.ts 在處理空值時導致 toLocaleString 崩潰的問題 - 清除全域路徑與 Controller 遷移殘留檔案
30 lines
936 B
PHP
30 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Landlord;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Modules\Core\Models\Tenant;
|
|
use Inertia\Inertia;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$stats = [
|
|
'totalTenants' => Tenant::count(),
|
|
'activeTenants' => Tenant::whereJsonContains('data->is_active', true)->count(),
|
|
'recentTenants' => Tenant::latest()->take(5)->get()->map(function ($tenant) {
|
|
return [
|
|
'id' => $tenant->id,
|
|
'name' => $tenant->name ?? $tenant->id,
|
|
'is_active' => $tenant->is_active ?? true,
|
|
'created_at' => $tenant->created_at->format('Y-m-d H:i'),
|
|
'domains' => $tenant->domains->pluck('domain')->toArray(),
|
|
];
|
|
}),
|
|
];
|
|
|
|
return Inertia::render('Landlord/Dashboard', $stats);
|
|
}
|
|
}
|