Files
star-erp/app/Http/Controllers/Landlord/DashboardController.php
sky121113 4f745c1021
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m3s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped
feat: 實作 Multi-tenancy 多租戶架構 (stancl/tenancy)
- 安裝並設定 stancl/tenancy 套件
- 分離 Central / Tenant migrations
- 建立 Tenant Model 與資料遷移指令
- 建立房東後台 CRUD (Landlord Dashboard)
- 新增租戶管理頁面 (列表、新增、編輯、詳情)
- 新增域名管理功能
- 更新部署手冊
2026-01-15 13:15:18 +08:00

30 lines
923 B
PHP

<?php
namespace App\Http\Controllers\Landlord;
use App\Http\Controllers\Controller;
use App\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);
}
}