|
32 | 32 |
|
33 | 33 | it('can filters products', function () { |
34 | 34 | $colorAttribute = Attribute::query()->create(['name' => 'Color', 'slug' => 'color', 'type' => 'checkbox']); |
| 35 | + $this->assertNotNull($colorAttribute->id); |
| 36 | + |
35 | 37 | $redAttributeValue = AttributeValue::query()->create(['value' => 'Red', 'key' => '#1e3a8a', 'attribute_id' => $colorAttribute->id]); |
36 | 38 | $blueAttributeValue = AttributeValue::query()->create(['value' => 'Blue', 'key' => '#ddf048', 'attribute_id' => $colorAttribute->id]); |
| 39 | + |
37 | 40 | $sizeAttribute = Attribute::query()->create(['name' => 'Size', 'slug' => 'size', 'type' => 'checkbox']); |
| 41 | + |
| 42 | + $this->assertNotNull($sizeAttribute->id); |
| 43 | + |
38 | 44 | $smallAttributeValue = AttributeValue::query()->create(['value' => 'Small', 'key' => 'XL', 'attribute_id' => $sizeAttribute->id]); |
39 | 45 | $largeAttributeValue = AttributeValue::query()->create(['value' => 'Large', 'key' => 'L', 'attribute_id' => $sizeAttribute->id]); |
40 | 46 |
|
41 | | - $this->product->attributes()->createMany([ |
| 47 | + $this->product->options()->attach([ |
42 | 48 | ['attribute_value_id' => $redAttributeValue->id, 'attribute_id' => $colorAttribute->id], |
43 | 49 | ['attribute_value_id' => $smallAttributeValue->id, 'attribute_id' => $sizeAttribute->id], |
44 | 50 | ]); |
45 | 51 |
|
46 | | - $this->secondProduct->attributes()->createMany([ |
| 52 | + $this->secondProduct->options()->attach([ |
47 | 53 | ['attribute_value_id' => $blueAttributeValue->id, 'attribute_id' => $colorAttribute->id], |
48 | 54 | ['attribute_value_id' => $largeAttributeValue->id, 'attribute_id' => $sizeAttribute->id], |
49 | 55 | ]); |
|
0 commit comments