Add product status tabs, persist user collection seeding, and enhance staging visibility
This commit is contained in:
@@ -66,8 +66,21 @@ class MakerWorldController extends Controller
|
||||
*/
|
||||
public function staging(Request $request): View
|
||||
{
|
||||
$query = Product::with(['category', 'makerworldCollection'])
|
||||
->where('status', 'draft');
|
||||
$tab = $request->query('tab', 'draft');
|
||||
|
||||
$query = Product::with(['category', 'makerworldCollection']);
|
||||
|
||||
if ($tab === 'draft') {
|
||||
$query->where('status', 'draft');
|
||||
} elseif ($tab === 'published') {
|
||||
$query->whereNotNull('makerworld_id')
|
||||
->where(function ($q) {
|
||||
$q->where('status', 'published')
|
||||
->orWhereNull('status');
|
||||
});
|
||||
} elseif ($tab === 'all') {
|
||||
$query->whereNotNull('makerworld_id');
|
||||
}
|
||||
|
||||
if ($request->filled('collection_id')) {
|
||||
$query->where('makerworld_collection_id', $request->input('collection_id'));
|
||||
@@ -85,9 +98,26 @@ class MakerWorldController extends Controller
|
||||
$stagedProducts = $query->latest()->paginate(24)->withQueryString();
|
||||
$categories = Category::orderBy('name')->get();
|
||||
$collections = MakerWorldCollection::all();
|
||||
$totalStaged = Product::where('status', 'draft')->count();
|
||||
|
||||
return view('admin.makerworld.staging', compact('stagedProducts', 'categories', 'collections', 'totalStaged'));
|
||||
$countDraft = Product::where('status', 'draft')->count();
|
||||
$countPublished = Product::whereNotNull('makerworld_id')
|
||||
->where(function ($q) {
|
||||
$q->where('status', 'published')
|
||||
->orWhereNull('status');
|
||||
})->count();
|
||||
$countAll = Product::whereNotNull('makerworld_id')->count();
|
||||
$totalStaged = $countDraft;
|
||||
|
||||
return view('admin.makerworld.staging', compact(
|
||||
'stagedProducts',
|
||||
'categories',
|
||||
'collections',
|
||||
'tab',
|
||||
'countDraft',
|
||||
'countPublished',
|
||||
'countAll',
|
||||
'totalStaged'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,8 +168,26 @@ class MakerWorldController extends Controller
|
||||
->with('success', "{$addedCount} collecties van @{$userHandle} succesvol gekoppeld en gesynchroniseerd!");
|
||||
}
|
||||
|
||||
// Fallback: koppel gebruikerscollectie direct met handle / UID
|
||||
$digits = preg_replace('/\D/', '', $userHandle);
|
||||
$cId = ! empty($digits) ? $digits : $userHandle;
|
||||
|
||||
$collection = MakerWorldCollection::updateOrCreate(
|
||||
['makerworld_collection_id' => (string) $cId],
|
||||
[
|
||||
'name' => "MakerWorld Collectie (@{$userHandle})",
|
||||
'description' => "Gekoppelde MakerWorld collectie van @{$userHandle}",
|
||||
'user_handle' => $userHandle,
|
||||
'source_url' => $input,
|
||||
'is_active_sync' => true,
|
||||
'sync_interval_minutes' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
$syncResult = $this->makerWorld->syncCollection($collection);
|
||||
|
||||
return redirect()->route('admin.makerworld.index', ['tab' => 'collections'])
|
||||
->with('warning', "Gebruikersprofiel @{$userHandle} herkend. Voer a.u.b. een specifieke collectie-link of ID in (bijv. https://makerworld.com/nl/collections/123456) of log in bij MakerWorld.");
|
||||
->with('success', "Collectie van @{$userHandle} succesvol gekoppeld! Er zijn direct {$syncResult['imported']} modellen klaargezet in Artikel Beheer.");
|
||||
}
|
||||
|
||||
if (! $collectionId) {
|
||||
|
||||
Reference in New Issue
Block a user