invoiceninja/database/seeds/PaymentTypesSeeder.php
David Bomba ba75a44eb8
Laravel 7.x Shift (#40)
* Adopt Laravel coding style

The Laravel framework adopts the PSR-2 coding style with some additions.
Laravel apps *should* adopt this coding style as well.

However, Shift allows you to customize the adopted coding style by
adding your own [PHP CS Fixer][1] `.php_cs` config to your project.

You may use [Shift's .php_cs][2] file as a base.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200

* Shift bindings

PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.

* Shift core files

* Shift to Throwable

* Add laravel/ui dependency

* Unindent vendor mail templates

* Shift config files

* Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them so you can review the commit diff for
changes. Moving forward, you should use ENV variables or create a
separate config file to allow the core config files to remain
automatically upgradeable.

* Shift Laravel dependencies

* Shift cleanup

* Upgrade to Laravel 7

Co-authored-by: Laravel Shift <shift@laravelshift.com>
2020-09-06 19:38:10 +10:00

81 lines
3.7 KiB
PHP

<?php
use App\Models\PaymentType;
use Illuminate\Database\Seeder;
class PaymentTypesSeeder extends Seeder
{
const BANK_LIBRARY_OFX = 1;
const GATEWAY_TYPE_CREDIT_CARD = 1;
const GATEWAY_TYPE_BANK_TRANSFER = 2;
const GATEWAY_TYPE_PAYPAL = 3;
const GATEWAY_TYPE_CRYPTO = 4;
const GATEWAY_TYPE_DWOLLA = 5;
const GATEWAY_TYPE_CUSTOM1 = 6;
const GATEWAY_TYPE_ALIPAY = 7;
const GATEWAY_TYPE_SOFORT = 8;
const GATEWAY_TYPE_SEPA = 9;
const GATEWAY_TYPE_GOCARDLESS = 10;
const GATEWAY_TYPE_APPLE_PAY = 11;
const GATEWAY_TYPE_CUSTOM2 = 12;
const GATEWAY_TYPE_CUSTOM3 = 13;
public function run()
{
Eloquent::unguard();
$paymentTypes = [
// ['name' => 'Apply Credit'],
['name' => 'Bank Transfer', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Cash'],
['name' => 'Debit', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'ACH', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Visa Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'MasterCard', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'American Express', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Discover Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Diners Card', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'EuroCard', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Nova', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Credit Card Other', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'PayPal', 'gateway_type_id' => self::GATEWAY_TYPE_PAYPAL],
['name' => 'Google Wallet'],
['name' => 'Check'],
['name' => 'Carte Blanche', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'UnionPay', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'JCB', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Laser', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Maestro', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Solo', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Switch', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'iZettle', 'gateway_type_id' => self::GATEWAY_TYPE_CREDIT_CARD],
['name' => 'Swish', 'gateway_type_id' => self::GATEWAY_TYPE_BANK_TRANSFER],
['name' => 'Venmo'],
['name' => 'Money Order'],
['name' => 'Alipay', 'gateway_type_id' => self::GATEWAY_TYPE_ALIPAY],
['name' => 'Sofort', 'gateway_type_id' => self::GATEWAY_TYPE_SOFORT],
['name' => 'SEPA', 'gateway_type_id' => self::GATEWAY_TYPE_SEPA],
['name' => 'GoCardless', 'gateway_type_id' => self::GATEWAY_TYPE_GOCARDLESS],
['name' => 'Crypto', 'gateway_type_id' => self::GATEWAY_TYPE_CRYPTO],
];
$x = 1;
foreach ($paymentTypes as $paymentType) {
$record = PaymentType::where('name', '=', $paymentType['name'])->first();
if ($record) {
$record->id = $x;
$record->name = $paymentType['name'];
$record->gateway_type_id = ! empty($paymentType['gateway_type_id']) ? $paymentType['gateway_type_id'] : null;
$record->save();
} else {
$paymentType['id'] = $x;
PaymentType::create($paymentType);
}
$x++;
}
}
}