records(function (?string $search, ?string $sortColumn, ?string $sortDirection, int|string $page, int|string $recordsPerPage, ?array $filters) use ($service) { $type = Arr::get($filters, 'type.value') ?? Arr::get($filters, 'type'); return $service->paginate( search: $search, sortColumn: $sortColumn, sortDirection: $sortDirection, page: (int) $page, perPage: (int) $recordsPerPage, filters: array_filter(['type' => is_array($type) ? ($type['value'] ?? null) : $type]), ); }) ->columns([ TextColumn::make('created_at')->label('Waktu')->dateTime('d M Y H:i', 'Asia/Jakarta')->sortable(), TextColumn::make('products.code')->label('Kode')->badge(), TextColumn::make('products.name')->label('Produk'), TextColumn::make('type') ->label('Tipe') ->badge() ->color(fn (string $state): string => match ($state) { 'restock' => 'success', 'adjustment' => 'warning', 'order_out' => 'info', default => 'gray', }) ->formatStateUsing(fn (string $state): string => match ($state) { 'restock' => 'Restok', 'adjustment' => 'Koreksi', 'order_out' => 'Order Keluar', default => $state, }), TextColumn::make('quantity') ->label('Qty') ->numeric() ->color(fn (string $state): string => str_starts_with((string) $state, '-') ? 'danger' : 'success'), TextColumn::make('notes')->label('Catatan')->limit(40), ]) ->filters([ Filter::make('type') ->schema([ Select::make('value')->label('Tipe Mutasi')->options([ 'restock' => 'Restok', 'adjustment' => 'Koreksi', 'order_out' => 'Order Keluar', ]), ]), ]) ->paginated([10, 25, 50]); } public function content(Schema $schema): Schema { return $schema ->components([ EmbeddedTable::make(), ]); } }