Add product status tabs, persist user collection seeding, and enhance staging visibility

This commit is contained in:
2026-11-01 16:17:02 +01:00
parent 11f6efad09
commit c06701673a
8 changed files with 281 additions and 68 deletions
@@ -17,13 +17,26 @@ class ProductController extends Controller
*/
public function index(Request $request): View
{
$query = Product::with('category')->latest();
$tab = $request->query('tab', 'all');
$query = Product::with(['category', 'makerworldCollection'])->latest();
if ($tab === 'published') {
$query->where(function ($q) {
$q->where('status', 'published')
->orWhereNull('status');
});
} elseif ($tab === 'draft') {
$query->where('status', 'draft');
} elseif ($tab === 'makerworld') {
$query->whereNotNull('makerworld_id');
}
if ($request->filled('q')) {
$q = $request->input('q');
$query->where(function ($w) use ($q) {
$w->where('name', 'like', "%{$q}%")
->orWhere('description', 'like', "%{$q}%");
->orWhere('description', 'like', "%{$q}%")
->orWhere('makerworld_id', 'like', "%{$q}%");
});
}
@@ -31,10 +44,23 @@ class ProductController extends Controller
$query->where('category_id', $request->input('category_id'));
}
$totalAll = Product::count();
$totalPublished = Product::where('status', 'published')->orWhereNull('status')->count();
$totalDraft = Product::where('status', 'draft')->count();
$totalMakerWorld = Product::whereNotNull('makerworld_id')->count();
$products = $query->paginate(20)->withQueryString();
$categories = Category::all();
return view('admin.products.index', compact('products', 'categories'));
return view('admin.products.index', compact(
'products',
'categories',
'tab',
'totalAll',
'totalPublished',
'totalDraft',
'totalMakerWorld'
));
}
/**