All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 43s
34 lines
962 B
PHP
34 lines
962 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Machine\Machine;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
// 從資料庫獲取真實統計數據
|
|
$totalRevenue = \App\Models\Member\MemberWallet::sum('balance');
|
|
$activeMachines = Machine::where('status', 'online')->count();
|
|
$alertsPending = Machine::where('status', 'error')->count();
|
|
$memberCount = \App\Models\Member\Member::count();
|
|
|
|
// 獲取最新動態 (最近 3 筆機台日誌)
|
|
$latestActivities = \App\Models\Machine\MachineLog::with('machine')
|
|
->latest()
|
|
->limit(3)
|
|
->get();
|
|
|
|
return view('admin.dashboard', compact(
|
|
'totalRevenue',
|
|
'activeMachines',
|
|
'alertsPending',
|
|
'memberCount',
|
|
'latestActivities'
|
|
));
|
|
}
|
|
}
|