refactor: standardize spacing in lambda functions and SQL queries across services
This commit is contained in:
parent
7164bd96d3
commit
a3c642e173
@ -18,11 +18,11 @@ public function __invoke(Request $request): Response
|
||||
$user = $request->user();
|
||||
|
||||
return Inertia::render('dashboard', [
|
||||
'attendance' => $this->service->getAttendanceStats(),
|
||||
'attendance' => $this->service->getAttendanceStats(),
|
||||
'revenueSummary' => $this->service->getRevenueSummary(),
|
||||
'expenseSummary' => $this->service->getExpenseSummary(),
|
||||
'orderStats' => $this->service->getOrderStats(),
|
||||
'todayAttendance' => $this->service->getTodayAttendance($user),
|
||||
'todayAttendance' => $this->service->getTodayAttendance($user),
|
||||
'isOnLeave' => $this->service->isOnLeave($user),
|
||||
'canCheckIn' => $user->employee !== null,
|
||||
]);
|
||||
|
||||
@ -107,5 +107,4 @@ public function destroy(RawMaterial $rawMaterial, RawMaterialPrice $variant): bo
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
use App\Enums\OrderChannel;
|
||||
use App\Enums\OrderStatus;
|
||||
use App\Enums\PaymentType;
|
||||
use App\Enums\PriceType;
|
||||
use App\Enums\RawMaterialUnit;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\CashAccount;
|
||||
@ -15,10 +14,8 @@
|
||||
use App\Models\Expense;
|
||||
use App\Models\LeaveRequest;
|
||||
use App\Models\Order;
|
||||
use App\Models\ProductVariant;
|
||||
use App\Models\Purchase;
|
||||
use App\Models\PurchaseItem;
|
||||
use App\Models\RawMaterialPrice;
|
||||
use App\Models\RestockItem;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
@ -472,10 +469,10 @@ public function getRevenueTrend(?string $startDate, ?string $endDate): array
|
||||
|
||||
return (clone $query)
|
||||
->join('order_items', 'orders.id', '=', 'order_items.order_id')
|
||||
->selectRaw("DATE(orders.created_at) as date")
|
||||
->selectRaw('DATE(orders.created_at) as date')
|
||||
->selectRaw('SUM(order_items.quantity) as qty')
|
||||
->groupBy(DB::raw("DATE(orders.created_at)"))
|
||||
->orderBy(DB::raw("DATE(orders.created_at)"))
|
||||
->groupBy(DB::raw('DATE(orders.created_at)'))
|
||||
->orderBy(DB::raw('DATE(orders.created_at)'))
|
||||
->get()
|
||||
->map(fn ($item) => [
|
||||
'date' => $item->date,
|
||||
@ -560,7 +557,7 @@ public function getOrderStats(?string $startDate, ?string $endDate): array
|
||||
->groupBy('marketing_id')
|
||||
->with('marketing:id')
|
||||
->get()
|
||||
->map(fn($item) => [
|
||||
->map(fn ($item) => [
|
||||
'name' => $item->marketing?->userProfile->full_name ?? '-',
|
||||
'count' => $item->count,
|
||||
'total' => (int) $item->total,
|
||||
|
||||
@ -22,14 +22,14 @@ public function getAttendanceStats(): array
|
||||
|
||||
$totalEmployees = Employee::whereHas(
|
||||
'user',
|
||||
fn($q) => $q
|
||||
fn ($q) => $q
|
||||
->where('is_active', true)
|
||||
->whereHas(
|
||||
'roles',
|
||||
fn($r) => $r
|
||||
fn ($r) => $r
|
||||
->whereHas(
|
||||
'permissions',
|
||||
fn($p) => $p
|
||||
fn ($p) => $p
|
||||
->where('name', 'attendances.create')
|
||||
)
|
||||
)
|
||||
@ -38,14 +38,14 @@ public function getAttendanceStats(): array
|
||||
$present = Attendance::where('attendance_date', $today)
|
||||
->whereHas(
|
||||
'employee.user',
|
||||
fn($q) => $q
|
||||
fn ($q) => $q
|
||||
->where('is_active', true)
|
||||
->whereHas(
|
||||
'roles',
|
||||
fn($r) => $r
|
||||
fn ($r) => $r
|
||||
->whereHas(
|
||||
'permissions',
|
||||
fn($p) => $p
|
||||
fn ($p) => $p
|
||||
->where('name', 'attendances.create')
|
||||
)
|
||||
)
|
||||
@ -56,14 +56,14 @@ public function getAttendanceStats(): array
|
||||
->where('end_date', '>=', $today)
|
||||
->whereHas(
|
||||
'employee.user',
|
||||
fn($q) => $q
|
||||
fn ($q) => $q
|
||||
->where('is_active', true)
|
||||
->whereHas(
|
||||
'roles',
|
||||
fn($r) => $r
|
||||
fn ($r) => $r
|
||||
->whereHas(
|
||||
'permissions',
|
||||
fn($p) => $p
|
||||
fn ($p) => $p
|
||||
->where('name', 'attendances.create')
|
||||
)
|
||||
)
|
||||
@ -161,7 +161,7 @@ public function getOrderStats(): array
|
||||
->groupBy('marketing_id')
|
||||
->with('marketing:id')
|
||||
->get()
|
||||
->map(fn($item) => [
|
||||
->map(fn ($item) => [
|
||||
'name' => $item->marketing?->userProfile->full_name ?? '-',
|
||||
'count' => $item->count,
|
||||
'total' => (int) $item->total,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user