ProductRelatedProductTableSeeder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 32 5
1
<?php
2
3
use Illuminate\Database\Seeder;
4
use Illuminate\Database\Eloquent\Model;
5
use Hideyo\Ecommerce\Framework\Services\Shop\Entity\Shop as Shop;
6
use Hideyo\Ecommerce\Framework\Services\Product\Entity\ProductRelatedProduct as ProductRelatedProduct;
7
8
class ProductRelatedProductTableSeeder extends Seeder
9
{
10
    public function run()
11
    {
12
        $productRelatedProduct = new ProductRelatedProduct;
13
14
        DB::table($productRelatedProduct->getTable())->delete();
15
16
        for ($x = 1; $x <= 10; $x++) {
17
	        $productRelatedProduct = new ProductRelatedProduct;
18
	        $productRelatedProduct->product_id = $x;
19
	        $productRelatedProduct->related_product_id = $x + 1;
20
	        $productRelatedProduct->save();
21
	    }
22
23
        for ($x = 2; $x <= 10; $x++) {
24
	        $productRelatedProduct = new ProductRelatedProduct;
25
	        $productRelatedProduct->product_id = $x;
26
	        $productRelatedProduct->related_product_id = $x + 1;
27
	        $productRelatedProduct->save();
28
	    }
29
30
        for ($x = 3; $x <= 10; $x++) {
31
	        $productRelatedProduct = new ProductRelatedProduct;
32
	        $productRelatedProduct->product_id = $x;
33
	        $productRelatedProduct->related_product_id = $x + 1;
34
	        $productRelatedProduct->save();
35
	    }
36
37
        for ($x = 4; $x <= 10; $x++) {
38
	        $productRelatedProduct = new ProductRelatedProduct;
39
	        $productRelatedProduct->product_id = $x;
40
	        $productRelatedProduct->related_product_id = $x + 1;
41
	        $productRelatedProduct->save();
42
	    }
43
    }
44
}
45