Warenwirtschaft: AP-49 — INCI-Lieferanten-Dropdown nur Rohstoff-Lieferanten

Im Produkt-/INCI-Formular zeigt das „Lieferanten"-Dropdown jetzt nur Lieferanten
der Kategorie „Kosmetikrohstoffe" statt aller Lieferanten (Live: 30 → 15). Filter
über whereHas supplierCategories per Kategoriename (stabiles Merkmal, keine
hartkodierte id). Test ergänzt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-08-28 09:13:42 +00:00
parent fa852340ee
commit 4eb36486b0
2 changed files with 37 additions and 1 deletions

View file

@ -46,7 +46,11 @@ class IngredientController extends Controller
'model' => $model,
'taxRates' => TaxRate::query()->active()->orderBy('pos')->orderBy('name')->get(),
'deliveryTimes' => DeliveryTime::query()->active()->orderBy('pos')->orderBy('label')->get(),
'suppliers' => Supplier::query()->where('active', true)->orderBy('name')->get(),
// AP-49: nur Rohstoff-Lieferanten (Kategorie „Kosmetikrohstoffe") — die
// gesamte Lieferantenliste ist im INCI-Formular zu unübersichtlich.
'suppliers' => Supplier::query()->where('active', true)
->whereHas('supplierCategories', fn ($q) => $q->where('name', 'Kosmetikrohstoffe'))
->orderBy('name')->get(),
'storageRooms' => StorageRoom::query()->active()->orderBy('pos')->orderBy('label')->get(),
'storageShelves' => StorageShelf::query()->active()->orderBy('pos')->orderBy('label')->get(),
'storageSlots' => StorageSlot::query()->active()->orderBy('pos')->orderBy('label')->get(),

View file

@ -0,0 +1,32 @@
<?php
use App\Models\Ingredient;
use App\Models\Supplier;
use App\Models\SupplierCategory;
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
uses(TestCase::class, RefreshDatabase::class);
test('AP-49: INCI-Lieferanten-Dropdown zeigt nur Rohstoff-Lieferanten', function () {
$user = User::query()->create(['email' => uniqid('sf_', true).'@test.example', 'password' => bcrypt('password')]);
$user->forceFill(['admin' => 7, 'confirmed' => true, 'active' => true, 'wizard' => 100, 'blocked' => false])->save();
$rawCat = SupplierCategory::query()->create(['name' => 'Kosmetikrohstoffe', 'pos' => 0]);
$packCat = SupplierCategory::query()->create(['name' => 'Versandverpackungen', 'pos' => 1]);
$raw = Supplier::factory()->create(['name' => 'AP49-RohstoffLieferant', 'active' => true]);
$raw->supplierCategories()->attach($rawCat->id);
$pack = Supplier::factory()->create(['name' => 'AP49-VerpackungsLieferant', 'active' => true]);
$pack->supplierCategories()->attach($packCat->id);
$ing = Ingredient::query()->create(['name' => 'AP49-INCI', 'active' => true, 'pos' => 0]);
$this->actingAs($user->fresh(), 'user');
$this->get(route('admin_product_ingredient_edit', $ing->id))
->assertSuccessful()
->assertSee('AP49-RohstoffLieferant')
->assertDontSee('AP49-VerpackungsLieferant');
});