PaymentMethodTableSeeder::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 0
loc 21
rs 9.7998
c 1
b 0
f 0
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\PaymentMethod\Entity\PaymentMethod as PaymentMethod;
7
use Hideyo\Ecommerce\Framework\Services\SendingMethod\Entity\SendingMethod as SendingMethod;
8
9
use Hideyo\Ecommerce\Framework\Services\TaxRate\Entity\TaxRate as TaxRate;
10
11
class PaymentMethodTableSeeder extends Seeder
12
{
13
    public function run()
14
    {
15
        $taxRate = TaxRate::where('title', '=', '21%')->first();
16
        $paymentMethod = new PaymentMethod;
17
18
        DB::table($paymentMethod->getTable())->delete();
19
        $shop = Shop::where('title', '=', 'hideyo')->first();
20
21
        $paymentMethod->active = 1;
22
        $paymentMethod->title = 'Bank transfer';
23
        $paymentMethod->tax_rate_id = $taxRate->id; 
24
        $paymentMethod->price = '0';  
25
        $paymentMethod->shop_id = $shop->id;
26
        $paymentMethod->save();
27
28
        $sendingMethod = SendingMethod::where('title', '=', 'China')->first();
29
        $sendingMethod->relatedPaymentMethods()->sync(array($paymentMethod->id));
30
31
32
        $sendingMethod = SendingMethod::where('title', '=', 'Netherlands')->first();
33
        $sendingMethod->relatedPaymentMethods()->sync(array($paymentMethod->id));
34
35
36
37
    }
38
}
39