*/ public function toArray(Request $request): array { return [ 'data' => $this->collection, 'pagination' => [ 'current_page' => $this->currentPage(), 'from' => $this->firstItem(), 'last_page' => $this->lastPage(), 'per_page' => $this->perPage(), 'to' => $this->lastItem(), 'total' => $this->total(), ], 'summary' => [ 'total_products' => $this->collection->count(), 'low_stock_products' => $this->collection->filter(function ($product) { return $product->stock_actuel <= $product->stock_minimum; })->count(), 'total_value' => $this->collection->sum(function ($product) { return $product->stock_actuel * $product->prix_unitaire; }), ], ]; } public function with(Request $request): array { return [ 'status' => 'success', 'message' => 'Produits récupérés avec succès', ]; } }