lots of design improvements
This commit is contained in:
@@ -11,6 +11,42 @@ use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the homepage with featured products.
|
||||
*/
|
||||
public function homepage()
|
||||
{
|
||||
// Get trending products (most upvoted in the last 7 days)
|
||||
$trendingProducts = Product::query()
|
||||
->with(['user', 'category'])
|
||||
->approved()
|
||||
->where('created_at', '>=', now()->subDays(7))
|
||||
->withCount('upvotes')
|
||||
->orderBy('upvotes_count', 'desc')
|
||||
->limit(6)
|
||||
->get();
|
||||
|
||||
// Get recently added products
|
||||
$recentProducts = Product::query()
|
||||
->with(['user', 'category'])
|
||||
->approved()
|
||||
->latest()
|
||||
->limit(12)
|
||||
->get();
|
||||
|
||||
// Get popular categories with product counts
|
||||
$categories = Category::query()
|
||||
->withCount(['products' => function($query) {
|
||||
$query->approved();
|
||||
}])
|
||||
->having('products_count', '>', 0)
|
||||
->orderBy('products_count', 'desc')
|
||||
->limit(8)
|
||||
->get();
|
||||
|
||||
return view('welcome', compact('trendingProducts', 'recentProducts', 'categories'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the products.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,22 @@ class ProfileController extends Controller
|
||||
*/
|
||||
public function show(User $user)
|
||||
{
|
||||
return view('profile.show', compact('user'));
|
||||
// Get user's products
|
||||
$products = $user->products()
|
||||
->with(['category', 'user'])
|
||||
->approved()
|
||||
->withCount('upvotes')
|
||||
->latest()
|
||||
->paginate(12);
|
||||
|
||||
// Get user's stats
|
||||
$stats = [
|
||||
'products_count' => $user->products()->approved()->count(),
|
||||
'total_upvotes' => $user->products()->approved()->withCount('upvotes')->get()->sum('upvotes_count'),
|
||||
'comments_count' => $user->comments()->count(),
|
||||
];
|
||||
|
||||
return view('profile.show', compact('user', 'products', 'stats'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user