@php // Determine the column class based on the number of cards per row. $columnClass = 'col-lg-4 col-md-6'; // Default to 3 columns if (isset($cardsPerRow) && $cardsPerRow == 4) { $columnClass = 'col-lg-3 col-md-6'; // 4 columns } elseif (isset($cardsPerRow) && $cardsPerRow == 6) { $columnClass = 'col-lg-2 col-md-6'; // 6 columns } elseif (isset($cardsPerRow) && $cardsPerRow == 3) { $columnClass = 'col-lg-4 col-md-6'; // 3 columns } // Check if the product is in the user's favorites *if the user is authenticated*. $isFavorite = false; if (Auth::check()) { $isFavorite = Auth::user()->favorites()->where('product_id', $product->id)->exists(); } @endphp