- 安裝並設定 stancl/tenancy 套件 - 分離 Central / Tenant migrations - 建立 Tenant Model 與資料遷移指令 - 建立房東後台 CRUD (Landlord Dashboard) - 新增租戶管理頁面 (列表、新增、編輯、詳情) - 新增域名管理功能 - 更新部署手冊
30 lines
923 B
PHP
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);
|
|
}
|
|
}
|