refactor: remove unused imports and improve SQL query formatting in DashboardController for cleaner code

This commit is contained in:
Yoga Pangestu 2026-06-20 21:48:37 +07:00
parent 21adde11fd
commit 2a6d4afdee

View File

@ -2,7 +2,6 @@
namespace App\Http\Controllers\Admin;
use App\Enums\CashTransactionType;
use App\Enums\CuttingStatus;
use App\Enums\EmployeeAdvanceStatus;
use App\Enums\EmploymentStatus;
@ -27,7 +26,6 @@
use App\Models\Purchase;
use App\Models\RawMaterialPrice;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Inertia\Inertia;
use Inertia\Response;
@ -261,7 +259,7 @@ private function getOrderStats(): array
->whereNotNull('marketing_id')
->join('users', 'orders.marketing_id', '=', 'users.id')
->leftJoin('user_profiles', 'users.id', '=', 'user_profiles.user_id')
->selectRaw("COALESCE(user_profiles.full_name, users.username) as name, COUNT(*) as count, SUM(orders.total_amount) as total")
->selectRaw('COALESCE(user_profiles.full_name, users.username) as name, COUNT(*) as count, SUM(orders.total_amount) as total')
->groupBy('orders.marketing_id', 'users.username', 'user_profiles.full_name')
->orderByDesc('total')
->limit(5)