Completed
Branch master (bb48cc)
by vijay
148:50 queued 92:39
created

GitHubTableSeeder::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 1
Ratio 20 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 1
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
use App\Model\Common\Template;
4
use App\Model\Common\TemplateType;
5
use App\Model\Payment\Currency;
6
use App\Model\Payment\Plan;
7
use App\Model\Payment\Promotion;
8
use App\Model\Payment\PromotionType;
9
use App\Model\Product\Product;
10
use App\Model\Product\ProductGroup;
11
use App\Model\Product\Subscription;
12
use App\Model\Product\Type;
13
use Illuminate\Database\Eloquent\Model;
14
use Illuminate\Database\Seeder;
15
use App\Model\Github\Github;
16
17
class DatabaseSeeder extends Seeder
18
{
19
    /**
20
     * Run the database seeds.
21
     *
22
     * @return void
23
     */
24
    public function run()
25
    {
26
        //Model::unguard();
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
27
28
        $this->call('PlanTableSeeder');
29
        $this->command->info('Plan table seeded!');
30
31
        $this->call('TemplateTypeTableSeeder');
32
        $this->command->info('Template Type table seeded!');
33
34
        $this->call('TemplateTableSeeder');
35
        $this->command->info('Template table seeded!');
36
37
        $this->call('GroupTableSeeder');
38
        $this->command->info('Product Group table seeded!');
39
40
        $this->call('ProductTypesTableSeeder');
41
        $this->command->info('Product Types table seeded!');
42
43
        $this->call('PromotionTypeTableSeeder');
44
        $this->command->info('Promotion Types table seeded!');
45
46
        $this->call('PromotionTableSeeder');
47
        $this->command->info('Promotion table seeded!');
48
49
        $this->call('CurrencyTableSeeder');
50
        $this->command->info('Currency table seeded!');
51
52
        $this->call('ProductTableSeeder');
53
        $this->command->info('Product table seeded!');
54
        
55
        $this->call('GitHubTableSeeder');
56
        $this->command->info('Github table seeded!');
57
    }
58
}
59
60
class PlanTableSeeder extends Seeder
61
{
62
    public function run()
63
    {
64
        \DB::table('plans')->delete();
65
66
        $subcriptions = [
67
            0 => ['name' => 'no subcription', 'days' => 0],
68
            1 => ['name' => 'one week', 'days' => 7],
69
            2 => ['name' => 'one month', 'days' => 30],
70
            3 => ['name' => 'three months', 'days' => 90],
71
            4 => ['name' => 'six months', 'days' => 180],
72
            5 => ['name' => 'one year', 'days' => 365],
73
            6 => ['name' => 'three year', 'days' => 1095],
74
            ];
75
            //var_dump($subcriptions);
76
        for ($i = 0; $i < count($subcriptions); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
77
            Plan::create(['id' => $i + 1, 'name' => $subcriptions[$i]['name'], 'days' => $subcriptions[$i]['days']]);
78
        }
79
    }
80
}
81
82
class ProductTypesTableSeeder extends Seeder
83
{
84
    public function run()
85
    {
86
        \DB::table('product_types')->delete();
87
88
        $types = [
89
            1 => ['name' => 'download'],
90
            0 => ['name' => 'SaaS'],
91
            ];
92
            //var_dump($subcriptions);
93
        for ($i = 0; $i < count($types); $i++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
94
            Type::create(['id' => $i + 1, 'name' => $types[$i]['name']]);
95
        }
96
    }
97
}
98 View Code Duplication
class CurrencyTableSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
{
100
    public function run()
101
    {
102
        \DB::table('currencies')->delete();
103
        Currency::create(['id' => 1, 'code' => 'USD', 'symbol' => '$', 'name' => 'US Doller', 'base_conversion' => '1.0']);
104
    }
105
}
106
107 View Code Duplication
class GroupTableSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
{
109
    public function run()
110
    {
111
        \DB::table('product_groups')->delete();
112
        ProductGroup::create(['id' => 1, 'name' => 'none', 'headline' => 'none', 'tagline' => 'none', 'hidden' => 0, 'cart_link' => 'none']);
113
    }
114
}
115
116
class PromotionTableSeeder extends Seeder
117
{
118
    public function run()
119
    {
120
        \DB::table('promotions')->delete();
121
        Promotion::create(['id' => 1, 'code' => 'none', 'type' => 1, 'uses' => 0, 'value' => 'none', 'start' => '', 'expiry' => '', 'lifetime' => 0, 'once' => 0, 'signups' => 0, 'existing_client' => 0]);
122
    }
123
}
124
125 View Code Duplication
class ProductTableSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
126
{
127
    public function run()
128
    {
129
        \DB::table('products')->delete();
130
        Product::create(['id' => 1, 'name' => 'default', 'type' => 1, 'group' => 1]);
131
         //Product::create(['id'=>2,'name'=>'none1','type'=>1,'group' =>1]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
88% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
132
    }
133
}
134
135
class PromotionTypeTableSeeder extends Seeder
136
{
137
    public function run()
138
    {
139
        \DB::table('promotion_types')->delete();
140
        PromotionType::create(['id' => 1, 'name' => 'Percentage']);
141
        PromotionType::create(['id' => 2, 'name' => 'Fixed Amount']);
142
        PromotionType::create(['id' => 3, 'name' => 'Price Override']);
143
        PromotionType::create(['id' => 4, 'name' => 'Free Setup']);
144
    }
145
}
146
147
class TemplateTypeTableSeeder extends Seeder
148
{
149
    public function run()
150
    {
151
        \DB::table('template_types')->delete();
152
        TemplateType::create(['id' => 1, 'name' => 'welcome_mail']);
153
        TemplateType::create(['id' => 2, 'name' => 'forgot_password']);
154
        TemplateType::create(['id' => 3, 'name' => 'order_mail']);
155
        TemplateType::create(['id' => 4, 'name' => 'subscription_going_to_end']);
156
        TemplateType::create(['id' => 5, 'name' => 'subscription_over']);
157
        TemplateType::create(['id' => 6, 'name' => 'invoice']);
158
        TemplateType::create(['id' => 7, 'name' => 'cart']);
159
    }
160
}
161
162 View Code Duplication
class TemplateTableSeeder extends Seeder
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
163
{
164
    public function run()
165
    {
166
        \DB::table('templates')->delete();
167
        Template::create(['id' => 1, 'name' => 'cart1', 'type' => 3, 'data' => '<div class="col-sm-6 col-md-3 col-lg-3"><div class="pricing-item"><div class="pricing-item-inner"><div class="pricing-wrap"><div class="pricing-icon"><i class="fa fa-credit-card-alt"></i></div><div class="pricing-title">{{title}}</div><div class="pricing-features font-alt"><ul class="sf-list pr-list"><li>{{feature}}</li></ul></div><div class="pricing-num"><sup>{{currency}}</sup>{{price}}</div><div class="pr-per">{{subscription}}</div><div class="pr-button"><a href="{{url}}" class="btn btn-mod">Buy Now</a></div></div> </div> </div></div>']);
168
    }
169
}
170
class GitHubTableSeeder extends Seeder
171
{
172
    public function run()
173
    {
174
        \DB::table('githubs')->delete();
175
        Github::create(['id' => 1]);
176
    }
177
}
178