From 88696c4eecaed9d28b93d4a17acf39927585d9ce Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 2 Mar 2016 16:29:26 +0200 Subject: [PATCH 01/15] Added auth check in subscription listeners --- app/Listeners/SubscriptionListener.php | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 2d12fcaeb953..c3f1d9d80339 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -24,29 +24,49 @@ class SubscriptionListener { public function createdClient(ClientWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new ClientTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer); } public function createdQuote(QuoteWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new InvoiceTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } public function createdPayment(PaymentWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new PaymentTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } public function createdCredit(CreditWasCreated $event) { + if ( ! Auth::check()) { + return; + } + //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); } public function createdInvoice(InvoiceWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new InvoiceTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } @@ -55,7 +75,7 @@ class SubscriptionListener { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor); } - + public function createdExpense(ExpenseWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense); @@ -69,11 +89,11 @@ class SubscriptionListener $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); $manager->parseIncludes($include); - + $resource = new Item($entity, $transformer, $entity->getEntityType()); $data = $manager->createData($resource)->toArray(); - + Utils::notifyZapier($subscription, $data); } } -} +} \ No newline at end of file From ab8f40517fc0e95c99343fe82508a1ed9cb80eeb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 2 Mar 2016 22:51:13 +0200 Subject: [PATCH 02/15] Fix for tests --- .travis.yml | 3 ++- database/seeds/PaymentLibrariesSeeder.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7dd08d994c6..9a1a2f53b643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,11 @@ install: # these providers require referencing git commit's which cause Travis to fail - sed -i '/mollie/d' composer.json - sed -i '/2checkout/d' composer.json + - sed -i '/omnipay-neteller/d' composer.json - travis_retry composer install --prefer-dist; before_script: - # prevent MySQL went away error + # prevent MySQL went away error - mysql -u root -e 'SET @@GLOBAL.wait_timeout=28800;' # copy configuration files - cp .env.example .env diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index d4d01c76fd92..8710357a36c2 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -32,7 +32,7 @@ class PaymentLibrariesSeeder extends Seeder ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'payment_library_id' => 1], ['name' => 'Coinbase', 'provider' => 'Coinbase', 'payment_library_id' => 1], ['name' => 'DataCash', 'provider' => 'DataCash', 'payment_library_id' => 1], - ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 1], + ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 2], ['name' => 'Pacnet', 'provider' => 'Pacnet', 'payment_library_id' => 1], ['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1], ['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1], @@ -157,7 +157,7 @@ class PaymentLibrariesSeeder extends Seeder ['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'label' => '20-03-2013'], ['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'label' => '03/20/2013'] ]; - + foreach ($formats as $format) { $record = DateFormat::whereLabel($format['label'])->first(); if ($record) { @@ -224,7 +224,7 @@ class PaymentLibrariesSeeder extends Seeder 'label' => '03/20/2013 6:15 pm' ] ]; - + foreach ($formats as $format) { $record = DatetimeFormat::whereLabel($format['label'])->first(); if ($record) { @@ -250,7 +250,7 @@ class PaymentLibrariesSeeder extends Seeder 'Playful', 'Photo', ]; - + for ($i=0; $i Date: Sun, 6 Mar 2016 08:13:01 +0200 Subject: [PATCH 03/15] Git update --- app/Http/routes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index f7bed59f6879..0f2fb017f461 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,5 +1,6 @@ id === 1) { Auth::loginUsingId(1); } -*/ \ No newline at end of file +*/ From 93d9d3828685e257a09da65ffae88f285ee52d4f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 6 Mar 2016 08:13:52 +0200 Subject: [PATCH 04/15] Git update --- app/Http/routes.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 0f2fb017f461..661d9514ee7b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,6 +1,5 @@ Date: Mon, 7 Mar 2016 17:26:57 +0200 Subject: [PATCH 05/15] Added warning if cache isn't set --- app/Libraries/Utils.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 027f512a47df..d0b17df7f021 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -274,7 +274,14 @@ class Utils } public static function getFromCache($id, $type) { - $data = Cache::get($type)->filter(function($item) use ($id) { + $cache = Cache::get($type); + + if ( ! $cache) { + static::logError("Cache for {$type} is not set"); + return null; + } + + $data = $cache->filter(function($item) use ($id) { return $item->id == $id; }); From 5bedad47e468413d84bc85ac8b459af97810dee6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 7 Mar 2016 17:34:59 +0200 Subject: [PATCH 06/15] Bumped version to 2.5.0.4 --- app/Http/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 661d9514ee7b..55ca02d103cf 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -509,7 +509,7 @@ if (!defined('CONTACT_EMAIL')) { define('NINJA_GATEWAY_CONFIG', 'NINJA_GATEWAY_CONFIG'); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); - define('NINJA_VERSION', '2.5.0.3'); + define('NINJA_VERSION', '2.5.0.4'); define('NINJA_DATE', '2000-01-01'); define('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja'); From b16986451026aad1e7b8888c0cb56c03436ddc89 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 19:36:09 +1100 Subject: [PATCH 07/15] merge fixes --- app/Listeners/SubscriptionListener.php | 35 +++++++++----------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 8b0a231560f4..72de6ef1b893 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -18,43 +18,28 @@ class SubscriptionListener { public function createdClient(ClientWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new ClientTransformer(Auth::user()->account); + $transformer = new ClientTransformer($event->client->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer); } public function createdQuote(QuoteWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new InvoiceTransformer(Auth::user()->account); + $transformer = new InvoiceTransformer($event->quote->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } public function createdPayment(PaymentWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new PaymentTransformer(Auth::user()->account); + $transformer = new PaymentTransformer($event->payment->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } - public function createdCredit(CreditWasCreated $event) - { - if ( ! Auth::check()) { - return; - } - //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); - } public function createdInvoice(InvoiceWasCreated $event) { - if ( ! Auth::check()) { - return; - } - $transformer = new InvoiceTransformer(Auth::user()->account); + $transformer = new InvoiceTransformer($event->invoice->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } + public function createdCredit(CreditWasCreated $event) + { + //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); + } public function createdVendor(VendorWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor); @@ -72,6 +57,10 @@ class SubscriptionListener $manager->parseIncludes($include); $resource = new Item($entity, $transformer, $entity->getEntityType()); $data = $manager->createData($resource)->toArray(); + // For legacy Zapier support + if (isset($data['client_id'])) { + $data['client_name'] = $entity->client->getDisplayName(); + } Utils::notifyZapier($subscription, $data); } } From 501d36da07403c405d0a107073e4dbc51a37b8fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 19:37:48 +1100 Subject: [PATCH 08/15] merge fixes --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bad7f18eb66b..ac07484b66d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ install: # these providers require referencing git commit's which cause Travis to fail - sed -i '/mollie/d' composer.json - sed -i '/2checkout/d' composer.json - - sed -i '/omnipay-neteller/d' composer.json - travis_retry composer install --prefer-dist; before_script: From c7275cee5fdd96a1aff06f834560b0d09cd787a6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 19:39:19 +1100 Subject: [PATCH 09/15] merge fixes --- app/Listeners/SubscriptionListener.php | 19 +- database/seeds/PaymentLibrariesSeeder.php | 347 +++++++++++++++++++++- 2 files changed, 364 insertions(+), 2 deletions(-) diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 72de6ef1b893..cac483b4d309 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -1,19 +1,25 @@ client->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer); } + public function createdQuote(QuoteWasCreated $event) { $transformer = new InvoiceTransformer($event->quote->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } + public function createdPayment(PaymentWasCreated $event) { $transformer = new PaymentTransformer($event->payment->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } + public function createdInvoice(InvoiceWasCreated $event) { $transformer = new InvoiceTransformer($event->invoice->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } + public function createdCredit(CreditWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); } + public function createdVendor(VendorWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor); } + public function createdExpense(ExpenseWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense); } + private function checkSubscriptions($activityTypeId, $entity, $transformer, $include = '') { $subscription = $entity->account->getSubscription($activityTypeId); + if ($subscription) { $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); $manager->parseIncludes($include); + $resource = new Item($entity, $transformer, $entity->getEntityType()); $data = $manager->createData($resource)->toArray(); + // For legacy Zapier support if (isset($data['client_id'])) { $data['client_name'] = $entity->client->getDisplayName(); } + Utils::notifyZapier($subscription, $data); } } -} \ No newline at end of file +} diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index b657e66dd1b9..8710357a36c2 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -1,4 +1,5 @@ createGateways(); + $this->createPaymentTerms(); + $this->createDateFormats(); + $this->createDatetimeFormats(); + $this->createInvoiceDesigns(); + $this->updateLocalization(); + } + + private function createGateways() { + $gateways = [ ['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], @@ -46,6 +59,7 @@ class PaymentLibrariesSeeder extends Seeder ['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 1], ['name' => 'WePay', 'provider' => 'WePay', 'payment_library_id' => 1], ]; + foreach ($gateways as $gateway) { $record = Gateway::where('name', '=', $gateway['name'])->first(); if ($record) { @@ -55,5 +69,336 @@ class PaymentLibrariesSeeder extends Seeder Gateway::create($gateway); } } + } -} \ No newline at end of file + + private function createPaymentTerms() { + + $paymentTerms = [ + ['num_days' => -1, 'name' => 'Net 0'], + ]; + + foreach ($paymentTerms as $paymentTerm) { + if (!DB::table('payment_terms')->where('name', '=', $paymentTerm['name'])->get()) { + PaymentTerm::create($paymentTerm); + } + } + + $currencies = [ + ['name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Pound Sterling', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Euro', 'code' => 'EUR', 'symbol' => '€', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'South African Rand', 'code' => 'ZAR', 'symbol' => 'R', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Danish Krone', 'code' => 'DKK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Israeli Shekel', 'code' => 'ILS', 'symbol' => 'NIS ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Swedish Krona', 'code' => 'SEK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Kenyan Shilling', 'code' => 'KES', 'symbol' => 'KSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Canadian Dollar', 'code' => 'CAD', 'symbol' => 'C$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Philippine Peso', 'code' => 'PHP', 'symbol' => 'P ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Indian Rupee', 'code' => 'INR', 'symbol' => 'Rs. ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Australian Dollar', 'code' => 'AUD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Singapore Dollar', 'code' => 'SGD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Norske Kroner', 'code' => 'NOK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'New Zealand Dollar', 'code' => 'NZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Vietnamese Dong', 'code' => 'VND', 'symbol' => '', 'precision' => '0', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Swiss Franc', 'code' => 'CHF', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '\'', 'decimal_separator' => '.'], + ['name' => 'Guatemalan Quetzal', 'code' => 'GTQ', 'symbol' => 'Q', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Malaysian Ringgit', 'code' => 'MYR', 'symbol' => 'RM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Brazilian Real', 'code' => 'BRL', 'symbol' => 'R$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Thai Baht', 'code' => 'THB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Nigerian Naira', 'code' => 'NGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Argentine Peso', 'code' => 'ARS', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Bangladeshi Taka', 'code' => 'BDT', 'symbol' => 'Tk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'United Arab Emirates Dirham', 'code' => 'AED', 'symbol' => 'DH ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Hong Kong Dollar', 'code' => 'HKD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Mexican Peso', 'code' => 'MXN', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Egyptian Pound', 'code' => 'EGP', 'symbol' => 'E£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Colombian Peso', 'code' => 'COP', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'West African Franc', 'code' => 'XOF', 'symbol' => 'CFA ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Chinese Renminbi', 'code' => 'CNY', 'symbol' => 'RMB ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Rwandan Franc', 'code' => 'RWF', 'symbol' => 'RF ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Tanzanian Shilling', 'code' => 'TZS', 'symbol' => 'TSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Netherlands Antillean Guilder', 'code' => 'ANG', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Trinidad and Tobago Dollar', 'code' => 'TTD', 'symbol' => 'TT$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'East Caribbean Dollar', 'code' => 'XCD', 'symbol' => 'EC$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Ghanaian Cedi', 'code' => 'GHS', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ['name' => 'Bulgarian Lev', 'code' => 'BGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'], + ['name' => 'Aruban Florin', 'code' => 'AWG', 'symbol' => 'Afl. ', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'], + ['name' => 'Turkish Lira', 'code' => 'TRY', 'symbol' => 'TL ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], + ['name' => 'Romanian New Leu', 'code' => 'RON', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], + ]; + + foreach ($currencies as $currency) { + $record = Currency::whereCode($currency['code'])->first(); + if ($record) { + $record->name = $currency['name']; + $record->symbol = $currency['symbol']; + $record->thousand_separator = $currency['thousand_separator']; + $record->decimal_separator = $currency['decimal_separator']; + $record->save(); + } else { + Currency::create($currency); + } + } + } + + private function createDateFormats() { + + $formats = [ + ['format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy', 'label' => '10/Mar/2013'], + ['format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy', 'label' => '10-Mar-2013'], + ['format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy', 'label' => '10/March/2013'], + ['format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy', 'label' => '10-March-2013'], + ['format' => 'M j, Y', 'picker_format' => 'M d, yyyy', 'label' => 'Mar 10, 2013'], + ['format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'label' => 'March 10, 2013'], + ['format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10, 2013'], + ['format' => 'Y-m-d', 'picker_format' => 'yyyy-mm-dd', 'label' => '2013-03-10'], + ['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'label' => '20-03-2013'], + ['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'label' => '03/20/2013'] + ]; + + foreach ($formats as $format) { + $record = DateFormat::whereLabel($format['label'])->first(); + if ($record) { + $record->format = $format['format']; + $record->picker_format = $format['picker_format']; + $record->save(); + } else { + DateFormat::create($format); + } + } + } + + private function createDatetimeFormats() { + + $formats = [ + [ + 'format' => 'd/M/Y g:i a', + 'format_moment' => 'DD/MMM/YYYY h:mm:ss a', + 'label' => '10/Mar/2013' + ], + [ + 'format' => 'd-M-Y g:i a', + 'format_moment' => 'DD-MMM-YYYY h:mm:ss a', + 'label' => '10-Mar-2013' + ], + [ + 'format' => 'd/F/Y g:i a', + 'format_moment' => 'DD/MMMM/YYYY h:mm:ss a', + 'label' => '10/March/2013' + ], + [ + 'format' => 'd-F-Y g:i a', + 'format_moment' => 'DD-MMMM-YYYY h:mm:ss a', + 'label' => '10-March-2013' + ], + [ + 'format' => 'M j, Y g:i a', + 'format_moment' => 'MMM D, YYYY h:mm:ss a', + 'label' => 'Mar 10, 2013 6:15 pm' + ], + [ + 'format' => 'F j, Y g:i a', + 'format_moment' => 'MMMM D, YYYY h:mm:ss a', + 'label' => 'March 10, 2013 6:15 pm' + ], + [ + 'format' => 'D M jS, Y g:i a', + 'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a', + 'label' => 'Mon March 10th, 2013 6:15 pm' + ], + [ + 'format' => 'Y-m-d g:i a', + 'format_moment' => 'YYYY-MMM-DD h:mm:ss a', + 'label' => '2013-03-10 6:15 pm' + ], + [ + 'format' => 'd-m-Y g:i a', + 'format_moment' => 'DD-MM-YYYY h:mm:ss a', + 'label' => '20-03-2013 6:15 pm' + ], + [ + 'format' => 'm/d/Y g:i a', + 'format_moment' => 'MM/DD/YYYY h:mm:ss a', + 'label' => '03/20/2013 6:15 pm' + ] + ]; + + foreach ($formats as $format) { + $record = DatetimeFormat::whereLabel($format['label'])->first(); + if ($record) { + $record->format = $format['format']; + $record->format_moment = $format['format_moment']; + $record->save(); + } else { + DatetimeFormat::create($format); + } + } + } + + private function createInvoiceDesigns() { + $designs = [ + 'Clean', + 'Bold', + 'Modern', + 'Plain', + 'Business', + 'Creative', + 'Elegant', + 'Hipster', + 'Playful', + 'Photo', + ]; + + for ($i=0; $ifirst(); + if (!$record) { + $record = new InvoiceDesign; + $record->id = $i + 1; + $record->name = $design; + } + $record->pdfmake = $pdfmake; + $record->save(); + } + } + } + } + + private function updateLocalization() { + // Source: http://www.bitboost.com/ref/international-address-formats.html + // Source: https://en.wikipedia.org/wiki/Linguistic_issues_concerning_the_euro + $countries = [ + 'AR' => [ + 'swap_postal_code' => true, + ], + 'AT' => [ // Austria + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'BE' => [ + 'swap_postal_code' => true, + ], + 'BG' => [ // Belgium + 'swap_currency_symbol' => true, + ], + 'CH' => [ + 'swap_postal_code' => true, + ], + 'CZ' => [ // Czech Republic + 'swap_currency_symbol' => true, + ], + 'DE' => [ // Germany + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'DK' => [ + 'swap_postal_code' => true, + ], + 'EE' => [ // Estonia + 'swap_currency_symbol' => true, + ], + 'ES' => [ // Spain + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'FI' => [ // Finland + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'FR' => [ // France + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'GR' => [ // Greece + 'swap_currency_symbol' => true, + ], + 'HR' => [ // Croatia + 'swap_currency_symbol' => true, + ], + 'HU' => [ // Hungary + 'swap_currency_symbol' => true, + ], + 'GL' => [ + 'swap_postal_code' => true, + ], + 'IE' => [ // Ireland + 'thousand_separator' => ',', + 'decimal_separator' => '.', + ], + 'IL' => [ + 'swap_postal_code' => true, + ], + 'IS' => [ // Iceland + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'IT' => [ // Italy + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'LT' => [ // Lithuania + 'swap_currency_symbol' => true, + ], + 'LU' => [ + 'swap_postal_code' => true, + ], + 'MY' => [ + 'swap_postal_code' => true, + ], + 'MX' => [ + 'swap_postal_code' => true, + ], + 'NL' => [ + 'swap_postal_code' => true, + ], + 'PL' => [ // Poland + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'PT' => [ // Portugal + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'RO' => [ // Romania + 'swap_currency_symbol' => true, + ], + 'SE' => [ // Sweden + 'swap_postal_code' => true, + 'swap_currency_symbol' => true, + ], + 'SI' => [ // Slovenia + 'swap_currency_symbol' => true, + ], + 'SK' => [ // Slovakia + 'swap_currency_symbol' => true, + ], + 'UY' => [ + 'swap_postal_code' => true, + ], + ]; + + foreach ($countries as $code => $data) { + $country = Country::where('iso_3166_2', '=', $code)->first(); + if (isset($data['swap_postal_code'])) { + $country->swap_postal_code = true; + } + if (isset($data['swap_currency_symbol'])) { + $country->swap_currency_symbol = true; + } + if (isset($data['thousand_separator'])) { + $country->thousand_separator = $data['thousand_separator']; + } + if (isset($data['decimal_separator'])) { + $country->decimal_separator = $data['decimal_separator']; + } + $country->save(); + } + } + +} From 98793fd74ac3a4f5f01f920bded032d2a75aae58 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 19:40:24 +1100 Subject: [PATCH 10/15] merge fixes --- database/seeds/PaymentLibrariesSeeder.php | 340 ---------------------- 1 file changed, 340 deletions(-) diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index 8710357a36c2..654ad9fe0e43 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -14,16 +14,6 @@ class PaymentLibrariesSeeder extends Seeder { Eloquent::unguard(); - $this->createGateways(); - $this->createPaymentTerms(); - $this->createDateFormats(); - $this->createDatetimeFormats(); - $this->createInvoiceDesigns(); - $this->updateLocalization(); - } - - private function createGateways() { - $gateways = [ ['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], @@ -71,334 +61,4 @@ class PaymentLibrariesSeeder extends Seeder } } - - private function createPaymentTerms() { - - $paymentTerms = [ - ['num_days' => -1, 'name' => 'Net 0'], - ]; - - foreach ($paymentTerms as $paymentTerm) { - if (!DB::table('payment_terms')->where('name', '=', $paymentTerm['name'])->get()) { - PaymentTerm::create($paymentTerm); - } - } - - $currencies = [ - ['name' => 'US Dollar', 'code' => 'USD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Pound Sterling', 'code' => 'GBP', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Euro', 'code' => 'EUR', 'symbol' => '€', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'South African Rand', 'code' => 'ZAR', 'symbol' => 'R', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Danish Krone', 'code' => 'DKK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Israeli Shekel', 'code' => 'ILS', 'symbol' => 'NIS ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Swedish Krona', 'code' => 'SEK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Kenyan Shilling', 'code' => 'KES', 'symbol' => 'KSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Canadian Dollar', 'code' => 'CAD', 'symbol' => 'C$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Philippine Peso', 'code' => 'PHP', 'symbol' => 'P ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Indian Rupee', 'code' => 'INR', 'symbol' => 'Rs. ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Australian Dollar', 'code' => 'AUD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Singapore Dollar', 'code' => 'SGD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Norske Kroner', 'code' => 'NOK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'New Zealand Dollar', 'code' => 'NZD', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Vietnamese Dong', 'code' => 'VND', 'symbol' => '', 'precision' => '0', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Swiss Franc', 'code' => 'CHF', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '\'', 'decimal_separator' => '.'], - ['name' => 'Guatemalan Quetzal', 'code' => 'GTQ', 'symbol' => 'Q', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Malaysian Ringgit', 'code' => 'MYR', 'symbol' => 'RM', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Brazilian Real', 'code' => 'BRL', 'symbol' => 'R$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Thai Baht', 'code' => 'THB', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Nigerian Naira', 'code' => 'NGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Argentine Peso', 'code' => 'ARS', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Bangladeshi Taka', 'code' => 'BDT', 'symbol' => 'Tk', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'United Arab Emirates Dirham', 'code' => 'AED', 'symbol' => 'DH ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Hong Kong Dollar', 'code' => 'HKD', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Indonesian Rupiah', 'code' => 'IDR', 'symbol' => 'Rp', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Mexican Peso', 'code' => 'MXN', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Egyptian Pound', 'code' => 'EGP', 'symbol' => 'E£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Colombian Peso', 'code' => 'COP', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'West African Franc', 'code' => 'XOF', 'symbol' => 'CFA ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Chinese Renminbi', 'code' => 'CNY', 'symbol' => 'RMB ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Rwandan Franc', 'code' => 'RWF', 'symbol' => 'RF ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Tanzanian Shilling', 'code' => 'TZS', 'symbol' => 'TSh ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Netherlands Antillean Guilder', 'code' => 'ANG', 'symbol' => '', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Trinidad and Tobago Dollar', 'code' => 'TTD', 'symbol' => 'TT$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'East Caribbean Dollar', 'code' => 'XCD', 'symbol' => 'EC$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Ghanaian Cedi', 'code' => 'GHS', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ['name' => 'Bulgarian Lev', 'code' => 'BGN', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'], - ['name' => 'Aruban Florin', 'code' => 'AWG', 'symbol' => 'Afl. ', 'precision' => '2', 'thousand_separator' => ' ', 'decimal_separator' => '.'], - ['name' => 'Turkish Lira', 'code' => 'TRY', 'symbol' => 'TL ', 'precision' => '2', 'thousand_separator' => '.', 'decimal_separator' => ','], - ['name' => 'Romanian New Leu', 'code' => 'RON', 'symbol' => '', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'], - ]; - - foreach ($currencies as $currency) { - $record = Currency::whereCode($currency['code'])->first(); - if ($record) { - $record->name = $currency['name']; - $record->symbol = $currency['symbol']; - $record->thousand_separator = $currency['thousand_separator']; - $record->decimal_separator = $currency['decimal_separator']; - $record->save(); - } else { - Currency::create($currency); - } - } - } - - private function createDateFormats() { - - $formats = [ - ['format' => 'd/M/Y', 'picker_format' => 'dd/M/yyyy', 'label' => '10/Mar/2013'], - ['format' => 'd-M-Y', 'picker_format' => 'dd-M-yyyy', 'label' => '10-Mar-2013'], - ['format' => 'd/F/Y', 'picker_format' => 'dd/MM/yyyy', 'label' => '10/March/2013'], - ['format' => 'd-F-Y', 'picker_format' => 'dd-MM-yyyy', 'label' => '10-March-2013'], - ['format' => 'M j, Y', 'picker_format' => 'M d, yyyy', 'label' => 'Mar 10, 2013'], - ['format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'label' => 'March 10, 2013'], - ['format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10, 2013'], - ['format' => 'Y-m-d', 'picker_format' => 'yyyy-mm-dd', 'label' => '2013-03-10'], - ['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'label' => '20-03-2013'], - ['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'label' => '03/20/2013'] - ]; - - foreach ($formats as $format) { - $record = DateFormat::whereLabel($format['label'])->first(); - if ($record) { - $record->format = $format['format']; - $record->picker_format = $format['picker_format']; - $record->save(); - } else { - DateFormat::create($format); - } - } - } - - private function createDatetimeFormats() { - - $formats = [ - [ - 'format' => 'd/M/Y g:i a', - 'format_moment' => 'DD/MMM/YYYY h:mm:ss a', - 'label' => '10/Mar/2013' - ], - [ - 'format' => 'd-M-Y g:i a', - 'format_moment' => 'DD-MMM-YYYY h:mm:ss a', - 'label' => '10-Mar-2013' - ], - [ - 'format' => 'd/F/Y g:i a', - 'format_moment' => 'DD/MMMM/YYYY h:mm:ss a', - 'label' => '10/March/2013' - ], - [ - 'format' => 'd-F-Y g:i a', - 'format_moment' => 'DD-MMMM-YYYY h:mm:ss a', - 'label' => '10-March-2013' - ], - [ - 'format' => 'M j, Y g:i a', - 'format_moment' => 'MMM D, YYYY h:mm:ss a', - 'label' => 'Mar 10, 2013 6:15 pm' - ], - [ - 'format' => 'F j, Y g:i a', - 'format_moment' => 'MMMM D, YYYY h:mm:ss a', - 'label' => 'March 10, 2013 6:15 pm' - ], - [ - 'format' => 'D M jS, Y g:i a', - 'format_moment' => 'ddd MMM Do, YYYY h:mm:ss a', - 'label' => 'Mon March 10th, 2013 6:15 pm' - ], - [ - 'format' => 'Y-m-d g:i a', - 'format_moment' => 'YYYY-MMM-DD h:mm:ss a', - 'label' => '2013-03-10 6:15 pm' - ], - [ - 'format' => 'd-m-Y g:i a', - 'format_moment' => 'DD-MM-YYYY h:mm:ss a', - 'label' => '20-03-2013 6:15 pm' - ], - [ - 'format' => 'm/d/Y g:i a', - 'format_moment' => 'MM/DD/YYYY h:mm:ss a', - 'label' => '03/20/2013 6:15 pm' - ] - ]; - - foreach ($formats as $format) { - $record = DatetimeFormat::whereLabel($format['label'])->first(); - if ($record) { - $record->format = $format['format']; - $record->format_moment = $format['format_moment']; - $record->save(); - } else { - DatetimeFormat::create($format); - } - } - } - - private function createInvoiceDesigns() { - $designs = [ - 'Clean', - 'Bold', - 'Modern', - 'Plain', - 'Business', - 'Creative', - 'Elegant', - 'Hipster', - 'Playful', - 'Photo', - ]; - - for ($i=0; $ifirst(); - if (!$record) { - $record = new InvoiceDesign; - $record->id = $i + 1; - $record->name = $design; - } - $record->pdfmake = $pdfmake; - $record->save(); - } - } - } - } - - private function updateLocalization() { - // Source: http://www.bitboost.com/ref/international-address-formats.html - // Source: https://en.wikipedia.org/wiki/Linguistic_issues_concerning_the_euro - $countries = [ - 'AR' => [ - 'swap_postal_code' => true, - ], - 'AT' => [ // Austria - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'BE' => [ - 'swap_postal_code' => true, - ], - 'BG' => [ // Belgium - 'swap_currency_symbol' => true, - ], - 'CH' => [ - 'swap_postal_code' => true, - ], - 'CZ' => [ // Czech Republic - 'swap_currency_symbol' => true, - ], - 'DE' => [ // Germany - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'DK' => [ - 'swap_postal_code' => true, - ], - 'EE' => [ // Estonia - 'swap_currency_symbol' => true, - ], - 'ES' => [ // Spain - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'FI' => [ // Finland - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'FR' => [ // France - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'GR' => [ // Greece - 'swap_currency_symbol' => true, - ], - 'HR' => [ // Croatia - 'swap_currency_symbol' => true, - ], - 'HU' => [ // Hungary - 'swap_currency_symbol' => true, - ], - 'GL' => [ - 'swap_postal_code' => true, - ], - 'IE' => [ // Ireland - 'thousand_separator' => ',', - 'decimal_separator' => '.', - ], - 'IL' => [ - 'swap_postal_code' => true, - ], - 'IS' => [ // Iceland - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'IT' => [ // Italy - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'LT' => [ // Lithuania - 'swap_currency_symbol' => true, - ], - 'LU' => [ - 'swap_postal_code' => true, - ], - 'MY' => [ - 'swap_postal_code' => true, - ], - 'MX' => [ - 'swap_postal_code' => true, - ], - 'NL' => [ - 'swap_postal_code' => true, - ], - 'PL' => [ // Poland - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'PT' => [ // Portugal - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'RO' => [ // Romania - 'swap_currency_symbol' => true, - ], - 'SE' => [ // Sweden - 'swap_postal_code' => true, - 'swap_currency_symbol' => true, - ], - 'SI' => [ // Slovenia - 'swap_currency_symbol' => true, - ], - 'SK' => [ // Slovakia - 'swap_currency_symbol' => true, - ], - 'UY' => [ - 'swap_postal_code' => true, - ], - ]; - - foreach ($countries as $code => $data) { - $country = Country::where('iso_3166_2', '=', $code)->first(); - if (isset($data['swap_postal_code'])) { - $country->swap_postal_code = true; - } - if (isset($data['swap_currency_symbol'])) { - $country->swap_currency_symbol = true; - } - if (isset($data['thousand_separator'])) { - $country->thousand_separator = $data['thousand_separator']; - } - if (isset($data['decimal_separator'])) { - $country->decimal_separator = $data['decimal_separator']; - } - $country->save(); - } - } - } From 5462e4276a81fa175cffdbc04d5f7bd49be86b77 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 20:10:25 +1100 Subject: [PATCH 11/15] changing the way validation works --- app/Http/Controllers/AccountApiController.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index f36252bc8d16..8326d2821c81 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -34,8 +34,26 @@ class AccountApiController extends BaseAPIController $this->accountRepo = $accountRepo; } - public function register(RegisterRequest $request) + public function register(Request $request) { + $validator = Validator::make($request->all(), [ + 'email' => 'required|unique:users', + 'first_name' => 'required', + 'last_name' => 'required', + 'password' => 'required', + ]); + + if ($validator->fails()) { + + foreach($validator->messages->all() as $message) + { + return $this->errorResponse(['message'=>$message]); + } + + + } + + $account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password); $user = $account->users()->first(); From aa8b160661ef38de1a4502b298d4962f6ae844bb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 20:11:45 +1100 Subject: [PATCH 12/15] changing the way validation works --- app/Http/Controllers/AccountApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 8326d2821c81..8e81011d9c71 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -45,7 +45,7 @@ class AccountApiController extends BaseAPIController if ($validator->fails()) { - foreach($validator->messages->all() as $message) + foreach($validator->errors()->all() as $message) { return $this->errorResponse(['message'=>$message]); } From 3a657e511aa3af451d4fb09a52e76e5889126f43 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 20:18:19 +1100 Subject: [PATCH 13/15] changing the way validation works --- app/Http/Controllers/AccountApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 8e81011d9c71..4ac5d99018f9 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -47,7 +47,7 @@ class AccountApiController extends BaseAPIController foreach($validator->errors()->all() as $message) { - return $this->errorResponse(['message'=>$message]); + return $this->errorResponse(['message'=>$message],400); } From 83de2a279ed799ab7a775a239e3c13e9db193c7a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 20:27:00 +1100 Subject: [PATCH 14/15] changing the way validation works --- app/Http/Controllers/AccountApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 4ac5d99018f9..8535e572e5b0 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -47,7 +47,7 @@ class AccountApiController extends BaseAPIController foreach($validator->errors()->all() as $message) { - return $this->errorResponse(['message'=>$message],400); + return $this->errorResponse(['message'=>$message],404); } From f6b2595936543b37aab57a1fa65324be032094a0 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 20:28:14 +1100 Subject: [PATCH 15/15] changing the way validation works --- app/Http/Controllers/AccountApiController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 8535e572e5b0..4ac5d99018f9 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -47,7 +47,7 @@ class AccountApiController extends BaseAPIController foreach($validator->errors()->all() as $message) { - return $this->errorResponse(['message'=>$message],404); + return $this->errorResponse(['message'=>$message],400); }