PaymentMethodTableSeeder   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 21 1
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