lots of design improvements

This commit is contained in:
Doar Mihai
2026-02-14 16:11:09 +02:00
parent 56b593d9ca
commit 67de095a03
25 changed files with 1942 additions and 1477 deletions
@@ -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.
*/
+16 -1
View File
@@ -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'));
}
/**