
PK 
<?php
use app\library\Shopcart;
use Illuminate\Support\Facades\Auth;
if (!function_exists('getHeaderCartCount')) {
/**
* Get cart count for header display
*
* @return array
*/
function getHeaderCartCount()
{
return count((new Shopcart())->getItems());
/*try {
if (Auth::check()) {
// Try different possible locations for Cart model
if (class_exists('App\Models\Cart')) {
return \App\Models\Cart::where('user_id', Auth::id())->count();
} elseif (class_exists('App\Cart')) {
return \App\Cart::where('user_id', Auth::id())->count();
} else {
// Fallback if Cart model doesn't exist
return 0;
}
} else {
// For guests - session-based cart
$sessionCart = session('cart', []);
return count($sessionCart);
}
} catch (\Exception $e) {
// Return 0 if any error occurs
return 0;
}*/
}
}
// Add other helper functions if needed
if (!function_exists('otherCustomFunction')) {
function otherCustomFunction()
{
// Your custom function logic
}
}


PK 99