paginate(50); return Inertia::render('Admin/Subscribers/Index', [ 'subscribers' => $subscribers->through(fn ($sub) => [ 'id' => $sub->id, 'email' => $sub->email, 'is_active' => $sub->is_active, 'created_at' => $sub->created_at->format('Y-m-d H:i'), ]), 'pagination' => [ 'current_page' => $subscribers->currentPage(), 'last_page' => $subscribers->lastPage(), 'per_page' => $subscribers->perPage(), 'total' => $subscribers->total(), ], 'stats' => [ 'total' => Subscription::count(), 'active' => Subscription::where('is_active', true)->count(), 'inactive' => Subscription::where('is_active', false)->count(), ], ]); } /** * Remove the specified subscriber. */ public function destroy(Subscription $subscription): RedirectResponse { // Soft delete by setting is_active to false $subscription->update(['is_active' => false]); return redirect()->route('admin.subscribers.index') ->with('success', 'Subscriber deactivated successfully.'); } }