From 43cd7910f8f4083d59a29dfe13158a8923470fc9 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 9 Mar 2016 20:34:45 +0200 Subject: [PATCH 01/42] Merge #763 --- resources/lang/de/texts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/de/texts.php b/resources/lang/de/texts.php index 3c2ec0580feb..80289bfa29f0 100644 --- a/resources/lang/de/texts.php +++ b/resources/lang/de/texts.php @@ -1121,7 +1121,7 @@ return array( 'all_pages_header' => 'Show header on', 'all_pages_footer' => 'Show footer on', 'invoice_currency' => 'Rechnungs-Währung', - 'enable_https' => 'Wir empfehlen dringend HTTPS zu verwendne, um Kreditkarten online zu akzeptieren.', + 'enable_https' => 'Wir empfehlen dringend HTTPS zu verwenden, um Kreditkarten online zu akzeptieren.', 'quote_issued_to' => 'Quote issued to', 'show_currency_code' => 'Währungscode', 'trial_message' => 'Your account will receive a free two week trial of our pro plan.', From b13e79ad8577e5309532658776e8beaef900abbd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 9 Mar 2016 20:42:02 +0200 Subject: [PATCH 02/42] Fix for Zapier notifications --- app/Listeners/SubscriptionListener.php | 38 ++++++-------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 14d0bb0016c3..cac483b4d309 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -24,53 +24,33 @@ 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); From 782537812544ed43519e96ad68c2aac8452fc38a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 11 Mar 2016 00:29:07 +0200 Subject: [PATCH 03/42] Fix for approving quotes --- app/Services/InvoiceService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php index 839c6fa6adf3..c5d6f258e02c 100644 --- a/app/Services/InvoiceService.php +++ b/app/Services/InvoiceService.php @@ -79,7 +79,8 @@ class InvoiceService extends BaseService public function approveQuote($quote, $invitation = null) { - $account = Auth::user()->account; + $account = $quote->account; + if (!$quote->is_quote || $quote->quote_invoice_id) { return null; } From b16986451026aad1e7b8888c0cb56c03436ddc89 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 19:36:09 +1100 Subject: [PATCH 04/42] 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 05/42] 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 06/42] 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 07/42] 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 08/42] 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 09/42] 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 10/42] 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 11/42] 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 12/42] 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); } From 7d2cf9770b3533e1031b7d7d9f57e6e0cfcc8cc3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 21:54:31 +1100 Subject: [PATCH 13/42] fixing validation --- app/Http/Controllers/AccountApiController.php | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 4ac5d99018f9..6b9ee78f04b1 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -34,26 +34,9 @@ class AccountApiController extends BaseAPIController $this->accountRepo = $accountRepo; } - public function register(Request $request) + public function register(RegisterRequest $request) { - $validator = Validator::make($request->all(), [ - 'email' => 'required|unique:users', - 'first_name' => 'required', - 'last_name' => 'required', - 'password' => 'required', - ]); - - if ($validator->fails()) { - - foreach($validator->errors()->all() as $message) - { - return $this->errorResponse(['message'=>$message],400); - } - - - } - - + $account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password); $user = $account->users()->first(); From 94a73f92ad28012ae41aed5117519a6dccdb2846 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:39:20 +1100 Subject: [PATCH 14/42] re-working validation --- app/Http/Controllers/AccountApiController.php | 2 +- app/Http/Requests/RegisterRequest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 6b9ee78f04b1..a4d0e8aa3ca7 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -36,7 +36,7 @@ class AccountApiController extends BaseAPIController public function register(RegisterRequest $request) { - + $account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password); $user = $account->users()->first(); diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 8709d42cc0a0..1dae2709498c 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -3,6 +3,8 @@ use Auth; use App\Http\Requests\Request; use Illuminate\Validation\Factory; +use App\Libraries\Utils; +use Response; class RegisterRequest extends Request { @@ -32,4 +34,15 @@ class RegisterRequest extends Request return $rules; } + + public function response(array $errors) + { + //return parent::response($errors); // TODO: Change the autogenerated stub + + $error['error'] = $errors[0]; + $error = json_encode($error, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); + + return Response::make($error, 400, $headers); + } } From 35dfe66de2d86c20432e4729f6db94bae5a84b87 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:41:08 +1100 Subject: [PATCH 15/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 1dae2709498c..608e15cd25f2 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -39,10 +39,12 @@ class RegisterRequest extends Request { //return parent::response($errors); // TODO: Change the autogenerated stub - $error['error'] = $errors[0]; - $error = json_encode($error, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(); + foreach($errors as $err) { + $error['error'] = $err; + $error = json_encode($error, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); - return Response::make($error, 400, $headers); + return Response::make($error, 400, $headers); + } } } From c8a46f6bd9820cc3065b0b4563fc018d247d17fc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:46:59 +1100 Subject: [PATCH 16/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 608e15cd25f2..bf9f7b61f7a5 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -2,6 +2,7 @@ use Auth; use App\Http\Requests\Request; +use Illuminate\Support\Facades\Log; use Illuminate\Validation\Factory; use App\Libraries\Utils; use Response; @@ -39,6 +40,8 @@ class RegisterRequest extends Request { //return parent::response($errors); // TODO: Change the autogenerated stub + Log::info($errors); + foreach($errors as $err) { $error['error'] = $err; $error = json_encode($error, JSON_PRETTY_PRINT); From fd173889eba15e8c28fb3e6ddf7ddbf07045bbab Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:56:44 +1100 Subject: [PATCH 17/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index bf9f7b61f7a5..7a8a0f9329e6 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -38,16 +38,18 @@ class RegisterRequest extends Request public function response(array $errors) { - //return parent::response($errors); // TODO: Change the autogenerated stub + return parent::response($errors); // TODO: Change the autogenerated stub Log::info($errors); - - foreach($errors as $err) { - $error['error'] = $err; - $error = json_encode($error, JSON_PRETTY_PRINT); - $headers = Utils::getApiHeaders(); - return Response::make($error, 400, $headers); + foreach($errors as $err) { + foreach ($err as $key => $value) { + $error['error'] = $value; + $error = json_encode($error, JSON_PRETTY_PRINT); + $headers = Utils::getApiHeaders(); + + return Response::make($error, 400, $headers); + } } } } From b244f8034b0472bbf255163b7c1a03ce8a5d129c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:58:05 +1100 Subject: [PATCH 18/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 7a8a0f9329e6..338b9b923dab 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -38,7 +38,7 @@ class RegisterRequest extends Request public function response(array $errors) { - return parent::response($errors); // TODO: Change the autogenerated stub + // return parent::response($errors); // TODO: Change the autogenerated stub Log::info($errors); From 7c054c5e9b4c2a98bd95a952982cf8988fc7e649 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 22:59:01 +1100 Subject: [PATCH 19/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 338b9b923dab..3ecebb306c9d 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -44,6 +44,11 @@ class RegisterRequest extends Request foreach($errors as $err) { foreach ($err as $key => $value) { + + Log::info($err); + Log::info($key); + Log::info($value); + $error['error'] = $value; $error = json_encode($error, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); From 4bc07aacbf9817c2d194967bb43f3d03f4ef5e2f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:02:07 +1100 Subject: [PATCH 20/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 3ecebb306c9d..9c2c1a1423f9 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -49,7 +49,7 @@ class RegisterRequest extends Request Log::info($key); Log::info($value); - $error['error'] = $value; + $error['error'] = ['message'=>$value]; $error = json_encode($error, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); From 3d2daf9758977dbe6602f4600b0b4860f864a0a3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:04:27 +1100 Subject: [PATCH 21/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 9c2c1a1423f9..66dbe3914c3a 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -36,9 +36,12 @@ class RegisterRequest extends Request return $rules; } - public function response(array $errors) + public function response(Request $request, array $errors) { - // return parent::response($errors); // TODO: Change the autogenerated stub + // TODO: Change the autogenerated stub + + if(!isset($request->api_secret)) + return parent::response($errors); Log::info($errors); From 392024a0b923f733a037284102ceaab8c2919bd3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:06:26 +1100 Subject: [PATCH 22/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 66dbe3914c3a..a5808fc4ba54 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -14,6 +14,13 @@ class RegisterRequest extends Request * * @return bool */ + public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content) + { + parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content); + + $this->request = $request; + } + public function authorize() { return true; @@ -36,11 +43,10 @@ class RegisterRequest extends Request return $rules; } - public function response(Request $request, array $errors) + public function response(array $errors) { - // TODO: Change the autogenerated stub - if(!isset($request->api_secret)) + if(!isset($this->request->api_secret)) return parent::response($errors); Log::info($errors); From 00aa0624b84ac903ac71501209bd793d597a0ead Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:08:31 +1100 Subject: [PATCH 23/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index a5808fc4ba54..bba475b87843 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -43,7 +43,7 @@ class RegisterRequest extends Request return $rules; } - public function response(array $errors) + public function response($errors) { if(!isset($this->request->api_secret)) From e36298cd35963951a67e4e3cba0f0df28e07d3f7 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:09:11 +1100 Subject: [PATCH 24/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index bba475b87843..a5808fc4ba54 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -43,7 +43,7 @@ class RegisterRequest extends Request return $rules; } - public function response($errors) + public function response(array $errors) { if(!isset($this->request->api_secret)) From b843bf008d179f8186a4727d0ebdb2f4cd8c0fd1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:10:15 +1100 Subject: [PATCH 25/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index a5808fc4ba54..0a02e01bc756 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -16,8 +16,6 @@ class RegisterRequest extends Request */ public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content) { - parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content); - $this->request = $request; } From f9853af70a5e4899ddefed7749116fb8b1b73eee Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:12:04 +1100 Subject: [PATCH 26/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 0a02e01bc756..a153396704b9 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -16,6 +16,12 @@ class RegisterRequest extends Request */ public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content) { + $this->query = $query; + $this->attributes = $attributes; + $this->cookies = $cookies; + $this->files = $files; + $this->server = $server; + $this->content = content; $this->request = $request; } From 15838765ffc0b126f68958bd72469f60c3942f70 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:14:08 +1100 Subject: [PATCH 27/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index a153396704b9..19c3edade426 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -16,12 +16,7 @@ class RegisterRequest extends Request */ public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content) { - $this->query = $query; - $this->attributes = $attributes; - $this->cookies = $cookies; - $this->files = $files; - $this->server = $server; - $this->content = content; + parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content); $this->request = $request; } @@ -49,7 +44,6 @@ class RegisterRequest extends Request public function response(array $errors) { - if(!isset($this->request->api_secret)) return parent::response($errors); From d7b6426aee258b73794328a340f67793b21d29d2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:20:56 +1100 Subject: [PATCH 28/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 19c3edade426..edc29fd90e41 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -14,11 +14,6 @@ class RegisterRequest extends Request * * @return bool */ - public function __construct(array $query, array $request, array $attributes, array $cookies, array $files, array $server, $content) - { - parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content); - $this->request = $request; - } public function authorize() { @@ -44,7 +39,9 @@ class RegisterRequest extends Request public function response(array $errors) { - if(!isset($this->request->api_secret)) + $request = $this->getRequest(); + + if(!isset($request->api_secret)) return parent::response($errors); Log::info($errors); @@ -64,4 +61,9 @@ class RegisterRequest extends Request } } } + + public function getRequest(\Illuminate\Http\Request $request) + { + return $request; + } } From c79509d04f6eb0b944e8d9760c8550a23ebcfc5d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:27:20 +1100 Subject: [PATCH 29/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index edc29fd90e41..91bd54f7de42 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,6 +15,11 @@ class RegisterRequest extends Request * @return bool */ + public function __construct(\Illuminate\Http\Request $request) + { + $this->request = $request; + } + public function authorize() { return true; @@ -39,9 +44,8 @@ class RegisterRequest extends Request public function response(array $errors) { - $request = $this->getRequest(); - if(!isset($request->api_secret)) + if(!isset($this->request->api_secret)) return parent::response($errors); Log::info($errors); @@ -62,8 +66,4 @@ class RegisterRequest extends Request } } - public function getRequest(\Illuminate\Http\Request $request) - { - return $request; - } } From b83ba5c7dceb8a4940cd1273b718d6049606919b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:28:33 +1100 Subject: [PATCH 30/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 91bd54f7de42..c72e6ad09217 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -45,6 +45,8 @@ class RegisterRequest extends Request public function response(array $errors) { + Log::info($this->request); + if(!isset($this->request->api_secret)) return parent::response($errors); From 584133734ea6169ff83b060a4779af2566d4f4ee Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:29:38 +1100 Subject: [PATCH 31/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index c72e6ad09217..d140839fd381 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -45,8 +45,9 @@ class RegisterRequest extends Request public function response(array $errors) { - Log::info($this->request); - + Log::info($this->request->api_secret); + Log::info($this->request->email); + if(!isset($this->request->api_secret)) return parent::response($errors); From 3d104400aa22ac3642c22f48e8b8499fdba3d0ad Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:31:15 +1100 Subject: [PATCH 32/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index d140839fd381..dbde21b1ab68 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,7 +15,7 @@ class RegisterRequest extends Request * @return bool */ - public function __construct(\Illuminate\Http\Request $request) + public function __construct(Request $request) { $this->request = $request; } @@ -47,7 +47,7 @@ class RegisterRequest extends Request Log::info($this->request->api_secret); Log::info($this->request->email); - + if(!isset($this->request->api_secret)) return parent::response($errors); From 13b425853eafe45680d82e0bcbaf5f10d702ff65 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:32:38 +1100 Subject: [PATCH 33/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index dbde21b1ab68..fa8200dfc429 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,10 +15,6 @@ class RegisterRequest extends Request * @return bool */ - public function __construct(Request $request) - { - $this->request = $request; - } public function authorize() { @@ -44,9 +40,10 @@ class RegisterRequest extends Request public function response(array $errors) { + $request = $this->getRequest(); - Log::info($this->request->api_secret); - Log::info($this->request->email); + Log::info($request->api_secret); + Log::info($request->email); if(!isset($this->request->api_secret)) return parent::response($errors); @@ -69,4 +66,10 @@ class RegisterRequest extends Request } } + public function getRequest(Request $request) + { + return $request; + } + + } From 3279b26bef6557fce054767f9af07e50a5a8b3d8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:34:42 +1100 Subject: [PATCH 34/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index fa8200dfc429..d06cd62c5436 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,6 +15,10 @@ class RegisterRequest extends Request * @return bool */ + public function __construct(Request $request) + { + $this->request = $request; + } public function authorize() { @@ -26,8 +30,10 @@ class RegisterRequest extends Request * * @return array */ - public function rules() + public function rules(Request $request) { + $this->request = $request; + $rules = [ 'email' => 'required|unique:users', 'first_name' => 'required', @@ -40,10 +46,9 @@ class RegisterRequest extends Request public function response(array $errors) { - $request = $this->getRequest(); - Log::info($request->api_secret); - Log::info($request->email); + Log::info($this->request->api_secret); + Log::info($this->request->email); if(!isset($this->request->api_secret)) return parent::response($errors); From a2ce87490ba975db233519c2a2df09ed3b8ed70d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:37:37 +1100 Subject: [PATCH 35/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index d06cd62c5436..6da65cf32593 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,11 +15,6 @@ class RegisterRequest extends Request * @return bool */ - public function __construct(Request $request) - { - $this->request = $request; - } - public function authorize() { return true; @@ -32,7 +27,7 @@ class RegisterRequest extends Request */ public function rules(Request $request) { - $this->request = $request; + $this->setRequest($request); $rules = [ 'email' => 'required|unique:users', @@ -46,11 +41,12 @@ class RegisterRequest extends Request public function response(array $errors) { + $request = $this->getRequest(); - Log::info($this->request->api_secret); - Log::info($this->request->email); + Log::info($request->api_secret); + Log::info($request->email); - if(!isset($this->request->api_secret)) + if(!isset($request->api_secret)) return parent::response($errors); Log::info($errors); @@ -71,9 +67,16 @@ class RegisterRequest extends Request } } - public function getRequest(Request $request) + + + public function setRequest($request) { - return $request; + $this->request = $request; + } + + public function getRequest() + { + return $this->request; } From 499a1561b19c2a1f641279d7cbe79169fb8d68a8 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:38:25 +1100 Subject: [PATCH 36/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 6da65cf32593..0d1ed7665986 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -1,7 +1,7 @@ Date: Sun, 13 Mar 2016 23:41:33 +1100 Subject: [PATCH 37/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 0d1ed7665986..550668a5dd78 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -15,6 +15,12 @@ class RegisterRequest extends Request * @return bool */ + public function __contstruct(Request $request) + { + $this->request = $request; + } + + public function authorize() { return true; @@ -25,9 +31,8 @@ class RegisterRequest extends Request * * @return array */ - public function rules(Request $request) + public function rules() { - $this->setRequest($request); $rules = [ 'email' => 'required|unique:users', @@ -41,7 +46,7 @@ class RegisterRequest extends Request public function response(array $errors) { - $request = $this->getRequest(); + $request = $this->request; Log::info($request->api_secret); Log::info($request->email); @@ -69,15 +74,4 @@ class RegisterRequest extends Request - public function setRequest($request) - { - $this->request = $request; - } - - public function getRequest() - { - return $this->request; - } - - } From 2b77af5abeec8c14e27e08898f007014e039ec66 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:43:39 +1100 Subject: [PATCH 38/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 28 ++++----------------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 550668a5dd78..89be776dd5c5 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -14,13 +14,6 @@ class RegisterRequest extends Request * * @return bool */ - - public function __contstruct(Request $request) - { - $this->request = $request; - } - - public function authorize() { return true; @@ -46,25 +39,12 @@ class RegisterRequest extends Request public function response(array $errors) { - $request = $this->request; - Log::info($request->api_secret); - Log::info($request->email); + foreach($errors as $error) { + foreach ($error as $key => $value) { - if(!isset($request->api_secret)) - return parent::response($errors); - - Log::info($errors); - - foreach($errors as $err) { - foreach ($err as $key => $value) { - - Log::info($err); - Log::info($key); - Log::info($value); - - $error['error'] = ['message'=>$value]; - $error = json_encode($error, JSON_PRETTY_PRINT); + $message['error'] = ['message'=>$value]; + $message = json_encode($message, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($error, 400, $headers); From ba3ca0dffc2a5bd63dd4f94738dfb23ba46257cd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:46:51 +1100 Subject: [PATCH 39/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 42 +++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 89be776dd5c5..83d098165dc6 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -1,7 +1,8 @@ req = $req; + + } + + public function authorize() { return true; @@ -40,11 +49,23 @@ class RegisterRequest extends Request public function response(array $errors) { - foreach($errors as $error) { - foreach ($error as $key => $value) { + Log::info($this->req->api_secret); + Log::info($this->req->email); - $message['error'] = ['message'=>$value]; - $message = json_encode($message, JSON_PRETTY_PRINT); + if(!isset($this->req->api_secret)) + return parent::response($errors); + + Log::info($errors); + + foreach($errors as $err) { + foreach ($err as $key => $value) { + + Log::info($err); + Log::info($key); + Log::info($value); + + $error['error'] = ['message'=>$value]; + $error = json_encode($error, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($error, 400, $headers); @@ -54,4 +75,15 @@ class RegisterRequest extends Request + public function setRequest($request) + { + $this->request = $request; + } + + public function getRequest() + { + return $this->request; + } + + } From 22f683152d67cd9ff347cf881afd4b12be6cbed6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:49:51 +1100 Subject: [PATCH 40/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 36 ++++++--------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 83d098165dc6..501f232082b0 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -19,7 +19,6 @@ class RegisterRequest extends Request public function __construct(InputRequest $req) { $this->req = $req; - } @@ -48,42 +47,21 @@ class RegisterRequest extends Request public function response(array $errors) { - - Log::info($this->req->api_secret); - Log::info($this->req->email); - + /* If the user is not validating from a mobile app - pass through parent::response*/ if(!isset($this->req->api_secret)) return parent::response($errors); - Log::info($errors); + /* If the user is validating from a mobile app - pass through first error string and return error*/ + foreach($errors as $error) { + foreach ($error as $key => $value) { - foreach($errors as $err) { - foreach ($err as $key => $value) { - - Log::info($err); - Log::info($key); - Log::info($value); - - $error['error'] = ['message'=>$value]; - $error = json_encode($error, JSON_PRETTY_PRINT); + $message['error'] = ['message'=>$value]; + $message = json_encode($error, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); - return Response::make($error, 400, $headers); + return Response::make($message, 400, $headers); } } } - - - public function setRequest($request) - { - $this->request = $request; - } - - public function getRequest() - { - return $this->request; - } - - } From 8d7a9a2d2918f640900d62d0b3a85d710d9fb9b4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:50:40 +1100 Subject: [PATCH 41/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 501f232082b0..60d046cb1851 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -56,7 +56,7 @@ class RegisterRequest extends Request foreach ($error as $key => $value) { $message['error'] = ['message'=>$value]; - $message = json_encode($error, JSON_PRETTY_PRINT); + $message = json_encode($message, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($message, 400, $headers); From d9346bfadf5109199e9ca4bbfc9cc9fd61c11e08 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 13 Mar 2016 23:52:02 +1100 Subject: [PATCH 42/42] re-working validation --- app/Http/Requests/RegisterRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Requests/RegisterRequest.php b/app/Http/Requests/RegisterRequest.php index 60d046cb1851..91a27556924c 100644 --- a/app/Http/Requests/RegisterRequest.php +++ b/app/Http/Requests/RegisterRequest.php @@ -47,11 +47,11 @@ class RegisterRequest extends Request public function response(array $errors) { - /* If the user is not validating from a mobile app - pass through parent::response*/ + /* If the user is not validating from a mobile app - pass through parent::response */ if(!isset($this->req->api_secret)) return parent::response($errors); - /* If the user is validating from a mobile app - pass through first error string and return error*/ + /* If the user is validating from a mobile app - pass through first error string and return error */ foreach($errors as $error) { foreach ($error as $key => $value) {