From 1eb83a2642d980e6ee9f582445db9d79b25efbec Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 30 Jan 2017 18:05:31 +0200 Subject: [PATCH] php-cs-fixer clean up --- app/Commands/Command.php | 1 - .../Commands/ChargeRenewalInvoices.php | 6 +- app/Console/Commands/CheckData.php | 9 +- app/Console/Commands/Inspire.php | 46 +- app/Console/Commands/MakeClass.php | 9 +- app/Console/Commands/MakeModule.php | 3 +- app/Console/Commands/PruneData.php | 2 +- app/Console/Commands/ResetData.php | 3 +- .../Commands/ResetInvoiceSchemaCounter.php | 2 +- .../Commands/SendRecurringInvoices.php | 2 +- app/Console/Commands/SendRenewalInvoices.php | 2 +- app/Console/Commands/TestOFX.php | 2 +- app/Constants.php | 13 +- app/Events/CreditWasArchived.php | 3 - app/Events/CreditWasCreated.php | 2 - app/Events/CreditWasDeleted.php | 7 +- app/Events/CreditWasRestored.php | 8 +- app/Events/ExpenseWasArchived.php | 1 - app/Events/ExpenseWasDeleted.php | 1 - app/Events/ExpenseWasRestored.php | 2 - app/Events/InvoiceInvitationWasEmailed.php | 3 - app/Events/InvoiceInvitationWasViewed.php | 6 +- app/Events/InvoiceWasArchived.php | 1 - app/Events/InvoiceWasCreated.php | 1 - app/Events/InvoiceWasRestored.php | 2 - app/Events/PaymentCompleted.php | 1 - app/Events/PaymentWasArchived.php | 1 - app/Events/PaymentWasCreated.php | 2 +- app/Events/PaymentWasDeleted.php | 4 +- app/Events/QuoteInvitationWasApproved.php | 1 - app/Events/QuoteInvitationWasEmailed.php | 1 - app/Events/QuoteInvitationWasViewed.php | 2 +- app/Events/QuoteWasArchived.php | 1 - app/Events/QuoteWasUpdated.php | 1 - app/Events/TaskWasArchived.php | 1 - app/Events/TaskWasCreated.php | 1 - app/Events/TaskWasDeleted.php | 1 - app/Events/TaskWasRestored.php | 2 - app/Events/TaskWasUpdated.php | 1 - app/Exceptions/Handler.php | 53 +- app/Handlers/InvoiceEventHandler.php | 70 +- app/Http/Controllers/AccountApiController.php | 47 +- app/Http/Controllers/AccountController.php | 36 +- .../Controllers/AccountGatewayController.php | 17 +- app/Http/Controllers/AppController.php | 8 +- app/Http/Controllers/Auth/AuthController.php | 4 +- .../Controllers/Auth/PasswordController.php | 1 - app/Http/Controllers/BaseAPIController.php | 7 +- app/Http/Controllers/BaseController.php | 2 +- app/Http/Controllers/BlueVineController.php | 134 +- app/Http/Controllers/BotController.php | 31 +- app/Http/Controllers/ClientApiController.php | 1 - .../ClientAuth/PasswordController.php | 2 +- app/Http/Controllers/ClientController.php | 12 +- .../Controllers/ClientPortalController.php | 125 +- app/Http/Controllers/DashboardController.php | 40 +- .../Controllers/DocumentAPIController.php | 9 +- app/Http/Controllers/DocumentController.php | 26 +- app/Http/Controllers/ExpenseApiController.php | 7 +- .../Controllers/ExpenseCategoryController.php | 1 - app/Http/Controllers/ExpenseController.php | 8 +- app/Http/Controllers/ExportController.php | 17 +- app/Http/Controllers/HomeController.php | 2 +- app/Http/Controllers/ImportController.php | 2 +- app/Http/Controllers/InvoiceApiController.php | 8 +- app/Http/Controllers/InvoiceController.php | 24 +- app/Http/Controllers/NinjaController.php | 6 +- .../Controllers/OnlinePaymentController.php | 19 +- app/Http/Controllers/PaymentApiController.php | 1 - app/Http/Controllers/PaymentController.php | 5 +- .../Controllers/PaymentTermController.php | 1 - app/Http/Controllers/ProjectController.php | 1 - app/Http/Controllers/QuoteApiController.php | 1 - app/Http/Controllers/QuoteController.php | 3 +- .../RecurringInvoiceController.php | 1 - app/Http/Controllers/TaskApiController.php | 2 - app/Http/Controllers/TaskController.php | 11 +- app/Http/Controllers/TokenController.php | 1 - app/Http/Controllers/UserApiController.php | 2 +- app/Http/Controllers/UserController.php | 8 +- app/Http/Controllers/VendorApiController.php | 1 + app/Http/Kernel.php | 54 +- app/Http/Middleware/ApiCheck.php | 8 +- app/Http/Middleware/PermissionsRequired.php | 2 +- .../Middleware/RedirectIfAuthenticated.php | 1 - app/Http/Middleware/StartupCheck.php | 6 +- app/Http/Requests/ClientRequest.php | 6 +- .../Requests/CreateBankAccountRequest.php | 4 +- app/Http/Requests/CreateDocumentRequest.php | 3 +- app/Http/Requests/CreateExpenseRequest.php | 2 +- app/Http/Requests/CreatePaymentAPIRequest.php | 7 +- app/Http/Requests/CreatePaymentRequest.php | 2 +- app/Http/Requests/CreateTaxRateRequest.php | 4 +- app/Http/Requests/CreditRequest.php | 7 +- app/Http/Requests/DocumentRequest.php | 7 +- app/Http/Requests/EntityRequest.php | 15 +- app/Http/Requests/ExpenseCategoryRequest.php | 5 +- app/Http/Requests/ExpenseRequest.php | 5 +- app/Http/Requests/InvoiceRequest.php | 5 +- app/Http/Requests/PaymentRequest.php | 7 +- app/Http/Requests/ProductRequest.php | 6 +- app/Http/Requests/ProjectRequest.php | 5 +- app/Http/Requests/RegisterRequest.php | 8 +- app/Http/Requests/Request.php | 8 +- .../Requests/SaveClientPortalSettings.php | 3 +- app/Http/Requests/SaveEmailSettings.php | 1 - app/Http/Requests/TaskRequest.php | 7 +- app/Http/Requests/TaxRateRequest.php | 7 +- app/Http/Requests/UpdateAccountRequest.php | 4 +- .../Requests/UpdateExpenseCategoryRequest.php | 2 +- app/Http/Requests/UpdateExpenseRequest.php | 2 +- app/Http/Requests/UpdatePaymentRequest.php | 1 - app/Http/Requests/UpdateProjectRequest.php | 2 +- app/Http/Requests/UpdateTaxRateRequest.php | 2 - app/Http/Requests/VendorRequest.php | 7 +- .../ViewComposers/AppLanguageComposer.php | 4 +- .../ClientPortalHeaderComposer.php | 4 +- .../ViewComposers/TranslationComposer.php | 2 +- app/Http/routes.php | 43 +- app/Includes/parsecsv.lib.php | 1433 +++++++++-------- app/Jobs/SendNotificationEmail.php | 1 - app/Jobs/SendPaymentEmail.php | 2 - app/Jobs/SendPushNotification.php | 1 - app/Libraries/CurlUtils.php | 3 +- app/Libraries/DateUtils.php | 1 - app/Libraries/HistoryUtils.php | 21 +- app/Libraries/OFX.php | 186 +-- app/Libraries/Utils.php | 29 +- app/Libraries/entity.php | 7 +- app/Libraries/lib_autolink.php | 541 +++---- app/Listeners/ActivityListener.php | 6 +- app/Listeners/AnalyticsListener.php | 2 +- app/Listeners/HandleUserLoggedIn.php | 27 +- app/Listeners/HandleUserSettingsChanged.php | 41 +- app/Listeners/HandleUserSignedUp.php | 2 +- app/Listeners/InvoiceListener.php | 2 +- app/Listeners/NotificationListener.php | 11 +- app/Listeners/SubscriptionListener.php | 39 +- app/Models/Account.php | 141 +- app/Models/AccountGateway.php | 12 +- app/Models/AccountGatewayToken.php | 1 - app/Models/BalanceAffecting.php | 2 +- app/Models/BankAccount.php | 1 - app/Models/BankSubaccount.php | 3 +- app/Models/Client.php | 15 +- app/Models/Company.php | 8 +- app/Models/Contact.php | 1 - app/Models/Country.php | 2 +- app/Models/Credit.php | 1 - app/Models/DatetimeFormat.php | 2 +- app/Models/Document.php | 75 +- app/Models/EntityModel.php | 15 +- app/Models/Expense.php | 5 +- app/Models/Industry.php | 2 +- app/Models/Invitation.php | 4 +- app/Models/Invoice.php | 105 +- app/Models/InvoiceItem.php | 1 - app/Models/Language.php | 2 +- app/Models/OwnedByClientTrait.php | 2 +- app/Models/Payment.php | 1 - app/Models/PaymentMethod.php | 11 +- app/Models/PaymentTerm.php | 1 - app/Models/Project.php | 1 - app/Models/SecurityCode.php | 1 - app/Models/Size.php | 4 +- app/Models/Task.php | 14 +- app/Models/TaxRate.php | 1 - app/Models/Traits/GeneratesNumbers.php | 6 +- app/Models/Traits/PresentsInvoice.php | 3 - app/Models/Traits/SendsEmails.php | 2 +- app/Models/User.php | 43 +- app/Models/Vendor.php | 2 +- app/Models/VendorContact.php | 1 + .../Datatables/AccountGatewayDatatable.php | 14 +- app/Ninja/Datatables/BankAccountDatatable.php | 2 - app/Ninja/Datatables/ClientDatatable.php | 9 +- app/Ninja/Datatables/CreditDatatable.php | 4 +- app/Ninja/Datatables/EntityDatatable.php | 4 +- .../Datatables/ExpenseCategoryDatatable.php | 6 +- app/Ninja/Datatables/ExpenseDatatable.php | 13 +- app/Ninja/Datatables/InvoiceDatatable.php | 8 +- app/Ninja/Datatables/PaymentDatatable.php | 12 +- app/Ninja/Datatables/ProductDatatable.php | 1 - app/Ninja/Datatables/ProjectDatatable.php | 11 +- .../Datatables/RecurringInvoiceDatatable.php | 1 - app/Ninja/Datatables/TaskDatatable.php | 10 +- app/Ninja/Datatables/TaxRateDatatable.php | 1 - app/Ninja/Datatables/TokenDatatable.php | 1 - app/Ninja/Datatables/UserDatatable.php | 4 +- app/Ninja/Datatables/VendorDatatable.php | 6 +- app/Ninja/Import/BaseTransformer.php | 1 - app/Ninja/Import/CSV/InvoiceTransformer.php | 2 +- .../Import/FreshBooks/InvoiceTransformer.php | 4 +- .../Import/FreshBooks/TaskTransformer.php | 2 +- .../Import/Harvest/ContactTransformer.php | 2 +- .../Import/Harvest/InvoiceTransformer.php | 2 +- .../Harvest/VendorContactTransformer.php | 2 +- .../Import/Hiveage/InvoiceTransformer.php | 2 +- .../Import/Invoiceable/InvoiceTransformer.php | 4 +- .../Import/Nutcache/InvoiceTransformer.php | 2 +- app/Ninja/Import/Nutcache/TaskTransformer.php | 2 +- app/Ninja/Import/Ronin/InvoiceTransformer.php | 4 +- app/Ninja/Import/Wave/InvoiceTransformer.php | 2 +- app/Ninja/Import/Wave/PaymentTransformer.php | 2 +- app/Ninja/Import/Zoho/InvoiceTransformer.php | 2 +- app/Ninja/Intents/BaseIntent.php | 17 +- app/Ninja/Intents/CreateInvoiceIntent.php | 4 +- app/Ninja/Intents/EmailInvoiceIntent.php | 2 +- app/Ninja/Intents/InvoiceIntent.php | 9 +- app/Ninja/Intents/ListProductsIntent.php | 3 +- app/Ninja/Intents/ProductIntent.php | 1 - app/Ninja/Intents/UpdateInvoiceIntent.php | 2 +- app/Ninja/Mailers/ContactMailer.php | 19 +- app/Ninja/Mailers/Mailer.php | 7 +- app/Ninja/Mailers/UserMailer.php | 4 +- app/Ninja/Notifications/PushFactory.php | 5 +- .../PaymentDrivers/BasePaymentDriver.php | 46 +- .../PaymentDrivers/BitPayPaymentDriver.php | 1 - .../PaymentDrivers/BraintreePaymentDriver.php | 6 +- .../CheckoutComPaymentDriver.php | 1 - .../PaymentDrivers/CustomPaymentDriver.php | 1 - .../PaymentDrivers/MolliePaymentDriver.php | 3 +- .../PayPalExpressPaymentDriver.php | 1 - .../PaymentDrivers/SkrillPaymentDriver.php | 2 +- .../PaymentDrivers/StripePaymentDriver.php | 24 +- .../TwoCheckoutPaymentDriver.php | 1 - .../PaymentDrivers/WePayPaymentDriver.php | 5 +- app/Ninja/Presenters/ClientPresenter.php | 5 +- app/Ninja/Presenters/CompanyPresenter.php | 5 +- app/Ninja/Presenters/ExpensePresenter.php | 1 - app/Ninja/Presenters/InvoicePresenter.php | 10 +- app/Ninja/Presenters/PaymentPresenter.php | 4 +- app/Ninja/Presenters/ProductPresenter.php | 1 - app/Ninja/Reports/AbstractReport.php | 5 +- app/Ninja/Reports/AgingReport.php | 3 +- app/Ninja/Reports/ClientReport.php | 2 +- app/Ninja/Reports/InvoiceDetailsReport.php | 2 +- app/Ninja/Reports/InvoiceReport.php | 9 +- app/Ninja/Reports/PaymentReport.php | 4 +- app/Ninja/Reports/ProductReport.php | 3 +- app/Ninja/Reports/TaxRateReport.php | 12 +- app/Ninja/Repositories/AccountRepository.php | 21 +- app/Ninja/Repositories/ActivityRepository.php | 1 - .../Repositories/BankAccountRepository.php | 2 +- app/Ninja/Repositories/BaseRepository.php | 6 +- app/Ninja/Repositories/ClientRepository.php | 11 +- app/Ninja/Repositories/ContactRepository.php | 2 +- app/Ninja/Repositories/CreditRepository.php | 12 +- .../Repositories/DashboardRepository.php | 23 +- app/Ninja/Repositories/DocumentRepository.php | 43 +- .../ExpenseCategoryRepository.php | 2 +- app/Ninja/Repositories/ExpenseRepository.php | 22 +- app/Ninja/Repositories/InvoiceRepository.php | 70 +- app/Ninja/Repositories/PaymentRepository.php | 2 +- app/Ninja/Repositories/ProductRepository.php | 6 +- app/Ninja/Repositories/ProjectRepository.php | 2 +- app/Ninja/Repositories/TaskRepository.php | 7 +- app/Ninja/Repositories/TokenRepository.php | 3 +- .../Repositories/VendorContactRepository.php | 2 +- app/Ninja/Repositories/VendorRepository.php | 2 +- .../Transformers/AccountTokenTransformer.php | 2 +- app/Ninja/Transformers/ClientTransformer.php | 2 +- app/Ninja/Transformers/CreditTransformer.php | 2 +- app/Ninja/Transformers/TaskTransformer.php | 1 - app/Ninja/Transformers/TaxRateTransformer.php | 2 +- app/Ninja/Transformers/UserTransformer.php | 2 +- .../Transformers/VendorContactTransformer.php | 2 +- app/Ninja/Transformers/VendorTransformer.php | 2 +- app/Policies/AccountGatewayPolicy.php | 6 +- app/Policies/BankAccountPolicy.php | 6 +- app/Policies/ClientPolicy.php | 4 +- app/Policies/CreditPolicy.php | 4 +- app/Policies/EntityPolicy.php | 21 +- app/Policies/ExpenseCategoryPolicy.php | 16 +- app/Policies/ExpensePolicy.php | 6 +- app/Policies/GenericEntityPolicy.php | 16 +- app/Policies/InvoicePolicy.php | 4 +- app/Policies/PaymentPolicy.php | 4 +- app/Policies/PaymentTermPolicy.php | 6 +- app/Policies/ProductPolicy.php | 1 - app/Policies/ProjectPolicy.php | 1 - app/Policies/QuotePolicy.php | 6 +- app/Policies/RecurringInvoicePolicy.php | 4 +- app/Policies/TaskPolicy.php | 6 +- app/Policies/TaxRatePolicy.php | 6 +- app/Policies/TokenPolicy.php | 9 +- app/Policies/VendorPolicy.php | 6 +- app/Providers/AppServiceProvider.php | 108 +- app/Providers/ComposerServiceProvider.php | 1 - app/Providers/ConfigServiceProvider.php | 29 +- app/Providers/EventServiceProvider.php | 58 +- app/Services/BaseService.php | 2 +- app/Services/CreditService.php | 2 +- app/Services/DatatableService.php | 10 +- app/Services/EmailService.php | 2 +- app/Services/ExpenseService.php | 4 +- app/Services/ImportService.php | 12 +- app/Services/InvoiceService.php | 10 +- app/Services/PaymentService.php | 15 +- app/Services/ProductService.php | 2 +- app/Services/PushService.php | 39 +- app/Services/RecurringInvoiceService.php | 3 +- app/Services/TaskService.php | 2 +- app/Services/TemplateService.php | 9 +- app/Services/VendorService.php | 5 +- database/factories/ModelFactory.php | 10 +- ...11_05_180133_confide_setup_users_table.php | 129 +- ...013_11_28_195703_setup_countries_table.php | 82 +- .../2014_02_13_151500_add_cascase_drops.php | 46 +- ...151817_add_support_for_invoice_designs.php | 105 +- ...2014_03_03_155556_add_phone_to_account.php | 56 +- ...2014_03_19_201454_add_language_support.php | 72 +- ..._03_20_200300_create_payment_libraries.php | 85 +- ...2014_03_23_051736_enable_forcing_jspdf.php | 50 +- ...0_add_sort_and_recommended_to_gateways.php | 78 +- .../2014_04_03_191105_add_pro_plan.php | 50 +- .../2014_04_17_100523_add_remember_token.php | 50 +- .../2014_04_17_145108_add_custom_fields.php | 88 +- ...014_04_23_170909_add_products_settings.php | 58 +- ...014_04_29_174315_add_advanced_settings.php | 63 +- .../2014_05_17_175626_add_quotes.php | 58 +- ...epted_credit_cards_to_account_gateways.php | 50 +- .../2014_07_13_142654_one_click_install.php | 84 +- ...4_07_17_205900_support_hiding_quantity.php | 98 +- .../2014_07_24_171214_add_zapier_support.php | 56 +- ...14_10_01_141248_add_company_vat_number.php | 64 +- ...4_10_05_141856_track_last_seen_message.php | 72 +- .../2014_10_06_103529_add_timesheets.php | 62 +- ..._10_06_195330_add_invoice_design_table.php | 92 +- ..._13_054100_add_invoice_number_settings.php | 88 +- ...14_10_14_225227_add_danish_translation.php | 40 +- .../2014_10_22_174452_add_affiliate_price.php | 60 +- ...014_10_30_184126_add_company_id_number.php | 64 +- ...1_04_200406_allow_null_client_currency.php | 42 +- .../2014_12_03_154119_add_discount_type.php | 50 +- .../2015_02_12_102940_add_email_templates.php | 42 +- ...015_02_17_131714_support_token_billing.php | 47 +- .../2015_02_27_081836_add_invoice_footer.php | 48 +- .../2015_03_03_140259_add_tokens.php | 45 +- .../2015_03_09_151011_add_ip_to_activity.php | 46 +- ...174122_add_pdf_email_attachment_option.php | 50 +- ...30_100000_create_password_resets_table.php | 36 +- .../2015_04_12_093447_add_sv_language.php | 36 +- .../2015_04_13_100333_add_notify_approved.php | 42 +- ..._122647_add_partial_amount_to_invoices.php | 48 +- .../2015_05_21_184104_add_font_size.php | 42 +- .../2015_05_27_121828_add_tasks.php | 40 +- ...05_27_170808_add_custom_invoice_labels.php | 43 +- ...06_09_134208_add_has_tasks_to_invoices.php | 42 +- ...015_06_14_093410_enable_resuming_tasks.php | 43 +- ...015_06_14_173025_multi_company_support.php | 38 +- ...5_07_07_160257_support_locking_account.php | 48 +- .../2015_07_08_114333_simplify_tasks.php | 57 +- .../2015_07_19_081332_add_custom_design.php | 42 +- .../2015_07_27_183830_add_pdfmake_support.php | 42 +- .../2015_09_10_185135_add_reminder_emails.php | 36 +- ..._27_180214_add_is_system_to_activities.php | 48 +- ...5_10_29_133747_add_default_quote_terms.php | 42 +- .../2015_11_01_080417_encrypt_tokens.php | 37 +- ...3_181318_improve_currency_localization.php | 36 +- ...015_12_27_154513_add_reminder_settings.php | 36 +- .../2015_12_30_042035_add_client_view_css.php | 36 +- .../2016_01_18_195351_add_bank_accounts.php | 43 +- ...2016_01_24_112646_add_bank_subaccounts.php | 51 +- ..._01_27_173015_add_header_footer_option.php | 61 +- ...135956_add_source_currency_to_expenses.php | 4 +- .../2016_02_25_152948_add_client_password.php | 76 +- ...02_28_081424_add_custom_invoice_fields.php | 8 +- ...2016_03_14_066181_add_user_permissions.php | 4 +- ...214710_add_support_three_decimal_taxes.php | 51 +- .../2016_03_22_168362_add_documents.php | 112 +- ...3_23_215049_support_multiple_tax_rates.php | 102 +- .../2016_04_16_103943_enterprise_plan.php | 58 +- .../2016_04_18_174135_add_page_size.php | 5 +- .../2016_04_23_182223_payments_changes.php | 37 +- ...5_add_swap_currency_symbol_to_currency.php | 12 +- ..._05_18_085739_add_invoice_type_support.php | 16 +- .../2016_05_24_164847_wepay_ach.php | 21 +- .../2016_07_08_083802_support_new_pricing.php | 6 +- .../2016_07_13_083821_add_buy_now_buttons.php | 18 +- ...2016_08_10_184027_add_support_for_bots.php | 25 +- ...2016_09_05_150625_create_gateway_types.php | 18 +- ...10_20_191150_add_expense_to_activities.php | 18 +- ...016_11_03_113316_add_invoice_signature.php | 30 +- .../2016_11_03_161149_add_bluevine_fields.php | 45 +- .../2016_11_28_092904_add_task_projects.php | 38 +- ...016_12_13_113955_add_pro_plan_discount.php | 6 +- .../2017_01_01_214241_add_inclusive_taxes.php | 54 +- database/seeds/BanksSeeder.php | 2 +- database/seeds/ConstantsSeeder.php | 328 ++-- database/seeds/CountriesSeeder.php | 7 +- database/seeds/CurrenciesSeeder.php | 2 +- database/seeds/GatewayTypesSeeder.php | 1 - database/seeds/IndustrySeeder.php | 62 +- database/seeds/InvoiceDesignsSeeder.php | 1 - database/seeds/InvoiceStatusSeeder.php | 3 +- database/seeds/PaymentLibrariesSeeder.php | 1 - database/seeds/PaymentTermsSeeder.php | 1 - database/seeds/PaymentTypesSeeder.php | 3 +- database/seeds/UserTableSeeder.php | 11 +- 400 files changed, 4676 insertions(+), 4914 deletions(-) diff --git a/app/Commands/Command.php b/app/Commands/Command.php index d6a8d61150..fa514df086 100644 --- a/app/Commands/Command.php +++ b/app/Commands/Command.php @@ -2,5 +2,4 @@ abstract class Command { - } diff --git a/app/Console/Commands/ChargeRenewalInvoices.php b/app/Console/Commands/ChargeRenewalInvoices.php index df3ee079a9..9e3c385862 100644 --- a/app/Console/Commands/ChargeRenewalInvoices.php +++ b/app/Console/Commands/ChargeRenewalInvoices.php @@ -71,17 +71,17 @@ class ChargeRenewalInvoices extends Command // check if account has switched to free since the invoice was created $account = Account::find($invoice->client->public_id); - if ( ! $account) { + if (! $account) { continue; } $company = $account->company; - if ( ! $company->plan || $company->plan == PLAN_FREE) { + if (! $company->plan || $company->plan == PLAN_FREE) { continue; } $this->info("Charging invoice {$invoice->invoice_number}"); - if ( ! $this->paymentService->autoBillInvoice($invoice)) { + if (! $this->paymentService->autoBillInvoice($invoice)) { $this->info('Failed to auto-bill, emailing invoice'); $this->mailer->sendInvoice($invoice); } diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 59e49333a7..2af7aed119 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -41,7 +41,8 @@ Options: /** * Class CheckData */ -class CheckData extends Command { +class CheckData extends Command +{ /** * @var string @@ -250,7 +251,6 @@ class CheckData extends Command { //$this->logMessage(var_dump($activities)); foreach ($activities as $activity) { - $activityFix = false; if ($activity->invoice_id) { @@ -336,7 +336,7 @@ class CheckData extends Command { $foundProblem = true; $clientFix -= $activity->adjustment; $activityFix = 0; - } else if ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) { + } elseif ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) { $this->logMessage("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}"); $foundProblem = true; $clientFix -= $activity->adjustment; @@ -350,7 +350,7 @@ class CheckData extends Command { $clientFix += $lastBalance - $activity->balance; $activityFix = 0; } - } else if ($activity->activity_type_id == ACTIVITY_TYPE_DELETE_PAYMENT) { + } elseif ($activity->activity_type_id == ACTIVITY_TYPE_DELETE_PAYMENT) { // **Fix for deleting payment after deleting invoice** if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) { $this->logMessage("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}"); @@ -423,5 +423,4 @@ class CheckData extends Command { ['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null], ]; } - } diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php index 8909799ec7..76966afbe9 100644 --- a/app/Console/Commands/Inspire.php +++ b/app/Console/Commands/Inspire.php @@ -6,30 +6,30 @@ use Illuminate\Foundation\Inspiring; /** * Class Inspire */ -class Inspire extends Command { +class Inspire extends Command +{ - /** - * The console command name. - * - * @var string - */ - protected $name = 'inspire'; + /** + * The console command name. + * + * @var string + */ + protected $name = 'inspire'; - /** - * The console command description. - * - * @var string - */ - protected $description = 'Display an inspiring quote'; - - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); - } + /** + * The console command description. + * + * @var string + */ + protected $description = 'Display an inspiring quote'; + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL); + } } diff --git a/app/Console/Commands/MakeClass.php b/app/Console/Commands/MakeClass.php index 83b99fa62b..b8290fce67 100644 --- a/app/Console/Commands/MakeClass.php +++ b/app/Console/Commands/MakeClass.php @@ -98,7 +98,7 @@ class MakeClass extends GeneratorCommand $str = ''; foreach ($fields as $field) { - if ( ! $field) { + if (! $field) { continue; } $field = explode(':', $field)[0]; @@ -120,7 +120,7 @@ class MakeClass extends GeneratorCommand $str = ''; foreach ($fields as $field) { - if ( ! $field) { + if (! $field) { continue; } $parts = explode(':', $field); @@ -144,7 +144,7 @@ class MakeClass extends GeneratorCommand $str = ''; foreach ($fields as $field) { - if ( ! $field) { + if (! $field) { continue; } $field = explode(':', $field)[0]; @@ -161,7 +161,7 @@ class MakeClass extends GeneratorCommand $str = ''; foreach ($fields as $field) { - if ( ! $field) { + if (! $field) { continue; } $field = explode(':', $field)[0]; @@ -169,6 +169,5 @@ class MakeClass extends GeneratorCommand } return rtrim($str); - } } diff --git a/app/Console/Commands/MakeModule.php b/app/Console/Commands/MakeModule.php index b96cb9ea76..572134815e 100644 --- a/app/Console/Commands/MakeModule.php +++ b/app/Console/Commands/MakeModule.php @@ -45,7 +45,7 @@ class MakeModule extends Command // convert 'name:string,description:text' to 'name,description' $fillable = explode(',', $fields); - $fillable = array_map(function($item) { + $fillable = array_map(function ($item) { return explode(':', $item)[0]; }, $fillable); $fillable = join(',', $fillable); @@ -94,5 +94,4 @@ class MakeModule extends Command array('migrate', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null), ); } - } diff --git a/app/Console/Commands/PruneData.php b/app/Console/Commands/PruneData.php index 1c04e1ab5f..3a1a892e08 100644 --- a/app/Console/Commands/PruneData.php +++ b/app/Console/Commands/PruneData.php @@ -42,7 +42,7 @@ class PruneData extends Command $results = DB::select($sql); foreach ($results as $result) { - $this->info("Deleting {$result->id}"); + $this->info("Deleting {$result->id}"); DB::table('accounts') ->where('id', '=', $result->id) ->delete(); diff --git a/app/Console/Commands/ResetData.php b/app/Console/Commands/ResetData.php index 2ab706fa1d..ddc00537a6 100644 --- a/app/Console/Commands/ResetData.php +++ b/app/Console/Commands/ResetData.php @@ -1,6 +1,5 @@ invoice->latest()->first(); $invoiceYear = Carbon::parse($latestInvoice->created_at)->year; - if(Carbon::now()->year > $invoiceYear || $force) { + if (Carbon::now()->year > $invoiceYear || $force) { $accounts->transform(function ($a) { /** @var Account $a */ $a->invoice_number_counter = 1; diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php index 3a546f187e..0e69b232f8 100644 --- a/app/Console/Commands/SendRecurringInvoices.php +++ b/app/Console/Commands/SendRecurringInvoices.php @@ -67,7 +67,7 @@ class SendRecurringInvoices extends Command $shouldSendToday = $recurInvoice->shouldSendToday(); $this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($shouldSendToday ? 'YES' : 'NO')); - if ( ! $shouldSendToday) { + if (! $shouldSendToday) { continue; } diff --git a/app/Console/Commands/SendRenewalInvoices.php b/app/Console/Commands/SendRenewalInvoices.php index 2751e151c0..30403ce4fd 100644 --- a/app/Console/Commands/SendRenewalInvoices.php +++ b/app/Console/Commands/SendRenewalInvoices.php @@ -74,7 +74,7 @@ class SendRenewalInvoices extends Command $plan['price'] = min($company->pending_plan_price, Utils::getPlanPrice($plan)); } - if ($plan['plan'] == PLAN_FREE || !$plan['plan'] || !$plan['term'] || !$plan['price']){ + if ($plan['plan'] == PLAN_FREE || !$plan['plan'] || !$plan['term'] || !$plan['price']) { continue; } diff --git a/app/Console/Commands/TestOFX.php b/app/Console/Commands/TestOFX.php index d21518cba7..a7f9bd5615 100644 --- a/app/Console/Commands/TestOFX.php +++ b/app/Console/Commands/TestOFX.php @@ -39,4 +39,4 @@ class TestOFX extends Command { $this->info(date('Y-m-d').' Running TestOFX...'); } -} \ No newline at end of file +} diff --git a/app/Constants.php b/app/Constants.php index 151d0026df..9d50c8f9bf 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -1,7 +1,6 @@ getLowerName()}::texts.{$text}"; $value = trans($key); if ($key != $value) { diff --git a/app/Events/CreditWasArchived.php b/app/Events/CreditWasArchived.php index 086b5229ca..a5ff2ac693 100644 --- a/app/Events/CreditWasArchived.php +++ b/app/Events/CreditWasArchived.php @@ -1,6 +1,5 @@ credit = $credit; } - } diff --git a/app/Events/CreditWasCreated.php b/app/Events/CreditWasCreated.php index 81ba63c450..dc48b07178 100644 --- a/app/Events/CreditWasCreated.php +++ b/app/Events/CreditWasCreated.php @@ -5,7 +5,6 @@ use Illuminate\Queue\SerializesModels; class CreditWasCreated extends Event { - use SerializesModels; /** @@ -22,5 +21,4 @@ class CreditWasCreated extends Event { $this->credit = $credit; } - } diff --git a/app/Events/CreditWasDeleted.php b/app/Events/CreditWasDeleted.php index c5f585fcf3..ddffac2404 100644 --- a/app/Events/CreditWasDeleted.php +++ b/app/Events/CreditWasDeleted.php @@ -6,9 +6,9 @@ use Illuminate\Queue\SerializesModels; /** * Class CreditWasDeleted */ -class CreditWasDeleted extends Event { - - use SerializesModels; +class CreditWasDeleted extends Event +{ + use SerializesModels; /** * @var Credit @@ -24,5 +24,4 @@ class CreditWasDeleted extends Event { { $this->credit = $credit; } - } diff --git a/app/Events/CreditWasRestored.php b/app/Events/CreditWasRestored.php index a80c9e729b..29e5f3894f 100644 --- a/app/Events/CreditWasRestored.php +++ b/app/Events/CreditWasRestored.php @@ -1,15 +1,14 @@ credit = $credit; } - } diff --git a/app/Events/ExpenseWasArchived.php b/app/Events/ExpenseWasArchived.php index 04b3582d88..6b7c865859 100644 --- a/app/Events/ExpenseWasArchived.php +++ b/app/Events/ExpenseWasArchived.php @@ -24,5 +24,4 @@ class ExpenseWasArchived extends Event { $this->expense = $expense; } - } diff --git a/app/Events/ExpenseWasDeleted.php b/app/Events/ExpenseWasDeleted.php index bb2b6e4dbd..653f14385d 100644 --- a/app/Events/ExpenseWasDeleted.php +++ b/app/Events/ExpenseWasDeleted.php @@ -24,5 +24,4 @@ class ExpenseWasDeleted extends Event { $this->expense = $expense; } - } diff --git a/app/Events/ExpenseWasRestored.php b/app/Events/ExpenseWasRestored.php index 142f41d7e9..fbf4868227 100644 --- a/app/Events/ExpenseWasRestored.php +++ b/app/Events/ExpenseWasRestored.php @@ -1,6 +1,5 @@ expense = $expense; } - } diff --git a/app/Events/InvoiceInvitationWasEmailed.php b/app/Events/InvoiceInvitationWasEmailed.php index 8dfffefcd7..f984cc7d4f 100644 --- a/app/Events/InvoiceInvitationWasEmailed.php +++ b/app/Events/InvoiceInvitationWasEmailed.php @@ -1,6 +1,5 @@ invitation = $invitation; $this->notes = $notes; } - } diff --git a/app/Events/InvoiceInvitationWasViewed.php b/app/Events/InvoiceInvitationWasViewed.php index 0897895a7a..e206b8ab0f 100644 --- a/app/Events/InvoiceInvitationWasViewed.php +++ b/app/Events/InvoiceInvitationWasViewed.php @@ -7,9 +7,9 @@ use Illuminate\Queue\SerializesModels; /** * Class InvoiceInvitationWasViewed */ -class InvoiceInvitationWasViewed extends Event { - - use SerializesModels; +class InvoiceInvitationWasViewed extends Event +{ + use SerializesModels; /** * @var Invoice diff --git a/app/Events/InvoiceWasArchived.php b/app/Events/InvoiceWasArchived.php index 0de212661a..c6f1c795b8 100644 --- a/app/Events/InvoiceWasArchived.php +++ b/app/Events/InvoiceWasArchived.php @@ -24,5 +24,4 @@ class InvoiceWasArchived extends Event { $this->invoice = $invoice; } - } diff --git a/app/Events/InvoiceWasCreated.php b/app/Events/InvoiceWasCreated.php index b78d7f769f..98c72a4ec4 100644 --- a/app/Events/InvoiceWasCreated.php +++ b/app/Events/InvoiceWasCreated.php @@ -24,5 +24,4 @@ class InvoiceWasCreated extends Event { $this->invoice = $invoice; } - } diff --git a/app/Events/InvoiceWasRestored.php b/app/Events/InvoiceWasRestored.php index e935f5b9e8..204b61825a 100644 --- a/app/Events/InvoiceWasRestored.php +++ b/app/Events/InvoiceWasRestored.php @@ -1,6 +1,5 @@ invoice = $invoice; $this->fromDeleted = $fromDeleted; } - } diff --git a/app/Events/PaymentCompleted.php b/app/Events/PaymentCompleted.php index 4d78fb923e..dbdf68d33b 100644 --- a/app/Events/PaymentCompleted.php +++ b/app/Events/PaymentCompleted.php @@ -24,5 +24,4 @@ class PaymentCompleted extends Event { $this->payment = $payment; } - } diff --git a/app/Events/PaymentWasArchived.php b/app/Events/PaymentWasArchived.php index 4bf7eb8ff7..722e1fb03c 100644 --- a/app/Events/PaymentWasArchived.php +++ b/app/Events/PaymentWasArchived.php @@ -24,5 +24,4 @@ class PaymentWasArchived extends Event { $this->payment = $payment; } - } diff --git a/app/Events/PaymentWasCreated.php b/app/Events/PaymentWasCreated.php index 98e95ae43a..50fe5ab0e9 100644 --- a/app/Events/PaymentWasCreated.php +++ b/app/Events/PaymentWasCreated.php @@ -8,7 +8,7 @@ use Illuminate\Queue\SerializesModels; */ class PaymentWasCreated extends Event { - use SerializesModels; + use SerializesModels; /** * @var Payment diff --git a/app/Events/PaymentWasDeleted.php b/app/Events/PaymentWasDeleted.php index e7b62fe74c..7ff50d7498 100644 --- a/app/Events/PaymentWasDeleted.php +++ b/app/Events/PaymentWasDeleted.php @@ -10,7 +10,7 @@ use Illuminate\Queue\SerializesModels; */ class PaymentWasDeleted extends Event { - use SerializesModels; + use SerializesModels; /** * @var Payment @@ -19,7 +19,7 @@ class PaymentWasDeleted extends Event /** * Create a new event instance. - * + * * @param Payment $payment */ public function __construct(Payment $payment) diff --git a/app/Events/QuoteInvitationWasApproved.php b/app/Events/QuoteInvitationWasApproved.php index c7237b3120..b62615988c 100644 --- a/app/Events/QuoteInvitationWasApproved.php +++ b/app/Events/QuoteInvitationWasApproved.php @@ -1,6 +1,5 @@ invitation = $invitation; $this->notes = $notes; } - } diff --git a/app/Events/QuoteInvitationWasViewed.php b/app/Events/QuoteInvitationWasViewed.php index 87f5da2a0b..6e8f6d3ba0 100644 --- a/app/Events/QuoteInvitationWasViewed.php +++ b/app/Events/QuoteInvitationWasViewed.php @@ -8,7 +8,7 @@ use Illuminate\Queue\SerializesModels; */ class QuoteInvitationWasViewed extends Event { - use SerializesModels; + use SerializesModels; public $quote; diff --git a/app/Events/QuoteWasArchived.php b/app/Events/QuoteWasArchived.php index 4e78026b24..08308e7f09 100644 --- a/app/Events/QuoteWasArchived.php +++ b/app/Events/QuoteWasArchived.php @@ -16,5 +16,4 @@ class QuoteWasArchived extends Event { $this->quote = $quote; } - } diff --git a/app/Events/QuoteWasUpdated.php b/app/Events/QuoteWasUpdated.php index b3559a85b1..7f5e1e4aff 100644 --- a/app/Events/QuoteWasUpdated.php +++ b/app/Events/QuoteWasUpdated.php @@ -19,5 +19,4 @@ class QuoteWasUpdated extends Event { $this->quote = $quote; } - } diff --git a/app/Events/TaskWasArchived.php b/app/Events/TaskWasArchived.php index 74a7d1e4f6..cd997f0601 100644 --- a/app/Events/TaskWasArchived.php +++ b/app/Events/TaskWasArchived.php @@ -24,5 +24,4 @@ class TaskWasArchived extends Event { $this->task = $task; } - } diff --git a/app/Events/TaskWasCreated.php b/app/Events/TaskWasCreated.php index af1fc5c27d..e8dd3d23ae 100644 --- a/app/Events/TaskWasCreated.php +++ b/app/Events/TaskWasCreated.php @@ -1,6 +1,5 @@ task = $task; } - } diff --git a/app/Events/TaskWasRestored.php b/app/Events/TaskWasRestored.php index 58891f6e3d..783d659a29 100644 --- a/app/Events/TaskWasRestored.php +++ b/app/Events/TaskWasRestored.php @@ -1,6 +1,5 @@ task = $task; } - } diff --git a/app/Events/TaskWasUpdated.php b/app/Events/TaskWasUpdated.php index 608f57ea7c..0e039bfc7b 100644 --- a/app/Events/TaskWasUpdated.php +++ b/app/Events/TaskWasUpdated.php @@ -1,6 +1,5 @@ path() != 'get_started') { // https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e @@ -84,13 +84,11 @@ class Handler extends ExceptionHandler } } - if($this->isHttpException($e)) - { - switch ($e->getStatusCode()) - { + if ($this->isHttpException($e)) { + switch ($e->getStatusCode()) { // not found case 404: - if($request->header('X-Ninja-Token') != '') { + if ($request->header('X-Ninja-Token') != '') { //API request which has hit a route which does not exist $error['error'] = ['message'=>'Route does not exist']; @@ -98,13 +96,12 @@ class Handler extends ExceptionHandler $headers = Utils::getApiHeaders(); return response()->make($error, 404, $headers); - } break; // internal error case '500': - if($request->header('X-Ninja-Token') != '') { + if ($request->header('X-Ninja-Token') != '') { //API request which produces 500 error $error['error'] = ['message'=>'Internal Server Error']; @@ -132,5 +129,5 @@ class Handler extends ExceptionHandler } else { return parent::render($request, $e); } - } + } } diff --git a/app/Handlers/InvoiceEventHandler.php b/app/Handlers/InvoiceEventHandler.php index 924a9590ee..7e4e6e714f 100644 --- a/app/Handlers/InvoiceEventHandler.php +++ b/app/Handlers/InvoiceEventHandler.php @@ -5,47 +5,45 @@ use App\Ninja\Mailers\ContactMailer; class InvoiceEventHandler { - protected $userMailer; - protected $contactMailer; + protected $userMailer; + protected $contactMailer; - public function __construct(UserMailer $userMailer, ContactMailer $contactMailer) - { - $this->userMailer = $userMailer; - $this->contactMailer = $contactMailer; - } + public function __construct(UserMailer $userMailer, ContactMailer $contactMailer) + { + $this->userMailer = $userMailer; + $this->contactMailer = $contactMailer; + } - public function subscribe($events) - { - $events->listen('invoice.sent', 'InvoiceEventHandler@onSent'); - $events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed'); - $events->listen('invoice.paid', 'InvoiceEventHandler@onPaid'); - } + public function subscribe($events) + { + $events->listen('invoice.sent', 'InvoiceEventHandler@onSent'); + $events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed'); + $events->listen('invoice.paid', 'InvoiceEventHandler@onPaid'); + } - public function onSent($invoice) - { - $this->sendNotifications($invoice, 'sent'); - } + public function onSent($invoice) + { + $this->sendNotifications($invoice, 'sent'); + } - public function onViewed($invoice) - { - $this->sendNotifications($invoice, 'viewed'); - } + public function onViewed($invoice) + { + $this->sendNotifications($invoice, 'viewed'); + } - public function onPaid($payment) - { - $this->contactMailer->sendPaymentConfirmation($payment); + public function onPaid($payment) + { + $this->contactMailer->sendPaymentConfirmation($payment); - $this->sendNotifications($payment->invoice, 'paid', $payment); - } + $this->sendNotifications($payment->invoice, 'paid', $payment); + } - private function sendNotifications($invoice, $type, $payment = null) - { - foreach ($invoice->account->users as $user) - { - if ($user->{'notify_' . $type}) - { + private function sendNotifications($invoice, $type, $payment = null) + { + foreach ($invoice->account->users as $user) { + if ($user->{'notify_' . $type}) { $this->userMailer->sendNotification($user, $invoice, $type, $payment); - } - } - } -} \ No newline at end of file + } + } + } +} diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index f81e505109..dc34d4467e 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -31,15 +31,15 @@ class AccountApiController extends BaseAPIController { $headers = Utils::getApiHeaders(); - if(hash_equals(env(API_SECRET),$request->api_secret)) + if (hash_equals(env(API_SECRET), $request->api_secret)) { return Response::make(RESULT_SUCCESS, 200, $headers); - else + } else { return $this->errorResponse(['message'=>'API Secret does not match .env variable'], 400); + } } public function register(RegisterRequest $request) { - $account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password); $user = $account->users()->first(); @@ -55,7 +55,7 @@ class AccountApiController extends BaseAPIController return $this->processLogin($request); } else { sleep(ERROR_DELAY); - return $this->errorResponse(['message'=>'Invalid credentials'],401); + return $this->errorResponse(['message'=>'Invalid credentials'], 401); } } @@ -117,20 +117,19 @@ class AccountApiController extends BaseAPIController $account = Auth::user()->account; //scan if this user has a token already registered (tokens can change, so we need to use the users email as key) - $devices = json_decode($account->devices,TRUE); + $devices = json_decode($account->devices, true); - for($x=0; $xusername) { - $devices[$x]['token'] = $request->token; //update + for ($x=0; $xusername) { + $devices[$x]['token'] = $request->token; //update $account->devices = json_encode($devices); - $account->save(); - $devices[$x]['account_key'] = $account->account_key; + $account->save(); + $devices[$x]['account_key'] = $account->account_key; - return $this->response($devices[$x]); - } + return $this->response($devices[$x]); } + } //User does not have a device, create new record @@ -139,10 +138,10 @@ class AccountApiController extends BaseAPIController 'email' => $request->email, 'device' => $request->device, 'account_key' => $account->account_key, - 'notify_sent' => TRUE, - 'notify_viewed' => TRUE, - 'notify_approved' => TRUE, - 'notify_paid' => TRUE, + 'notify_sent' => true, + 'notify_viewed' => true, + 'notify_approved' => true, + 'notify_paid' => true, ]; $devices[] = $newDevice; @@ -150,23 +149,20 @@ class AccountApiController extends BaseAPIController $account->save(); return $this->response($newDevice); - } public function updatePushNotifications(Request $request) { $account = Auth::user()->account; - $devices = json_decode($account->devices, TRUE); + $devices = json_decode($account->devices, true); - if(count($devices) < 1) + if (count($devices) < 1) { return $this->errorResponse(['message'=>'No registered devices.'], 400); + } - for($x=0; $xusername) - { - + for ($x=0; $xusername) { $newDevice = [ 'token' => $devices[$x]['token'], 'email' => $devices[$x]['email'], @@ -185,7 +181,6 @@ class AccountApiController extends BaseAPIController return $this->response($newDevice); } } - } public function oauthLogin(Request $request) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index cbab239479..25c6718ca5 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -87,8 +87,7 @@ class AccountController extends BaseController ContactMailer $contactMailer, ReferralRepository $referralRepository, PaymentService $paymentService - ) - { + ) { $this->accountRepo = $accountRepo; $this->userMailer = $userMailer; $this->contactMailer = $contactMailer; @@ -161,7 +160,8 @@ class AccountController extends BaseController /** * @return \Illuminate\Http\RedirectResponse */ - public function changePlan() { + public function changePlan() + { $user = Auth::user(); $account = $user->account; $company = $account->company; @@ -171,7 +171,7 @@ class AccountController extends BaseController $numUsers = Input::get('num_users'); if ($plan != PLAN_ENTERPRISE) { - $numUsers = 1; + $numUsers = 1; } $planDetails = $account->getPlanDetails(false, false); @@ -221,12 +221,11 @@ class AccountController extends BaseController if ($newPlan['price'] > $credit) { $invitation = $this->accountRepo->enablePlan($newPlan, $credit); if ($hasPaid) { - return Redirect::to('view/' . $invitation->invitation_key); + return Redirect::to('view/' . $invitation->invitation_key); } else { - return Redirect::to('payment/' . $invitation->invitation_key); + return Redirect::to('payment/' . $invitation->invitation_key); } } else { - if ($plan == PLAN_FREE) { $company->discount = 0; } else { @@ -290,7 +289,7 @@ class AccountController extends BaseController */ public function showSection($section = false) { - if ( ! Auth::user()->is_admin) { + if (! Auth::user()->is_admin) { return Redirect::to('/settings/user_details'); } @@ -749,7 +748,7 @@ class AccountController extends BaseController $account->live_preview = Input::get('live_preview') ? true : false; // Automatically disable live preview when using a large font - $fonts = Cache::get('fonts')->filter(function($font) use ($account) { + $fonts = Cache::get('fonts')->filter(function ($font) use ($account) { if ($font->google_font) { return false; } @@ -1036,14 +1035,13 @@ class AccountController extends BaseController } $extension = strtolower($uploaded->getClientOriginalExtension()); - if(empty(Document::$types[$extension]) && !empty(Document::$extraExtensions[$extension])){ + if (empty(Document::$types[$extension]) && !empty(Document::$extraExtensions[$extension])) { $documentType = Document::$extraExtensions[$extension]; - } - else{ + } else { $documentType = $extension; } - if(!in_array($documentType, ['jpeg', 'png', 'gif'])){ + if (!in_array($documentType, ['jpeg', 'png', 'gif'])) { Session::flash('warning', 'Unsupported file type'); } else { $documentTypeData = Document::$types[$documentType]; @@ -1051,7 +1049,7 @@ class AccountController extends BaseController $filePath = $uploaded->path(); $size = filesize($filePath); - if($size/1000 > MAX_DOCUMENT_SIZE){ + if ($size/1000 > MAX_DOCUMENT_SIZE) { Session::flash('warning', 'File too large'); } else { if ($documentType != 'gif') { @@ -1128,7 +1126,7 @@ class AccountController extends BaseController $user->email = trim(strtolower(Input::get('email'))); $user->phone = trim(Input::get('phone')); - if ( ! Auth::user()->is_admin) { + if (! Auth::user()->is_admin) { $user->notify_sent = Input::get('notify_sent'); $user->notify_viewed = Input::get('notify_viewed'); $user->notify_paid = Input::get('notify_paid'); @@ -1204,7 +1202,7 @@ class AccountController extends BaseController $gateway_type_id = intval(Input::get('gateway_type_id')); $gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first(); - if ( ! $gateway_settings) { + if (! $gateway_settings) { $gateway_settings = AccountGatewaySettings::createNew(); $gateway_settings->gateway_type_id = $gateway_type_id; } @@ -1232,7 +1230,7 @@ class AccountController extends BaseController { $account = Auth::user()->account; if ($account->hasLogo()) { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { $account->getLogoDisk()->delete($account->logo); } @@ -1349,7 +1347,7 @@ class AccountController extends BaseController $account = Auth::user()->account; \Log::info("Canceled Account: {$account->name} - {$user->email}"); - Document::scope()->each(function($item, $key) { + Document::scope()->each(function ($item, $key) { $item->delete(); }); @@ -1416,7 +1414,7 @@ class AccountController extends BaseController ->withTrashed() ->first(); - if ( ! $invoice) { + if (! $invoice) { return trans('texts.create_invoice_for_sample'); } diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index 7d2d97e294..ec6552e93d 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -81,7 +81,7 @@ class AccountGatewayController extends BaseController */ public function create() { - if ( ! \Request::secure() && ! Utils::isNinjaDev()) { + if (! \Request::secure() && ! Utils::isNinjaDev()) { Session::flash('warning', trans('texts.enable_https')); } @@ -89,7 +89,7 @@ class AccountGatewayController extends BaseController $accountGatewaysIds = $account->gatewayIds(); $otherProviders = Input::get('other_providers'); - if ( ! Utils::isNinja() || ! env('WEPAY_CLIENT_ID') || Gateway::hasStandardGateway($accountGatewaysIds)) { + if (! Utils::isNinja() || ! env('WEPAY_CLIENT_ID') || Gateway::hasStandardGateway($accountGatewaysIds)) { $otherProviders = true; } @@ -132,7 +132,7 @@ class AccountGatewayController extends BaseController foreach ($gateways as $gateway) { $fields = $gateway->getFields(); - if ( ! $gateway->isCustom()) { + if (! $gateway->isCustom()) { asort($fields); } $gateway->fields = $gateway->id == GATEWAY_WEPAY ? [] : $fields; @@ -231,7 +231,7 @@ class AccountGatewayController extends BaseController $accountGateway->gateway_id = $gatewayId; if ($gatewayId == GATEWAY_WEPAY) { - if(!$this->setupWePay($accountGateway, $wepayResponse)) { + if (!$this->setupWePay($accountGateway, $wepayResponse)) { return $wepayResponse; } $oldConfig = $accountGateway->getConfig(); @@ -255,7 +255,7 @@ class AccountGatewayController extends BaseController $config->$field = $value; } } - } elseif($oldConfig) { + } elseif ($oldConfig) { $config = clone $oldConfig; } @@ -383,7 +383,7 @@ class AccountGatewayController extends BaseController ->withInput(); } - try{ + try { $wepay = Utils::setupWePay(); $userDetails = [ @@ -428,9 +428,9 @@ class AccountGatewayController extends BaseController try { $wepay->request('user/send_confirmation/', []); $confirmationRequired = true; - } catch(\WePayException $ex){ + } catch (\WePayException $ex) { if ($ex->getMessage() == 'This access_token is already approved.') { - $confirmationRequired = false; + $confirmationRequired = false; } else { throw $ex; } @@ -488,5 +488,4 @@ class AccountGatewayController extends BaseController return Redirect::to("gateways/{$accountGateway->public_id}/edit"); } - } diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 18955e7600..5249c74ff3 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -145,7 +145,7 @@ class AppController extends BaseController return Redirect::to('/'); } - if ( ! $canUpdateEnv = @fopen(base_path().'/.env', 'w')) { + if (! $canUpdateEnv = @fopen(base_path().'/.env', 'w')) { Session::flash('error', 'Warning: Permission denied to write to .env config file, try running sudo chown www-data:www-data /path/to/ninja/.env'); return Redirect::to('/settings/system_settings'); } @@ -183,7 +183,7 @@ class AppController extends BaseController continue; } if (preg_match('/\s/', $val)) { - $val = "'{$val}'"; + $val = "'{$val}'"; } $config .= "{$key}={$val}\n"; } @@ -277,7 +277,7 @@ class AppController extends BaseController Event::fire(new UserSettingsChanged()); // legacy fix: check cipher is in .env file - if ( ! env('APP_CIPHER')) { + if (! env('APP_CIPHER')) { $fp = fopen(base_path().'/.env', 'a'); fwrite($fp, "\nAPP_CIPHER=AES-256-CBC"); fclose($fp); @@ -314,7 +314,7 @@ class AppController extends BaseController public function stats() { - if ( ! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) { + if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) { sleep(3); return ''; } diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 79efb8d079..84922822ce 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -127,7 +127,6 @@ class AuthController extends Controller */ public function postLoginWrapper(Request $request) { - $userId = Auth::check() ? Auth::user()->id : null; $user = User::where('email', '=', $request->input('email'))->first(); @@ -155,7 +154,6 @@ class AuthController extends Controller $users = $this->accountRepo->loadAccounts(Auth::user()->id); Session::put(SESSION_USER_ACCOUNTS, $users); - } elseif ($user) { $user->failed_logins = $user->failed_logins + 1; $user->save(); @@ -173,7 +171,7 @@ class AuthController extends Controller $account = Auth::user()->account; $this->accountRepo->unlinkAccount($account); - if ( ! $account->hasMultipleAccounts()) { + if (! $account->hasMultipleAccounts()) { $account->company->forceDelete(); } $account->forceDelete(); diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php index e26ca7bc1f..a5ceba3e66 100644 --- a/app/Http/Controllers/Auth/PasswordController.php +++ b/app/Http/Controllers/Auth/PasswordController.php @@ -34,5 +34,4 @@ class PasswordController extends Controller { $this->middleware('guest'); } - } diff --git a/app/Http/Controllers/BaseAPIController.php b/app/Http/Controllers/BaseAPIController.php index 4022408794..c872d8206a 100644 --- a/app/Http/Controllers/BaseAPIController.php +++ b/app/Http/Controllers/BaseAPIController.php @@ -92,13 +92,13 @@ class BaseAPIController extends Controller } if ($clientPublicId = Input::get('client_id')) { - $filter = function($query) use ($clientPublicId) { + $filter = function ($query) use ($clientPublicId) { $query->where('public_id', '=', $clientPublicId); }; $query->whereHas('client', $filter); } - if ( ! Utils::hasPermission('view_all')){ + if (! Utils::hasPermission('view_all')) { if ($this->entityType == ENTITY_USER) { $query->where('id', '=', Auth::user()->id); } else { @@ -174,14 +174,13 @@ class BaseAPIController extends Controller return Response::make($response, 200, $headers); } - protected function errorResponse($response, $httpErrorCode = 400) + protected function errorResponse($response, $httpErrorCode = 400) { $error['error'] = $response; $error = json_encode($error, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($error, $httpErrorCode, $headers); - } protected function getRequestIncludes($data) diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 11e78f6b66..5ca6f2c801 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -25,7 +25,7 @@ class BaseController extends Controller protected function returnBulk($entityType, $action, $ids) { - if ( ! is_array($ids)) { + if (! is_array($ids)) { $ids = [$ids]; } diff --git a/app/Http/Controllers/BlueVineController.php b/app/Http/Controllers/BlueVineController.php index aeab0508c2..d80fab0b9d 100644 --- a/app/Http/Controllers/BlueVineController.php +++ b/app/Http/Controllers/BlueVineController.php @@ -8,83 +8,87 @@ use Redirect; use URL; use Session; -class BlueVineController extends BaseController { - public function signup() { - $user = Auth::user(); +class BlueVineController extends BaseController +{ + public function signup() + { + $user = Auth::user(); - $data = array( - 'personal_user_full_name' => Input::get( 'name' ), - 'business_phone_number' => Input::get( 'phone' ), - 'email' => Input::get( 'email' ), - 'personal_fico_score' => intval( Input::get( 'fico_score' ) ), - 'business_annual_revenue' => intval( Input::get( 'annual_revenue' ) ), - 'business_monthly_average_bank_balance' => intval( Input::get( 'average_bank_balance' ) ), - 'business_inception_date' => date( 'Y-m-d', strtotime( Input::get( 'business_inception' ) ) ), - 'partner_internal_business_id' => 'ninja_account_' . $user->account_id, - ); + $data = array( + 'personal_user_full_name' => Input::get('name'), + 'business_phone_number' => Input::get('phone'), + 'email' => Input::get('email'), + 'personal_fico_score' => intval(Input::get('fico_score')), + 'business_annual_revenue' => intval(Input::get('annual_revenue')), + 'business_monthly_average_bank_balance' => intval(Input::get('average_bank_balance')), + 'business_inception_date' => date('Y-m-d', strtotime(Input::get('business_inception'))), + 'partner_internal_business_id' => 'ninja_account_' . $user->account_id, + ); - if ( ! empty( Input::get( 'quote_type_factoring' ) ) ) { - $data['invoice_factoring_offer'] = true; - $data['desired_credit_line'] = intval( Input::get( 'desired_credit_limit' )['invoice_factoring'] ); - } + if (! empty(Input::get('quote_type_factoring'))) { + $data['invoice_factoring_offer'] = true; + $data['desired_credit_line'] = intval(Input::get('desired_credit_limit')['invoice_factoring']); + } - if ( ! empty( Input::get( 'quote_type_loc' ) ) ) { - $data['line_of_credit_offer'] = true; - $data['desired_credit_line_for_loc'] = intval( Input::get( 'desired_credit_limit' )['line_of_credit'] ); - } + if (! empty(Input::get('quote_type_loc'))) { + $data['line_of_credit_offer'] = true; + $data['desired_credit_line_for_loc'] = intval(Input::get('desired_credit_limit')['line_of_credit']); + } - $api_client = new \GuzzleHttp\Client(); - try { - $response = $api_client->request( 'POST', - 'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query( array( - 'external_register_token' => env( 'BLUEVINE_PARTNER_TOKEN' ), - 'c' => env( 'BLUEVINE_PARTNER_UNIQUE_ID' ), - 'signup_parent_url' => URL::to( '/bluevine/completed' ), - ) ), array( - 'json' => $data - ) - ); - } catch ( \GuzzleHttp\Exception\RequestException $ex ) { - if ( $ex->getCode() == 403 ) { - $response_body = $ex->getResponse()->getBody( true ); - $response_data = json_decode( $response_body ); + $api_client = new \GuzzleHttp\Client(); + try { + $response = $api_client->request('POST', + 'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query(array( + 'external_register_token' => env('BLUEVINE_PARTNER_TOKEN'), + 'c' => env('BLUEVINE_PARTNER_UNIQUE_ID'), + 'signup_parent_url' => URL::to('/bluevine/completed'), + )), array( + 'json' => $data + ) + ); + } catch (\GuzzleHttp\Exception\RequestException $ex) { + if ($ex->getCode() == 403) { + $response_body = $ex->getResponse()->getBody(true); + $response_data = json_decode($response_body); - return response()->json( [ - 'error' => true, - 'message' => $response_data->reason - ] ); - } else { - return response()->json( [ - 'error' => true - ] ); - } - } + return response()->json([ + 'error' => true, + 'message' => $response_data->reason + ]); + } else { + return response()->json([ + 'error' => true + ]); + } + } - $company = $user->account->company; - $company->bluevine_status = 'signed_up'; - $company->save(); + $company = $user->account->company; + $company->bluevine_status = 'signed_up'; + $company->save(); - $quote_data = json_decode( $response->getBody() ); + $quote_data = json_decode($response->getBody()); - return response()->json( $quote_data ); - } + return response()->json($quote_data); + } - public function hideMessage() { - $user = Auth::user(); + public function hideMessage() + { + $user = Auth::user(); - if ( $user ) { - $company = $user->account->company; - $company->bluevine_status = 'ignored'; - $company->save(); - } + if ($user) { + $company = $user->account->company; + $company->bluevine_status = 'ignored'; + $company->save(); + } - return 'success'; - } + return 'success'; + } - public function handleCompleted() { - Session::flash( 'message', trans( 'texts.bluevine_completed' ) ); + public function handleCompleted() + { + Session::flash('message', trans('texts.bluevine_completed')); - return Redirect::to( '/dashboard' ); - } + return Redirect::to('/dashboard'); + } } diff --git a/app/Http/Controllers/BotController.php b/app/Http/Controllers/BotController.php index 5e5994185c..3cb9049fe2 100644 --- a/app/Http/Controllers/BotController.php +++ b/app/Http/Controllers/BotController.php @@ -29,7 +29,7 @@ class BotController extends Controller $input = Input::all(); $botUserId = $input['from']['id']; - if ( ! $token = $this->authenticate($input)) { + if (! $token = $this->authenticate($input)) { return SkypeResponse::message(trans('texts.not_authorized')); } @@ -71,7 +71,7 @@ class BotController extends Controller } elseif ($text == 'status') { $response = SkypeResponse::message(trans('texts.intent_not_supported')); } else { - if ( ! $user = User::whereBotUserId($botUserId)->with('account')->first()) { + if (! $user = User::whereBotUserId($botUserId)->with('account')->first()) { return SkypeResponse::message(trans('texts.not_authorized')); } @@ -102,7 +102,7 @@ class BotController extends Controller if (Utils::isNinjaDev()) { // skip validation for testing - } elseif ( ! $this->validateToken($token)) { + } elseif (! $this->validateToken($token)) { return false; } @@ -186,7 +186,7 @@ class BotController extends Controller private function validateEmail($email, $botUserId) { - if ( ! $email || ! $botUserId) { + if (! $email || ! $botUserId) { return false; } @@ -203,7 +203,7 @@ class BotController extends Controller ->whereNull('bot_user_id') ->first(); - if ( ! $user) { + if (! $user) { return false; } @@ -221,7 +221,7 @@ class BotController extends Controller private function validateCode($input, $botUserId) { - if ( ! $input || ! $botUserId) { + if (! $input || ! $botUserId) { return false; } @@ -230,11 +230,11 @@ class BotController extends Controller ->where('attempts', '<', 5) ->first(); - if ( ! $code) { + if (! $code) { return false; } - if ( ! hash_equals($code->code, $input)) { + if (! hash_equals($code->code, $input)) { $code->attempts += 1; $code->save(); return false; @@ -256,7 +256,7 @@ class BotController extends Controller private function validateToken($token) { - if ( ! $token) { + if (! $token) { return false; } @@ -273,17 +273,17 @@ class BotController extends Controller $sig_enc = $token_arr[2]; // 2 base 64 url decoding - $headers_arr = json_decode($this->base64_url_decode($headers_enc), TRUE); - $claims_arr = json_decode($this->base64_url_decode($claims_enc), TRUE); + $headers_arr = json_decode($this->base64_url_decode($headers_enc), true); + $claims_arr = json_decode($this->base64_url_decode($claims_enc), true); $sig = $this->base64_url_decode($sig_enc); // 3 get key list $keylist = file_get_contents('https://api.aps.skype.com/v1/keys'); - $keylist_arr = json_decode($keylist, TRUE); - foreach($keylist_arr['keys'] as $key => $value) { + $keylist_arr = json_decode($keylist, true); + foreach ($keylist_arr['keys'] as $key => $value) { // 4 select one key (which matches) - if($value['kid'] == $headers_arr['kid']) { + if ($value['kid'] == $headers_arr['kid']) { // 5 get public key from key info $cert_txt = '-----BEGIN CERTIFICATE-----' . "\n" . chunk_split($value['x5c'][0], 64) . '-----END CERTIFICATE-----'; @@ -301,7 +301,8 @@ class BotController extends Controller return ($token_valid == 1); } - private function base64_url_decode($arg) { + private function base64_url_decode($arg) + { $res = $arg; $res = str_replace('-', '+', $res); $res = str_replace('_', '/', $res); diff --git a/app/Http/Controllers/ClientApiController.php b/app/Http/Controllers/ClientApiController.php index 4f6ca6521c..54d400e502 100644 --- a/app/Http/Controllers/ClientApiController.php +++ b/app/Http/Controllers/ClientApiController.php @@ -174,5 +174,4 @@ class ClientApiController extends BaseAPIController return $this->itemResponse($client); } - } diff --git a/app/Http/Controllers/ClientAuth/PasswordController.php b/app/Http/Controllers/ClientAuth/PasswordController.php index a7957cacf5..f1b5624a1a 100644 --- a/app/Http/Controllers/ClientAuth/PasswordController.php +++ b/app/Http/Controllers/ClientAuth/PasswordController.php @@ -67,7 +67,7 @@ class PasswordController extends Controller * Send a reset link to the given user. * * @param \Illuminate\Http\Request $request - * + * * @return \Illuminate\Http\Response */ public function sendResetLinkEmail(Request $request) diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index c2fd0a93d6..d8ebe79472 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -84,29 +84,29 @@ class ClientController extends BaseController $user = Auth::user(); $actionLinks = []; - if ($user->can('create', ENTITY_INVOICE)){ + if ($user->can('create', ENTITY_INVOICE)) { $actionLinks[] = ['label' => trans('texts.new_invoice'), 'url' => URL::to('/invoices/create/'.$client->public_id)]; } - if ($user->can('create', ENTITY_TASK)){ + if ($user->can('create', ENTITY_TASK)) { $actionLinks[] = ['label' => trans('texts.new_task'), 'url' => URL::to('/tasks/create/'.$client->public_id)]; } if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) { $actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)]; } - if(!empty($actionLinks)){ + if (!empty($actionLinks)) { $actionLinks[] = \DropdownButton::DIVIDER; } - if($user->can('create', ENTITY_PAYMENT)){ + if ($user->can('create', ENTITY_PAYMENT)) { $actionLinks[] = ['label' => trans('texts.enter_payment'), 'url' => URL::to('/payments/create/'.$client->public_id)]; } - if($user->can('create', ENTITY_CREDIT)){ + if ($user->can('create', ENTITY_CREDIT)) { $actionLinks[] = ['label' => trans('texts.enter_credit'), 'url' => URL::to('/credits/create/'.$client->public_id)]; } - if($user->can('create', ENTITY_EXPENSE)){ + if ($user->can('create', ENTITY_EXPENSE)) { $actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => URL::to('/expenses/create/0/'.$client->public_id)]; } diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php index 7cefa6e1e1..e3564d4f94 100644 --- a/app/Http/Controllers/ClientPortalController.php +++ b/app/Http/Controllers/ClientPortalController.php @@ -116,7 +116,7 @@ class ClientPortalController extends BaseController } } - if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)){ + if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) { $data['enableWePayACH'] = $wepayGateway->getAchEnabled(); } @@ -157,10 +157,10 @@ class ClientPortalController extends BaseController ]; } - if($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()){ + if ($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()) { $zipDocs = $this->getInvoiceZipDocuments($invoice, $size); - if(count($zipDocs) > 1){ + if (count($zipDocs) > 1) { $data['documentsZipURL'] = URL::to("client/documents/{$invitation->invitation_key}"); $data['documentsZipSize'] = $size; } @@ -227,7 +227,7 @@ class ClientPortalController extends BaseController return $this->returnError(); } Session::put('contact_key', $contactKey);// track current contact - } else if (!$contact = $this->getContact()) { + } elseif (!$contact = $this->getContact()) { return $this->returnError(); } @@ -274,7 +274,9 @@ class ClientPortalController extends BaseController $query->where('activities.adjustment', '!=', 0); return Datatable::query($query) - ->addColumn('activities.id', function ($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); }) + ->addColumn('activities.id', function ($model) { + return Utils::timestampToDateTimeString(strtotime($model->created_at)); + }) ->addColumn('activity_type_id', function ($model) { $data = [ 'client' => Utils::getClientDisplayName($model), @@ -288,9 +290,13 @@ class ClientPortalController extends BaseController ]; return trans("texts.activity_{$model->activity_type_id}", $data); - }) - ->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); }) - ->addColumn('adjustment', function ($model) { return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : ''; }) + }) + ->addColumn('balance', function ($model) { + return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); + }) + ->addColumn('adjustment', function ($model) { + return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : ''; + }) ->make(); } @@ -404,13 +410,25 @@ class ClientPortalController extends BaseController $payments = $this->paymentRepo->findForContact($contact->id, Input::get('sSearch')); return Datatable::query($payments) - ->addColumn('invoice_number', function ($model) { return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number; }) - ->addColumn('transaction_reference', function ($model) { return $model->transaction_reference ? $model->transaction_reference : ''.trans('texts.manual_entry').''; }) - ->addColumn('payment_type', function ($model) { return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? 'Online payment' : ''); }) - ->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); }) - ->addColumn('payment_date', function ($model) { return Utils::dateToString($model->payment_date); }) - ->addColumn('status', function ($model) { return $this->getPaymentStatusLabel($model); }) - ->orderColumns( 'invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date') + ->addColumn('invoice_number', function ($model) { + return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number; + }) + ->addColumn('transaction_reference', function ($model) { + return $model->transaction_reference ? $model->transaction_reference : ''.trans('texts.manual_entry').''; + }) + ->addColumn('payment_type', function ($model) { + return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? 'Online payment' : ''); + }) + ->addColumn('amount', function ($model) { + return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); + }) + ->addColumn('payment_date', function ($model) { + return Utils::dateToString($model->payment_date); + }) + ->addColumn('status', function ($model) { + return $this->getPaymentStatusLabel($model); + }) + ->orderColumns('invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date') ->make(); } @@ -560,7 +578,8 @@ class ClientPortalController extends BaseController ]); } - private function getContact() { + private function getContact() + { $contactKey = session('contact_key'); if (!$contactKey) { @@ -576,7 +595,8 @@ class ClientPortalController extends BaseController return $contact; } - public function getDocumentVFSJS($publicId, $name){ + public function getDocumentVFSJS($publicId, $name) + { if (!$contact = $this->getContact()) { return $this->returnError(); } @@ -584,22 +604,22 @@ class ClientPortalController extends BaseController $document = Document::scope($publicId, $contact->account_id)->first(); - if(!$document->isPDFEmbeddable()){ + if (!$document->isPDFEmbeddable()) { return Response::view('error', ['error'=>'Image does not exist!'], 404); } $authorized = false; - if($document->expense && $document->expense->client_id == $contact->client_id){ + if ($document->expense && $document->expense->client_id == $contact->client_id) { $authorized = true; - } else if($document->invoice && $document->invoice->client_id ==$contact->client_id){ + } elseif ($document->invoice && $document->invoice->client_id ==$contact->client_id) { $authorized = true; } - if(!$authorized){ + if (!$authorized) { return Response::view('error', ['error'=>'Not authorized'], 403); } - if(substr($name, -3)=='.js'){ + if (substr($name, -3)=='.js') { $name = substr($name, 0, -3); } @@ -612,14 +632,16 @@ class ClientPortalController extends BaseController return $response; } - protected function canCreateZip(){ + protected function canCreateZip() + { return function_exists('gmp_init'); } - protected function getInvoiceZipDocuments($invoice, &$size=0){ + protected function getInvoiceZipDocuments($invoice, &$size=0) + { $documents = $invoice->documents; - foreach($invoice->expenses as $expense){ + foreach ($invoice->expenses as $expense) { $documents = $documents->merge($expense->documents); } @@ -628,31 +650,31 @@ class ClientPortalController extends BaseController $size = 0; $maxSize = MAX_ZIP_DOCUMENTS_SIZE * 1000; $toZip = []; - foreach($documents as $document){ - if($size + $document->size > $maxSize)break; + foreach ($documents as $document) { + if ($size + $document->size > $maxSize) { + break; + } - if(!empty($toZip[$document->name])){ + if (!empty($toZip[$document->name])) { // This name is taken - if($toZip[$document->name]->hash != $document->hash){ + if ($toZip[$document->name]->hash != $document->hash) { // 2 different files with the same name $nameInfo = pathinfo($document->name); - for($i = 1;; $i++){ + for ($i = 1;; $i++) { $name = $nameInfo['filename'].' ('.$i.').'.$nameInfo['extension']; - if(empty($toZip[$name])){ + if (empty($toZip[$name])) { $toZip[$name] = $document; $size += $document->size; break; - } else if ($toZip[$name]->hash == $document->hash){ + } elseif ($toZip[$name]->hash == $document->hash) { // We're not adding this after all break; } } - } - } - else{ + } else { $toZip[$document->name] = $document; $size += $document->size; } @@ -661,7 +683,8 @@ class ClientPortalController extends BaseController return $toZip; } - public function getInvoiceDocumentsZip($invitationKey){ + public function getInvoiceDocumentsZip($invitationKey) + { if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { return $this->returnError(); } @@ -672,21 +695,22 @@ class ClientPortalController extends BaseController $toZip = $this->getInvoiceZipDocuments($invoice); - if(!count($toZip)){ + if (!count($toZip)) { return Response::view('error', ['error'=>'No documents small enough'], 404); } $zip = new ZipArchive($invitation->account->name.' Invoice '.$invoice->invoice_number.'.zip'); - return Response::stream(function() use ($toZip, $zip) { - foreach($toZip as $name=>$document){ + return Response::stream(function () use ($toZip, $zip) { + foreach ($toZip as $name=>$document) { $fileStream = $document->getStream(); - if($fileStream){ + if ($fileStream) { $zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]); - while ($buffer = fread($fileStream, 256000))$zip->stream_file_part($buffer); + while ($buffer = fread($fileStream, 256000)) { + $zip->stream_file_part($buffer); + } fclose($fileStream); $zip->complete_file_stream(); - } - else{ + } else { $zip->add_file($name, $document->getRaw()); } } @@ -694,7 +718,8 @@ class ClientPortalController extends BaseController }, 200); } - public function getDocument($invitationKey, $publicId){ + public function getDocument($invitationKey, $publicId) + { if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { return $this->returnError(); } @@ -705,13 +730,13 @@ class ClientPortalController extends BaseController $document = Document::scope($publicId, $invitation->account_id)->firstOrFail(); $authorized = false; - if($document->expense && $document->expense->client_id == $invitation->invoice->client_id){ + if ($document->expense && $document->expense->client_id == $invitation->invoice->client_id) { $authorized = true; - } else if($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id){ + } elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) { $authorized = true; } - if(!$authorized){ + if (!$authorized) { return Response::view('error', ['error'=>'Not authorized'], 403); } @@ -795,7 +820,8 @@ class ClientPortalController extends BaseController return redirect()->to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/'); } - public function setDefaultPaymentMethod(){ + public function setDefaultPaymentMethod() + { if (!$contact = $this->getContact()) { return $this->returnError(); } @@ -834,7 +860,8 @@ class ClientPortalController extends BaseController Utils::logError("Payment Method Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message), 'PHP', true); } - public function setAutoBill(){ + public function setAutoBill() + { if (!$contact = $this->getContact()) { return $this->returnError(); } diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 02c0988a53..1d5ccc8887 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -43,10 +43,10 @@ class DashboardController extends BaseController $expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll); $tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll); - $showBlueVinePromo = $user->is_admin + $showBlueVinePromo = $user->is_admin && env('BLUEVINE_PARTNER_UNIQUE_ID') && ! $account->company->bluevine_status - && $account->created_at <= date( 'Y-m-d', strtotime( '-1 month' )); + && $account->created_at <= date('Y-m-d', strtotime('-1 month')); $showWhiteLabelExpired = Utils::isSelfHost() && $account->company->hasExpiredPlan(PLAN_WHITE_LABEL); @@ -82,7 +82,7 @@ class DashboardController extends BaseController $data = [ 'account' => $user->account, - 'user' => $user, + 'user' => $user, 'paidToDate' => $paidToDate, 'balances' => $balances, 'averageInvoice' => $averageInvoice, @@ -98,29 +98,29 @@ class DashboardController extends BaseController 'currencies' => $currencies, 'expenses' => $expenses, 'tasks' => $tasks, - 'showBlueVinePromo' => $showBlueVinePromo, + 'showBlueVinePromo' => $showBlueVinePromo, 'showWhiteLabelExpired' => $showWhiteLabelExpired, ]; - if ($showBlueVinePromo) { - $usdLast12Months = 0; - $pastYear = date( 'Y-m-d', strtotime( '-1 year' )); - $paidLast12Months = $dashboardRepo->paidToDate( $account, $userId, $viewAll, $pastYear ); + if ($showBlueVinePromo) { + $usdLast12Months = 0; + $pastYear = date('Y-m-d', strtotime('-1 year')); + $paidLast12Months = $dashboardRepo->paidToDate($account, $userId, $viewAll, $pastYear); - foreach ( $paidLast12Months as $item ) { - if ( $item->currency_id == null ) { - $currency = $user->account->currency_id ?: DEFAULT_CURRENCY; - } else { - $currency = $item->currency_id; - } + foreach ($paidLast12Months as $item) { + if ($item->currency_id == null) { + $currency = $user->account->currency_id ?: DEFAULT_CURRENCY; + } else { + $currency = $item->currency_id; + } - if ( $currency == CURRENCY_DOLLAR ) { - $usdLast12Months += $item->value; - } - } + if ($currency == CURRENCY_DOLLAR) { + $usdLast12Months += $item->value; + } + } - $data['usdLast12Months'] = $usdLast12Months; - } + $data['usdLast12Months'] = $usdLast12Months; + } return View::make('dashboard', $data); } diff --git a/app/Http/Controllers/DocumentAPIController.php b/app/Http/Controllers/DocumentAPIController.php index b639bb7dda..1a7134c31f 100644 --- a/app/Http/Controllers/DocumentAPIController.php +++ b/app/Http/Controllers/DocumentAPIController.php @@ -53,7 +53,6 @@ class DocumentAPIController extends BaseAPIController $documents = Document::scope(); return $this->listResponse($documents); - } /** @@ -65,10 +64,11 @@ class DocumentAPIController extends BaseAPIController { $document = $request->entity(); - if(array_key_exists($document->type, Document::$types)) + if (array_key_exists($document->type, Document::$types)) { return DocumentController::getDownloadResponse($document); - else - return $this->errorResponse(['error'=>'Invalid mime type'],400); + } else { + return $this->errorResponse(['error'=>'Invalid mime type'], 400); + } } /** @@ -94,7 +94,6 @@ class DocumentAPIController extends BaseAPIController */ public function store(CreateDocumentRequest $request) { - $document = $this->documentRepo->upload($request->all()); return $this->itemResponse($document); diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index f25a027f86..9ec6365f7e 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -26,25 +26,25 @@ class DocumentController extends BaseController return static::getDownloadResponse($request->entity()); } - public static function getDownloadResponse($document){ + public static function getDownloadResponse($document) + { $direct_url = $document->getDirectUrl(); - if($direct_url){ + if ($direct_url) { return redirect($direct_url); } $stream = $document->getStream(); - if($stream){ + if ($stream) { $headers = [ 'Content-Type' => Document::$types[$document->type]['mime'], 'Content-Length' => $document->size, ]; - $response = Response::stream(function() use ($stream) { + $response = Response::stream(function () use ($stream) { fpassthru($stream); }, 200, $headers); - } - else{ + } else { $response = Response::make($document->getRaw(), 200); $response->header('content-type', Document::$types[$document->type]['mime']); } @@ -56,12 +56,12 @@ class DocumentController extends BaseController { $document = $request->entity(); - if(empty($document->preview)){ + if (empty($document->preview)) { return Response::view('error', ['error'=>'Preview does not exist!'], 404); } $direct_url = $document->getDirectPreviewUrl(); - if($direct_url){ + if ($direct_url) { return redirect($direct_url); } @@ -76,11 +76,11 @@ class DocumentController extends BaseController { $document = $request->entity(); - if(substr($name, -3)=='.js'){ + if (substr($name, -3)=='.js') { $name = substr($name, 0, -3); } - if(!$document->isPDFEmbeddable()){ + if (!$document->isPDFEmbeddable()) { return Response::view('error', ['error'=>'Image does not exist!'], 404); } @@ -97,13 +97,13 @@ class DocumentController extends BaseController { $result = $this->documentRepo->upload($request->all(), $doc_array); - if(is_string($result)){ - return Response::json([ + if (is_string($result)) { + return Response::json([ 'error' => $result, 'code' => 400 ], 400); } else { - return Response::json([ + return Response::json([ 'error' => false, 'document' => $doc_array, 'code' => 200 diff --git a/app/Http/Controllers/ExpenseApiController.php b/app/Http/Controllers/ExpenseApiController.php index 2f38a53362..997be9a09d 100644 --- a/app/Http/Controllers/ExpenseApiController.php +++ b/app/Http/Controllers/ExpenseApiController.php @@ -1,6 +1,5 @@ withTrashed() ->with('client', 'invoice', 'vendor', 'expense_category') - ->orderBy('created_at','desc'); + ->orderBy('created_at', 'desc'); return $this->listResponse($expenses); } @@ -145,8 +144,4 @@ class ExpenseApiController extends BaseAPIController return $this->itemResponse($expense); } - - - - } diff --git a/app/Http/Controllers/ExpenseCategoryController.php b/app/Http/Controllers/ExpenseCategoryController.php index ebee16df7c..14e98bb3ac 100644 --- a/app/Http/Controllers/ExpenseCategoryController.php +++ b/app/Http/Controllers/ExpenseCategoryController.php @@ -100,5 +100,4 @@ class ExpenseCategoryController extends BaseController return redirect()->to('/expense_categories'); } - } diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php index e159b268f2..f19024fc4c 100644 --- a/app/Http/Controllers/ExpenseController.php +++ b/app/Http/Controllers/ExpenseController.php @@ -110,7 +110,6 @@ class ExpenseController extends BaseController foreach ($invoices as $invoice) { $actions[] = ['url' => 'javascript:submitAction("add_to_invoice", '.$invoice->public_id.')', 'label' => trans('texts.add_to_invoice', ['invoice' => $invoice->invoice_number])]; } - } $actions[] = \DropdownButton::DIVIDER; @@ -181,8 +180,7 @@ class ExpenseController extends BaseController $action = Input::get('action'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids'); - switch($action) - { + switch ($action) { case 'invoice': case 'add_to_invoice': $expenses = Expense::scope($ids)->with('client')->get(); @@ -190,8 +188,7 @@ class ExpenseController extends BaseController $currencyId = null; // Validate that either all expenses do not have a client or if there is a client, it is the same client - foreach ($expenses as $expense) - { + foreach ($expenses as $expense) { if ($expense->client) { if (!$clientPublicId) { $clientPublicId = $expense->client->public_id; @@ -223,7 +220,6 @@ class ExpenseController extends BaseController return Redirect::to("invoices/{$invoiceId}/edit") ->with('expenseCurrencyId', $currencyId) ->with('expenses', $ids); - } break; diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index ed0d1480e1..4db38263d9 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -39,7 +39,7 @@ class ExportController extends BaseController } else { $fields = $request->all(); $fields = array_filter(array_map(function ($key) { - if ( ! in_array($key, ['format', 'include', '_token'])) { + if (! in_array($key, ['format', 'include', '_token'])) { return $key; } else { return null; @@ -74,11 +74,11 @@ class ExportController extends BaseController // eager load data, include archived but exclude deleted $account = Auth::user()->account; - $account->load(['clients' => function($query) { + $account->load(['clients' => function ($query) { $query->withArchived() - ->with(['contacts', 'invoices' => function($query) { + ->with(['contacts', 'invoices' => function ($query) { $query->withArchived() - ->with(['invoice_items', 'payments' => function($query) { + ->with(['invoice_items', 'payments' => function ($query) { $query->withArchived(); }]); }]); @@ -102,8 +102,8 @@ class ExportController extends BaseController { $data = $this->getData($request); - return Excel::create($fileName, function($excel) use ($data) { - $excel->sheet('', function($sheet) use ($data) { + return Excel::create($fileName, function ($excel) use ($data) { + $excel->sheet('', function ($sheet) use ($data) { $sheet->loadView('export', $data); }); })->download('csv'); @@ -120,8 +120,7 @@ class ExportController extends BaseController $user = Auth::user(); $data = $this->getData($request); - return Excel::create($fileName, function($excel) use ($user, $data) { - + return Excel::create($fileName, function ($excel) use ($user, $data) { $excel->setTitle($data['title']) ->setCreator($user->getDisplayName()) ->setLastModifiedBy($user->getDisplayName()) @@ -140,7 +139,7 @@ class ExportController extends BaseController $key = 'recurring_invoices'; } $label = trans("texts.{$key}"); - $excel->sheet($label, function($sheet) use ($key, $data) { + $excel->sheet($label, function ($sheet) use ($key, $data) { if ($key === 'quotes') { $key = 'invoices'; $data['entityType'] = ENTITY_QUOTE; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 5c5a7b4854..0d4c8b7445 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -136,7 +136,7 @@ class HomeController extends BaseController { Mail::raw(request()->message, function ($message) { $subject = 'Customer Message'; - if ( ! Utils::isNinja()) { + if (! Utils::isNinja()) { $subject .= ': v' . NINJA_VERSION; } $message->to(CONTACT_EMAIL) diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index e5b74453e4..83bd79c225 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -31,7 +31,7 @@ class ImportController extends BaseController } } - if ( ! count($files)) { + if (! count($files)) { Session::flash('error', trans('texts.select_file')); return Redirect::to('/settings/' . ACCOUNT_IMPORT_EXPORT); } diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index a10fe91b99..0f68d5b6be 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -113,7 +113,7 @@ class InvoiceApiController extends BaseAPIController if (isset($data['email'])) { $email = $data['email']; - $client = Client::scope()->whereHas('contacts', function($query) use ($email) { + $client = Client::scope()->whereHas('contacts', function ($query) use ($email) { $query->where('email', '=', $email); })->first(); @@ -152,7 +152,7 @@ class InvoiceApiController extends BaseAPIController $client = $this->clientRepo->save($clientData); } - } else if (isset($data['client_id'])) { + } elseif (isset($data['client_id'])) { $client = Client::scope($data['client_id'])->firstOrFail(); } @@ -174,7 +174,7 @@ class InvoiceApiController extends BaseAPIController if ($invoice->isInvoice()) { if ($isAutoBill) { $payment = $this->paymentService->autoBillInvoice($invoice); - } else if ($isPaid) { + } elseif ($isPaid) { $payment = $this->paymentRepo->save([ 'invoice_id' => $invoice->id, 'client_id' => $client->id, @@ -187,7 +187,7 @@ class InvoiceApiController extends BaseAPIController if ($payment) { app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment); //$this->dispatch(new SendPaymentEmail($payment)); - } elseif ( ! $invoice->is_recurring) { + } elseif (! $invoice->is_recurring) { app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice); //$this->dispatch(new SendInvoiceEmail($invoice)); } diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index c43c967233..7dafc98576 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -124,7 +124,7 @@ class InvoiceController extends BaseController $lastSent = ($invoice->is_recurring && $invoice->last_sent_date) ? $invoice->recurring_invoices->last() : null; - if(!Auth::user()->hasPermission('view_all')){ + if (!Auth::user()->hasPermission('view_all')) { $clients = $clients->where('clients.user_id', '=', Auth::user()->id); } @@ -151,7 +151,7 @@ class InvoiceController extends BaseController } // Set the invitation data on the client's contacts - if ( ! $clone) { + if (! $clone) { $clients = $data['clients']; foreach ($clients as $client) { if ($client->id != $invoice->client->id) { @@ -247,9 +247,12 @@ class InvoiceController extends BaseController ]; $ends = ['th','st','nd','rd','th','th','th','th','th','th']; - for($i = 1; $i < 31; $i++){ - if ($i >= 11 && $i <= 13) $ordinal = $i. 'th'; - else $ordinal = $i . $ends[$i % 10]; + for ($i = 1; $i < 31; $i++) { + if ($i >= 11 && $i <= 13) { + $ordinal = $i. 'th'; + } else { + $ordinal = $i . $ends[$i % 10]; + } $dayStr = str_pad($i, 2, '0', STR_PAD_LEFT); $str = trans('texts.day_of_month', ['ordinal'=>$ordinal]); @@ -268,8 +271,8 @@ class InvoiceController extends BaseController trans('texts.friday'), trans('texts.saturday'), ]; - foreach(['1st','2nd','3rd','4th'] as $i=>$ordinal){ - foreach($daysOfWeek as $j=>$dayOfWeek){ + foreach (['1st','2nd','3rd','4th'] as $i=>$ordinal) { + foreach ($daysOfWeek as $j=>$dayOfWeek) { $str = trans('texts.day_of_week_after', ['ordinal' => $ordinal, 'day' => $dayOfWeek]); $day = $i * 7 + $j + 1; @@ -327,7 +330,6 @@ class InvoiceController extends BaseController 'expenseCurrencyId' => Session::get('expenseCurrencyId') ?: null, 'expenses' => Session::get('expenses') ? Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get() : [], ]; - } /** @@ -467,7 +469,8 @@ class InvoiceController extends BaseController */ public function bulk($entityType = ENTITY_INVOICE) { - $action = Input::get('bulk_action') ?: Input::get('action');; + $action = Input::get('bulk_action') ?: Input::get('action'); + ; $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids')); $count = $this->invoiceService->bulk($ids, $action); @@ -554,7 +557,7 @@ class InvoiceController extends BaseController } // Show the current version as the last in the history - if ( ! $paymentId) { + if (! $paymentId) { $versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName(); } @@ -586,5 +589,4 @@ class InvoiceController extends BaseController return $count ? RESULT_FAILURE : RESULT_SUCCESS; } - } diff --git a/app/Http/Controllers/NinjaController.php b/app/Http/Controllers/NinjaController.php index cab57f9da2..b22e6b4d30 100644 --- a/app/Http/Controllers/NinjaController.php +++ b/app/Http/Controllers/NinjaController.php @@ -100,7 +100,7 @@ class NinjaController extends BaseController if (Input::has('product_id')) { Session::set('product_id', Input::get('product_id')); - } else if (!Session::has('product_id')) { + } elseif (!Session::has('product_id')) { Session::set('product_id', PRODUCT_ONE_CLICK_INSTALL); } @@ -284,6 +284,6 @@ class NinjaController extends BaseController $company->plan = null; $company->save(); - return RESULT_SUCCESS; - } + return RESULT_SUCCESS; + } } diff --git a/app/Http/Controllers/OnlinePaymentController.php b/app/Http/Controllers/OnlinePaymentController.php index 14c0d8764a..b77f495d30 100644 --- a/app/Http/Controllers/OnlinePaymentController.php +++ b/app/Http/Controllers/OnlinePaymentController.php @@ -64,14 +64,14 @@ class OnlinePaymentController extends BaseController */ public function showPayment($invitationKey, $gatewayTypeAlias = false, $sourceId = false) { - if ( ! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { + if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { return response()->view('error', [ 'error' => trans('texts.invoice_not_found'), 'hideHeader' => true, ]); } - if ( ! $invitation->invoice->canBePaid()) { + if (! $invitation->invoice->canBePaid()) { return redirect()->to('view/' . $invitation->invitation_key); } @@ -84,7 +84,7 @@ class OnlinePaymentController extends BaseController $account->loadLocalizationSettings($invitation->invoice->client); - if ( ! $gatewayTypeAlias) { + if (! $gatewayTypeAlias) { $gatewayTypeId = Session::get($invitation->id . 'gateway_type'); } elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) { $gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias); @@ -111,7 +111,7 @@ class OnlinePaymentController extends BaseController $gatewayTypeId = Session::get($invitation->id . 'gateway_type'); $paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId); - if ( ! $invitation->invoice->canBePaid()) { + if (! $invitation->invoice->canBePaid()) { return redirect()->to('view/' . $invitation->invitation_key); } @@ -141,7 +141,7 @@ class OnlinePaymentController extends BaseController $invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway') ->where('invitation_key', '=', $invitationKey)->firstOrFail(); - if ( ! $gatewayTypeAlias) { + if (! $gatewayTypeAlias) { $gatewayTypeId = Session::get($invitation->id . 'gateway_type'); } elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) { $gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias); @@ -210,7 +210,8 @@ class OnlinePaymentController extends BaseController * @param $routingNumber * @return \Illuminate\Http\JsonResponse */ - public function getBankInfo($routingNumber) { + public function getBankInfo($routingNumber) + { if (strlen($routingNumber) != 9 || !preg_match('/\d{9}/', $routingNumber)) { return response()->json([ 'message' => 'Invalid routing number', @@ -278,14 +279,14 @@ class OnlinePaymentController extends BaseController $redirectUrl = Input::get('redirect_url'); $failureUrl = URL::previous(); - if ( ! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) { + if (! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) { return redirect()->to("{$failureUrl}/?error=invalid account"); } Auth::onceUsingId($account->users[0]->id); $product = Product::scope(Input::get('product_id'))->first(); - if ( ! $product) { + if (! $product) { return redirect()->to("{$failureUrl}/?error=invalid product"); } @@ -296,7 +297,7 @@ class OnlinePaymentController extends BaseController $query->where('contact_key', $contactKey); })->first(); } - if ( ! $client) { + if (! $client) { $rules = [ 'first_name' => 'string|max:100', 'last_name' => 'string|max:100', diff --git a/app/Http/Controllers/PaymentApiController.php b/app/Http/Controllers/PaymentApiController.php index 4daad26d0d..7fddd7a0f4 100644 --- a/app/Http/Controllers/PaymentApiController.php +++ b/app/Http/Controllers/PaymentApiController.php @@ -150,5 +150,4 @@ class PaymentApiController extends BaseAPIController return $this->itemResponse($payment); } - } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index bcb244f1e2..622517555b 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -49,8 +49,7 @@ class PaymentController extends BaseController PaymentRepository $paymentRepo, ContactMailer $contactMailer, PaymentService $paymentService - ) - { + ) { $this->paymentRepo = $paymentRepo; $this->contactMailer = $contactMailer; $this->paymentService = $paymentService; @@ -130,7 +129,7 @@ class PaymentController extends BaseController } $actions[] = ['url' => url("/invoices/{$payment->invoice->public_id}/edit"), 'label' => trans('texts.edit_invoice')]; $actions[] = DropdownButton::DIVIDER; - if ( ! $payment->trashed()) { + if (! $payment->trashed()) { $actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_payment')]; $actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_payment')]; } else { diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php index 30f3c5bf42..d517809998 100644 --- a/app/Http/Controllers/PaymentTermController.php +++ b/app/Http/Controllers/PaymentTermController.php @@ -126,5 +126,4 @@ class PaymentTermController extends BaseController return Redirect::to('settings/' . ACCOUNT_PAYMENT_TERMS); } - } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 9e43e2c639..a064e2787f 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -109,5 +109,4 @@ class ProjectController extends BaseController return redirect()->to('/projects'); } - } diff --git a/app/Http/Controllers/QuoteApiController.php b/app/Http/Controllers/QuoteApiController.php index d6c572ceb0..33b6be4c18 100644 --- a/app/Http/Controllers/QuoteApiController.php +++ b/app/Http/Controllers/QuoteApiController.php @@ -43,5 +43,4 @@ class QuoteApiController extends BaseAPIController return $this->listResponse($invoices); } - } diff --git a/app/Http/Controllers/QuoteController.php b/app/Http/Controllers/QuoteController.php index 005da1b11d..480169ed44 100644 --- a/app/Http/Controllers/QuoteController.php +++ b/app/Http/Controllers/QuoteController.php @@ -129,7 +129,8 @@ class QuoteController extends BaseController public function bulk() { - $action = Input::get('bulk_action') ?: Input::get('action');; + $action = Input::get('bulk_action') ?: Input::get('action'); + ; $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids')); if ($action == 'convert') { diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php index db1b83ba39..ed73fbe858 100644 --- a/app/Http/Controllers/RecurringInvoiceController.php +++ b/app/Http/Controllers/RecurringInvoiceController.php @@ -38,5 +38,4 @@ class RecurringInvoiceController extends BaseController return response()->view('list_wrapper', $data); } - } diff --git a/app/Http/Controllers/TaskApiController.php b/app/Http/Controllers/TaskApiController.php index 632a8b034d..10c2936190 100644 --- a/app/Http/Controllers/TaskApiController.php +++ b/app/Http/Controllers/TaskApiController.php @@ -117,7 +117,5 @@ class TaskApiController extends BaseAPIController $task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Input::all()); return $this->itemResponse($task); - } - } diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 452ce50eba..fe1809b876 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -54,8 +54,7 @@ class TaskController extends BaseController TaskRepository $taskRepo, InvoiceRepository $invoiceRepo, TaskService $taskService - ) - { + ) { // parent::__construct(); $this->taskRepo = $taskRepo; @@ -227,7 +226,7 @@ class TaskController extends BaseController $task = $this->taskRepo->save($publicId, Input::all()); - if($publicId) { + if ($publicId) { Session::flash('message', trans('texts.updated_task')); } else { Session::flash('message', trans('texts.created_task')); @@ -252,7 +251,7 @@ class TaskController extends BaseController $this->taskRepo->save($ids, ['action' => $action]); Session::flash('message', trans('texts.stopped_task')); return Redirect::to('tasks'); - } else if ($action == 'invoice' || $action == 'add_to_invoice') { + } elseif ($action == 'invoice' || $action == 'add_to_invoice') { $tasks = Task::scope($ids)->with('client')->orderBy('project_id', 'id')->get(); $clientPublicId = false; $data = []; @@ -262,7 +261,7 @@ class TaskController extends BaseController if ($task->client) { if (!$clientPublicId) { $clientPublicId = $task->client->public_id; - } else if ($clientPublicId != $task->client->public_id) { + } elseif ($clientPublicId != $task->client->public_id) { Session::flash('error', trans('texts.task_error_multiple_clients')); return Redirect::to('tasks'); } @@ -271,7 +270,7 @@ class TaskController extends BaseController if ($task->is_running) { Session::flash('error', trans('texts.task_error_running')); return Redirect::to('tasks'); - } else if ($task->invoice_id) { + } elseif ($task->invoice_id) { Session::flash('error', trans('texts.task_error_invoiced')); return Redirect::to('tasks'); } diff --git a/app/Http/Controllers/TokenController.php b/app/Http/Controllers/TokenController.php index 51e53b5d97..742218ed06 100644 --- a/app/Http/Controllers/TokenController.php +++ b/app/Http/Controllers/TokenController.php @@ -157,5 +157,4 @@ class TokenController extends BaseController return Redirect::to('settings/' . ACCOUNT_API_TOKENS); } - } diff --git a/app/Http/Controllers/UserApiController.php b/app/Http/Controllers/UserApiController.php index be37ecc66c..3bb82b13fd 100644 --- a/app/Http/Controllers/UserApiController.php +++ b/app/Http/Controllers/UserApiController.php @@ -64,4 +64,4 @@ class UserApiController extends BaseAPIController return $this->response($data); } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1f8dd1c0d0..4edc3a1b43 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -95,12 +95,12 @@ class UserController extends BaseController */ public function create() { - if ( ! Auth::user()->registered) { + if (! Auth::user()->registered) { Session::flash('error', trans('texts.register_to_add_user')); return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT); } - if ( ! Auth::user()->confirmed) { + if (! Auth::user()->confirmed) { Session::flash('error', trans('texts.confirmation_required')); return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT); } @@ -132,7 +132,7 @@ class UserController extends BaseController if ($action === 'archive') { $user->delete(); } else { - if ( ! Auth::user()->caddAddUsers()) { + if (! Auth::user()->caddAddUsers()) { return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT) ->with('error', trans('texts.max_users_reached')); } @@ -326,7 +326,7 @@ class UserController extends BaseController { $user = $this->accountRepo->findUser(Auth::user(), $accountKey); - if ( ! $user) { + if (! $user) { return redirect()->to('/'); } diff --git a/app/Http/Controllers/VendorApiController.php b/app/Http/Controllers/VendorApiController.php index c38e5867e2..b88c5831af 100644 --- a/app/Http/Controllers/VendorApiController.php +++ b/app/Http/Controllers/VendorApiController.php @@ -1,4 +1,5 @@ 'App\Http\Middleware\Authenticate', - 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', - 'permissions.required' => 'App\Http\Middleware\PermissionsRequired', - 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', + /** + * The application's route middleware. + * + * @var array + */ + protected $routeMiddleware = [ + 'auth' => 'App\Http\Middleware\Authenticate', + 'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth', + 'permissions.required' => 'App\Http\Middleware\PermissionsRequired', + 'guest' => 'App\Http\Middleware\RedirectIfAuthenticated', 'api' => 'App\Http\Middleware\ApiCheck', - ]; - + ]; } diff --git a/app/Http/Middleware/ApiCheck.php b/app/Http/Middleware/ApiCheck.php index 93de1b0c43..178f44ed4e 100644 --- a/app/Http/Middleware/ApiCheck.php +++ b/app/Http/Middleware/ApiCheck.php @@ -12,7 +12,8 @@ use App\Models\AccountToken; /** * Class ApiCheck */ -class ApiCheck { +class ApiCheck +{ /** * Handle an incoming request. @@ -38,7 +39,7 @@ class ApiCheck { if ($loggingIn) { // check API secret - if ( ! $hasApiSecret) { + if (! $hasApiSecret) { sleep(ERROR_DELAY); $error['error'] = ['message'=>'Invalid value for API_SECRET']; return Response::json($error, 403, $headers); @@ -81,7 +82,7 @@ class ApiCheck { $new_hour_throttle = $hour_throttle - $last_api_diff; $new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle; $new_hour_throttle += $hour / $hour_limit; - $hour_hits_remaining = floor(( $hour - $new_hour_throttle ) * $hour_limit / $hour); + $hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour); $hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0; } @@ -97,5 +98,4 @@ class ApiCheck { return $next($request); } - } diff --git a/app/Http/Middleware/PermissionsRequired.php b/app/Http/Middleware/PermissionsRequired.php index 636bc82c8b..25eb8999ec 100644 --- a/app/Http/Middleware/PermissionsRequired.php +++ b/app/Http/Middleware/PermissionsRequired.php @@ -14,7 +14,7 @@ class PermissionsRequired /** * @var array */ - static protected $actions = []; + protected static $actions = []; /** * Handle an incoming request. diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 1e0cb5a133..7addbfb53e 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -47,5 +47,4 @@ class RedirectIfAuthenticated return $next($request); } - } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index c18eb306cc..c7758f271e 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -122,9 +122,9 @@ class StartupCheck } // Check if the user is claiming a license (ie, additional invoices, white label, etc.) - if ( ! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) { + if (! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) { $claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license'); - if ( ! $claimingLicense && Input::has('license_key') && Input::has('product_id')) { + if (! $claimingLicense && Input::has('license_key') && Input::has('product_id')) { $licenseKey = Input::get('license_key'); $productId = Input::get('product_id'); @@ -170,7 +170,7 @@ class StartupCheck foreach ($cachedTables as $name => $class) { if (Input::has('clear_cache') || !Cache::has($name)) { // check that the table exists in case the migration is pending - if ( ! Schema::hasTable((new $class)->getTable())) { + if (! Schema::hasTable((new $class)->getTable())) { continue; } if ($name == 'paymentTerms') { diff --git a/app/Http/Requests/ClientRequest.php b/app/Http/Requests/ClientRequest.php index ec28cdb77d..8a9e853ee3 100644 --- a/app/Http/Requests/ClientRequest.php +++ b/app/Http/Requests/ClientRequest.php @@ -1,7 +1,7 @@ user()->hasFeature(FEATURE_DOCUMENTS)) { + if (! $this->user()->hasFeature(FEATURE_DOCUMENTS)) { return false; } @@ -43,5 +43,4 @@ class CreateDocumentRequest extends DocumentRequest //'file' => 'mimes:jpg' ]; } - } diff --git a/app/Http/Requests/CreateExpenseRequest.php b/app/Http/Requests/CreateExpenseRequest.php index dd096eebdc..3c7f1fd374 100644 --- a/app/Http/Requests/CreateExpenseRequest.php +++ b/app/Http/Requests/CreateExpenseRequest.php @@ -2,7 +2,7 @@ class CreateExpenseRequest extends ExpenseRequest { - // Expenses + // Expenses /** * Determine if the user is authorized to make this request. * diff --git a/app/Http/Requests/CreatePaymentAPIRequest.php b/app/Http/Requests/CreatePaymentAPIRequest.php index d809c4d3d0..3c5dd457e2 100644 --- a/app/Http/Requests/CreatePaymentAPIRequest.php +++ b/app/Http/Requests/CreatePaymentAPIRequest.php @@ -2,8 +2,6 @@ use App\Models\Invoice; - - class CreatePaymentAPIRequest extends PaymentRequest { /** @@ -26,7 +24,7 @@ class CreatePaymentAPIRequest extends PaymentRequest */ public function rules() { - if ( ! $this->invoice_id || ! $this->amount) { + if (! $this->invoice_id || ! $this->amount) { return [ 'invoice_id' => 'required|numeric|min:1', 'amount' => 'required|numeric|min:0.01', @@ -52,7 +50,4 @@ class CreatePaymentAPIRequest extends PaymentRequest return $rules; } - - - } diff --git a/app/Http/Requests/CreatePaymentRequest.php b/app/Http/Requests/CreatePaymentRequest.php index 9b45b2486d..cd7345e9eb 100644 --- a/app/Http/Requests/CreatePaymentRequest.php +++ b/app/Http/Requests/CreatePaymentRequest.php @@ -33,7 +33,7 @@ class CreatePaymentRequest extends PaymentRequest 'payment_date' => 'required', ]; - if ( ! empty($input['payment_type_id']) && $input['payment_type_id'] == PAYMENT_TYPE_CREDIT) { + if (! empty($input['payment_type_id']) && $input['payment_type_id'] == PAYMENT_TYPE_CREDIT) { $rules['payment_type_id'] = 'has_credit:'.$input['client'].','.$input['amount']; } diff --git a/app/Http/Requests/CreateTaxRateRequest.php b/app/Http/Requests/CreateTaxRateRequest.php index 6a83dc0cbc..a14d4262c6 100644 --- a/app/Http/Requests/CreateTaxRateRequest.php +++ b/app/Http/Requests/CreateTaxRateRequest.php @@ -1,10 +1,8 @@ entityType . '_id'; - if ( ! empty($this->$field)) { + if (! empty($this->$field)) { $publicId = $this->$field; } - if ( ! $publicId) { + if (! $publicId) { $field = Utils::pluralizeEntityType($this->entityType); - if ( ! empty($this->$field)) { + if (! empty($this->$field)) { $publicId = $this->$field; } } - if ( ! $publicId) { + if (! $publicId) { $publicId = Input::get('public_id') ?: Input::get('id'); } - if ( ! $publicId) { + if (! $publicId) { return null; } @@ -67,5 +67,4 @@ class EntityRequest extends Request { { return []; } - } diff --git a/app/Http/Requests/ExpenseCategoryRequest.php b/app/Http/Requests/ExpenseCategoryRequest.php index 810e7e56be..47a05b83dd 100644 --- a/app/Http/Requests/ExpenseCategoryRequest.php +++ b/app/Http/Requests/ExpenseCategoryRequest.php @@ -1,7 +1,6 @@ 'required|unique:users', 'first_name' => 'required', @@ -44,13 +43,13 @@ class RegisterRequest extends Request public function response(array $errors) { /* If the user is not validating from a mobile app - pass through parent::response */ - if(!isset($this->req->api_secret)) + 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 */ - foreach($errors as $error) { + foreach ($errors as $error) { foreach ($error as $key => $value) { - $message['error'] = ['message'=>$value]; $message = json_encode($message, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); @@ -59,5 +58,4 @@ class RegisterRequest extends Request } } } - } diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index f965e6af7b..7fa613457e 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -5,7 +5,8 @@ use Response; use App\Libraries\Utils; // https://laracasts.com/discuss/channels/general-discussion/laravel-5-modify-input-before-validation/replies/34366 -abstract class Request extends FormRequest { +abstract class Request extends FormRequest +{ // populate in subclass to auto load record protected $autoload = []; @@ -54,14 +55,13 @@ abstract class Request extends FormRequest { public function response(array $errors) { /* If the user is not validating from a mobile app - pass through parent::response */ - if ( ! request()->api_secret) { + if (! request()->api_secret) { return parent::response($errors); } /* If the user is validating from a mobile app - pass through first error string and return error */ - foreach($errors as $error) { + foreach ($errors as $error) { foreach ($error as $key => $value) { - $message['error'] = ['message'=>$value]; $message = json_encode($message, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); diff --git a/app/Http/Requests/SaveClientPortalSettings.php b/app/Http/Requests/SaveClientPortalSettings.php index 3c2485e7d7..6503ce86aa 100644 --- a/app/Http/Requests/SaveClientPortalSettings.php +++ b/app/Http/Requests/SaveClientPortalSettings.php @@ -48,11 +48,10 @@ class SaveClientPortalSettings extends Request $iframeURL = preg_replace('/[^a-zA-Z0-9_\-\:\/\.]/', '', $iframeURL); $input['iframe_url'] = rtrim($iframeURL, '/'); $input['subdomain'] = null; - } + } $this->replace($input); return $this->all(); } - } diff --git a/app/Http/Requests/SaveEmailSettings.php b/app/Http/Requests/SaveEmailSettings.php index 84f8c5baf8..98e58ed22b 100644 --- a/app/Http/Requests/SaveEmailSettings.php +++ b/app/Http/Requests/SaveEmailSettings.php @@ -23,5 +23,4 @@ class SaveEmailSettings extends Request 'bcc_email' => 'email', ]; } - } diff --git a/app/Http/Requests/TaskRequest.php b/app/Http/Requests/TaskRequest.php index 1e2783781f..e87b64bfe9 100644 --- a/app/Http/Requests/TaskRequest.php +++ b/app/Http/Requests/TaskRequest.php @@ -1,7 +1,6 @@ 'required', 'name' => sprintf('required|unique:expense_categories,name,%s,id,account_id,%s', $this->entity()->id, $this->user()->account_id), ]; diff --git a/app/Http/Requests/UpdateExpenseRequest.php b/app/Http/Requests/UpdateExpenseRequest.php index 55a7ae59bf..44379f4f3d 100644 --- a/app/Http/Requests/UpdateExpenseRequest.php +++ b/app/Http/Requests/UpdateExpenseRequest.php @@ -19,7 +19,7 @@ class UpdateExpenseRequest extends ExpenseRequest */ public function rules() { - return [ + return [ 'amount' => 'numeric', ]; } diff --git a/app/Http/Requests/UpdatePaymentRequest.php b/app/Http/Requests/UpdatePaymentRequest.php index 70a328d267..55f73241ff 100644 --- a/app/Http/Requests/UpdatePaymentRequest.php +++ b/app/Http/Requests/UpdatePaymentRequest.php @@ -20,6 +20,5 @@ class UpdatePaymentRequest extends PaymentRequest public function rules() { return []; - } } diff --git a/app/Http/Requests/UpdateProjectRequest.php b/app/Http/Requests/UpdateProjectRequest.php index cbc4a5b321..12269e18e5 100644 --- a/app/Http/Requests/UpdateProjectRequest.php +++ b/app/Http/Requests/UpdateProjectRequest.php @@ -19,7 +19,7 @@ class UpdateProjectRequest extends ProjectRequest */ public function rules() { - return [ + return [ 'name' => sprintf('required|unique:projects,name,%s,id,account_id,%s', $this->entity()->id, $this->user()->account_id), ]; } diff --git a/app/Http/Requests/UpdateTaxRateRequest.php b/app/Http/Requests/UpdateTaxRateRequest.php index e0a741ee96..b186001954 100644 --- a/app/Http/Requests/UpdateTaxRateRequest.php +++ b/app/Http/Requests/UpdateTaxRateRequest.php @@ -1,7 +1,5 @@ getLocale(); - if(preg_match('/_/', $code)) { + if (preg_match('/_/', $code)) { $codes = explode('_', $code); $code = $codes[0]; } return $code; } -} \ No newline at end of file +} diff --git a/app/Http/ViewComposers/ClientPortalHeaderComposer.php b/app/Http/ViewComposers/ClientPortalHeaderComposer.php index 7525b80bf6..3b85704a19 100644 --- a/app/Http/ViewComposers/ClientPortalHeaderComposer.php +++ b/app/Http/ViewComposers/ClientPortalHeaderComposer.php @@ -25,7 +25,7 @@ class ClientPortalHeaderComposer { $contactKey = session('contact_key'); - if ( ! $contactKey) { + if (! $contactKey) { return false; } @@ -33,7 +33,7 @@ class ClientPortalHeaderComposer ->with('client') ->first(); - if ( ! $contact || $contact->is_deleted) { + if (! $contact || $contact->is_deleted) { return false; } diff --git a/app/Http/ViewComposers/TranslationComposer.php b/app/Http/ViewComposers/TranslationComposer.php index 76a576ea54..c8049fc1ea 100644 --- a/app/Http/ViewComposers/TranslationComposer.php +++ b/app/Http/ViewComposers/TranslationComposer.php @@ -45,4 +45,4 @@ class TranslationComposer return $lang->name; })); } -} \ No newline at end of file +} diff --git a/app/Http/routes.php b/app/Http/routes.php index 91692222fb..cd6207f752 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -26,7 +26,7 @@ Route::get('/keep_alive', 'HomeController@keepAlive'); Route::post('/get_started', 'AccountController@getStarted'); // Client visible pages -Route::group(['middleware' => 'auth:client'], function() { +Route::group(['middleware' => 'auth:client'], function () { Route::get('view/{invitation_key}', 'ClientPortalController@view'); Route::get('download/{invitation_key}', 'ClientPortalController@download'); Route::put('sign/{invitation_key}', 'ClientPortalController@sign'); @@ -113,7 +113,7 @@ if (Utils::isReseller()) { Route::post('/reseller_stats', 'AppController@stats'); } -Route::group(['middleware' => 'auth:user'], function() { +Route::group(['middleware' => 'auth:user'], function () { Route::get('dashboard', 'DashboardController@index'); Route::get('dashboard_chart_data/{group_by}/{start_date}/{end_date}/{currency_id}/{include_expenses}', 'DashboardController@chartData'); Route::get('set_entity_filter/{entity_type}/{filter?}', 'AccountController@setEntityFilter'); @@ -216,17 +216,17 @@ Route::group(['middleware' => 'auth:user'], function() { Route::get('expense_categories/{expense_categories}/edit', 'ExpenseCategoryController@edit'); Route::post('expense_categories/bulk', 'ExpenseCategoryController@bulk'); - // BlueVine - Route::post('bluevine/signup', 'BlueVineController@signup'); - Route::get('bluevine/hide_message', 'BlueVineController@hideMessage'); - Route::get('bluevine/completed', 'BlueVineController@handleCompleted'); + // BlueVine + Route::post('bluevine/signup', 'BlueVineController@signup'); + Route::get('bluevine/hide_message', 'BlueVineController@hideMessage'); + Route::get('bluevine/completed', 'BlueVineController@handleCompleted'); Route::get('white_label/hide_message', 'NinjaController@hideWhiteLabelMessage'); }); Route::group([ 'middleware' => ['auth:user', 'permissions.required'], 'permissions' => 'admin', -], function() { +], function () { Route::get('api/users', 'UserController@getDatatable'); Route::resource('users', 'UserController'); Route::post('users/bulk', 'UserController@bulk'); @@ -282,13 +282,12 @@ Route::group([ Route::get('self-update/download', 'SelfUpdateController@download'); }); -Route::group(['middleware' => 'auth:user'], function() { +Route::group(['middleware' => 'auth:user'], function () { Route::get('settings/{section?}', 'AccountController@showSection'); }); // Route groups for API -Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() -{ +Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function () { Route::get('ping', 'AccountApiController@ping'); Route::post('login', 'AccountApiController@login'); Route::post('oauth_login', 'AccountApiController@oauthLogin'); @@ -310,7 +309,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() Route::resource('products', 'ProductApiController'); Route::resource('tax_rates', 'TaxRateApiController'); Route::resource('users', 'UserApiController'); - Route::resource('expenses','ExpenseApiController'); + Route::resource('expenses', 'ExpenseApiController'); Route::post('add_token', 'AccountApiController@addDeviceToken'); Route::post('update_notifications', 'AccountApiController@updatePushNotifications'); Route::get('dashboard', 'DashboardApiController@index'); @@ -320,37 +319,37 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() }); // Redirects for legacy links -Route::get('/rocksteady', function() { +Route::get('/rocksteady', function () { return Redirect::to(NINJA_WEB_URL, 301); }); -Route::get('/about', function() { +Route::get('/about', function () { return Redirect::to(NINJA_WEB_URL, 301); }); -Route::get('/contact', function() { +Route::get('/contact', function () { return Redirect::to(NINJA_WEB_URL.'/contact', 301); }); -Route::get('/plans', function() { +Route::get('/plans', function () { return Redirect::to(NINJA_WEB_URL.'/pricing', 301); }); -Route::get('/faq', function() { +Route::get('/faq', function () { return Redirect::to(NINJA_WEB_URL.'/how-it-works', 301); }); -Route::get('/features', function() { +Route::get('/features', function () { return Redirect::to(NINJA_WEB_URL.'/features', 301); }); -Route::get('/testimonials', function() { +Route::get('/testimonials', function () { return Redirect::to(NINJA_WEB_URL, 301); }); -Route::get('/compare-online-invoicing{sites?}', function() { +Route::get('/compare-online-invoicing{sites?}', function () { return Redirect::to(NINJA_WEB_URL, 301); }); -Route::get('/forgot', function() { +Route::get('/forgot', function () { return Redirect::to(NINJA_APP_URL.'/recover_password', 301); }); -Route::get('/feed', function() { +Route::get('/feed', function () { return Redirect::to(NINJA_WEB_URL.'/feed', 301); }); -Route::get('/comments/feed', function() { +Route::get('/comments/feed', function () { return Redirect::to(NINJA_WEB_URL.'/comments/feed', 301); }); diff --git a/app/Includes/parsecsv.lib.php b/app/Includes/parsecsv.lib.php index 797beef303..8d47887d7a 100644 --- a/app/Includes/parsecsv.lib.php +++ b/app/Includes/parsecsv.lib.php @@ -1,695 +1,784 @@ data); - ---------------- - # tab delimited, and encoding conversion - $csv = new parseCSV(); - $csv->encoding('UTF-16', 'UTF-8'); - $csv->delimiter = "\t"; - $csv->parse('data.tsv'); - print_r($csv->data); - ---------------- - # auto-detect delimiter character - $csv = new parseCSV(); - $csv->auto('data.csv'); - print_r($csv->data); - ---------------- - # modify data in a csv file - $csv = new parseCSV(); - $csv->sort_by = 'id'; - $csv->parse('data.csv'); - # "4" is the value of the "id" column of the CSV row - $csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com'); - $csv->save(); - ---------------- - # add row/entry to end of CSV file - # - only recommended when you know the extact sctructure of the file - $csv = new parseCSV(); - $csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true); - ---------------- - # convert 2D array to csv data and send headers - # to browser to treat output as a file and download it - $csv = new parseCSV(); - $csv->output (true, 'movies.csv', $array); - ---------------- + Code Examples + ---------------- + # general usage + $csv = new parseCSV('data.csv'); + print_r($csv->data); + ---------------- + # tab delimited, and encoding conversion + $csv = new parseCSV(); + $csv->encoding('UTF-16', 'UTF-8'); + $csv->delimiter = "\t"; + $csv->parse('data.tsv'); + print_r($csv->data); + ---------------- + # auto-detect delimiter character + $csv = new parseCSV(); + $csv->auto('data.csv'); + print_r($csv->data); + ---------------- + # modify data in a csv file + $csv = new parseCSV(); + $csv->sort_by = 'id'; + $csv->parse('data.csv'); + # "4" is the value of the "id" column of the CSV row + $csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com'); + $csv->save(); + ---------------- + # add row/entry to end of CSV file + # - only recommended when you know the extact sctructure of the file + $csv = new parseCSV(); + $csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true); + ---------------- + # convert 2D array to csv data and send headers + # to browser to treat output as a file and download it + $csv = new parseCSV(); + $csv->output (true, 'movies.csv', $array); + ---------------- */ - /** - * Configuration - * - set these options with $object->var_name = 'value'; - */ - - # use first line/entry as field names - var $heading = true; - - # override field names - var $fields = []; - - # sort entries by this field - var $sort_by = null; - var $sort_reverse = false; - - # delimiter (comma) and enclosure (double quote) - var $delimiter = ','; - var $enclosure = '"'; - - # basic SQL-like conditions for row matching - var $conditions = null; - - # number of rows to ignore from beginning of data - var $offset = null; - - # limits the number of returned rows to specified amount - var $limit = null; - - # number of rows to analyze when attempting to auto-detect delimiter - var $auto_depth = 15; - - # characters to ignore when attempting to auto-detect delimiter - var $auto_non_chars = "a-zA-Z0-9\n\r"; - - # preferred delimiter characters, only used when all filtering method - # returns multiple possible delimiters (happens very rarely) - var $auto_preferred = ",;\t.:|"; - - # character encoding options - var $convert_encoding = false; - var $input_encoding = 'ISO-8859-1'; - var $output_encoding = 'ISO-8859-1'; - - # used by unparse(), save(), and output() functions - var $linefeed = "\r\n"; - - # only used by output() function - var $output_delimiter = ','; - var $output_filename = 'data.csv'; - - - /** - * Internal variables - */ - - # current file - var $file; - - # loaded file contents - var $file_data; - - # array of field values in data parsed - var $titles = []; - - # two dimentional array of CSV data - var $data = []; - - - /** - * Constructor - * @param input CSV file or string - * @return nothing - */ - function __construct ($input = null, $offset = null, $limit = null, $conditions = null) { - if ( $offset !== null ) $this->offset = $offset; - if ( $limit !== null ) $this->limit = $limit; - if ( count($conditions) > 0 ) $this->conditions = $conditions; - if ( !empty($input) ) $this->parse($input); - } - - - // ============================================== - // ----- [ Main Functions ] --------------------- - // ============================================== - - /** - * Parse CSV file or string - * @param input CSV file or string - * @return nothing - */ - function parse ($input = null, $offset = null, $limit = null, $conditions = null) { - if ( !empty($input) ) { - if ( $offset !== null ) $this->offset = $offset; - if ( $limit !== null ) $this->limit = $limit; - if ( count($conditions) > 0 ) $this->conditions = $conditions; - if ( is_readable($input) ) { - $this->data = $this->parse_file($input); - } else { - $this->file_data = &$input; - $this->data = $this->parse_string(); - } - if ( $this->data === false ) return false; - } - return true; - } - - /** - * Save changes, or new file and/or data - * @param file file to save to - * @param data 2D array with data - * @param append append current data to end of target CSV if exists - * @param fields field names - * @return true or false - */ - function save ($file = null, $data = [], $append = false, $fields = []) { - if ( empty($file) ) $file = &$this->file; - $mode = ( $append ) ? 'at' : 'wt' ; - $is_php = ( preg_match('/\.php$/i', $file) ) ? true : false ; - return $this->_wfile($file, $this->unparse($data, $fields, $append, $is_php), $mode); - } - - /** - * Generate CSV based string for output - * @param output if true, prints headers and strings to browser - * @param filename filename sent to browser in headers if output is true - * @param data 2D array with data - * @param fields field names - * @param delimiter delimiter used to separate data - * @return CSV data using delimiter of choice, or default - */ - function output ($output = true, $filename = null, $data = [], $fields = [], $delimiter = null) { - if ( empty($filename) ) $filename = $this->output_filename; - if ( $delimiter === null ) $delimiter = $this->output_delimiter; - $data = $this->unparse($data, $fields, null, null, $delimiter); - if ( $output ) { - header('Content-type: application/csv'); - header('Content-Disposition: inline; filename="'.$filename.'"'); - echo $data; - } - return $data; - } - - /** - * Convert character encoding - * @param input input character encoding, uses default if left blank - * @param output output character encoding, uses default if left blank - * @return nothing - */ - function encoding ($input = null, $output = null) { - $this->convert_encoding = true; - if ( $input !== null ) $this->input_encoding = $input; - if ( $output !== null ) $this->output_encoding = $output; - } - - /** - * Auto-Detect Delimiter: Find delimiter by analyzing a specific number of - * rows to determine most probable delimiter character - * @param file local CSV file - * @param parse true/false parse file directly - * @param search_depth number of rows to analyze - * @param preferred preferred delimiter characters - * @param enclosure enclosure character, default is double quote ("). - * @return delimiter character - */ - function auto ($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) { - - if ( $file === null ) $file = $this->file; - if ( empty($search_depth) ) $search_depth = $this->auto_depth; - if ( $enclosure === null ) $enclosure = $this->enclosure; - - if ( $preferred === null ) $preferred = $this->auto_preferred; - - if ( empty($this->file_data) ) { - if ( $this->_check_data($file) ) { - $data = &$this->file_data; - } else return false; - } else { - $data = &$this->file_data; - } - - $chars = []; - $strlen = strlen($data); - $enclosed = false; - $n = 1; - $to_end = true; - - // walk specific depth finding posssible delimiter characters - for ( $i=0; $i < $strlen; $i++ ) { - $ch = $data{$i}; - $nch = ( isset($data{$i+1}) ) ? $data{$i+1} : false ; - $pch = ( isset($data{$i-1}) ) ? $data{$i-1} : false ; - - // open and closing quotes - if ( $ch == $enclosure && (!$enclosed || $nch != $enclosure) ) { - $enclosed = ( $enclosed ) ? false : true ; - - // inline quotes - } elseif ( $ch == $enclosure && $enclosed ) { - $i++; - - // end of row - } elseif ( ($ch == "\n" && $pch != "\r" || $ch == "\r") && !$enclosed ) { - if ( $n >= $search_depth ) { - $strlen = 0; - $to_end = false; - } else { - $n++; - } - - // count character - } elseif (!$enclosed) { - if ( !preg_match('/['.preg_quote($this->auto_non_chars, '/').']/i', $ch) ) { - if ( !isset($chars[$ch][$n]) ) { - $chars[$ch][$n] = 1; - } else { - $chars[$ch][$n]++; - } - } - } - } - - // filtering - $depth = ( $to_end ) ? $n-1 : $n ; - $filtered = []; - foreach( $chars as $char => $value ) { - if ( $match = $this->_check_count($char, $value, $depth, $preferred) ) { - $filtered[$match] = $char; - } - } - - // capture most probable delimiter - ksort($filtered); - $delimiter = reset($filtered); - $this->delimiter = $delimiter; - - // parse data - if ( $parse ) $this->data = $this->parse_string(); - - return $delimiter; - - } - - - // ============================================== - // ----- [ Core Functions ] --------------------- - // ============================================== - - /** - * Read file to string and call parse_string() - * @param file local CSV file - * @return 2D array with CSV data, or false on failure - */ - function parse_file ($file = null) { - if ( $file === null ) $file = $this->file; - if ( empty($this->file_data) ) $this->load_data($file); - return ( !empty($this->file_data) ) ? $this->parse_string() : false ; - } - - /** - * Parse CSV strings to arrays - * @param data CSV string - * @return 2D array with CSV data, or false on failure - */ - function parse_string ($data = null) { - if ( empty($data) ) { - if ( $this->_check_data() ) { - $data = &$this->file_data; - } else return false; - } - - $rows = []; - $row = []; - $row_count = 0; - $current = ''; - $head = ( !empty($this->fields) ) ? $this->fields : [] ; - $col = 0; - $enclosed = false; - $was_enclosed = false; - $strlen = strlen($data); - - // walk through each character - for ( $i=0; $i < $strlen; $i++ ) { - $ch = $data{$i}; - $nch = ( isset($data{$i+1}) ) ? $data{$i+1} : false ; - $pch = ( isset($data{$i-1}) ) ? $data{$i-1} : false ; - - // open and closing quotes - if ( $ch == $this->enclosure && (!$enclosed || $nch != $this->enclosure) ) { - $enclosed = ( $enclosed ) ? false : true ; - if ( $enclosed ) $was_enclosed = true; - - // inline quotes - } elseif ( $ch == $this->enclosure && $enclosed ) { - $current .= $ch; - $i++; - - // end of field/row - } elseif ( ($ch == $this->delimiter || ($ch == "\n" && $pch != "\r") || $ch == "\r") && !$enclosed ) { - if ( !$was_enclosed ) $current = trim($current); - $key = ( !empty($head[$col]) ) ? $head[$col] : $col ; - $row[$key] = $current; - $current = ''; - $col++; - - // end of row - if ( $ch == "\n" || $ch == "\r" ) { - if ( $this->_validate_offset($row_count) && $this->_validate_row_conditions($row, $this->conditions) ) { - if ( $this->heading && empty($head) ) { - $head = $row; - } elseif ( empty($this->fields) || (!empty($this->fields) && (($this->heading && $row_count > 0) || !$this->heading)) ) { - if ( !empty($this->sort_by) && !empty($row[$this->sort_by]) ) { - if ( isset($rows[$row[$this->sort_by]]) ) { - $rows[$row[$this->sort_by].'_0'] = &$rows[$row[$this->sort_by]]; - unset($rows[$row[$this->sort_by]]); - for ( $sn=1; isset($rows[$row[$this->sort_by].'_'.$sn]); $sn++ ) {} - $rows[$row[$this->sort_by].'_'.$sn] = $row; - } else $rows[$row[$this->sort_by]] = $row; - } else $rows[] = $row; - } - } - $row = []; - $col = 0; - $row_count++; - if ( $this->sort_by === null && $this->limit !== null && count($rows) == $this->limit ) { - $i = $strlen; - } - } - - // append character to current field - } else { - $current .= $ch; - } - } - $this->titles = $head; - if ( !empty($this->sort_by) ) { - ( $this->sort_reverse ) ? krsort($rows) : ksort($rows) ; - if ( $this->offset !== null || $this->limit !== null ) { - $rows = array_slice($rows, ($this->offset === null ? 0 : $this->offset) , $this->limit, true); - } - } - return $rows; - } - - /** - * Create CSV data from array - * @param data 2D array with data - * @param fields field names - * @param append if true, field names will not be output - * @param is_php if a php die() call should be put on the first - * line of the file, this is later ignored when read. - * @param delimiter field delimiter to use - * @return CSV data (text string) - */ - function unparse ( $data = [], $fields = [], $append = false , $is_php = false, $delimiter = null) { - if ( !is_array($data) || empty($data) ) $data = &$this->data; - if ( !is_array($fields) || empty($fields) ) $fields = &$this->titles; - if ( $delimiter === null ) $delimiter = $this->delimiter; - - $string = ( $is_php ) ? "".$this->linefeed : '' ; - $entry = []; - - // create heading - if ( $this->heading && !$append ) { - foreach( $fields as $key => $value ) { - $entry[] = $this->_enclose_value($value); - } - $string .= implode($delimiter, $entry).$this->linefeed; - $entry = []; - } - - // create data - foreach( $data as $key => $row ) { - foreach( $row as $field => $value ) { - $entry[] = $this->_enclose_value($value); - } - $string .= implode($delimiter, $entry).$this->linefeed; - $entry = []; - } - - return $string; - } - - /** - * Load local file or string - * @param input local CSV file - * @return true or false - */ - function load_data ($input = null) { - $data = null; - $file = null; - if ( $input === null ) { - $file = $this->file; - } elseif ( file_exists($input) ) { - $file = $input; - } else { - $data = $input; - } - if ( !empty($data) || $data = $this->_rfile($file) ) { - if ( $this->file != $file ) $this->file = $file; - if ( preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ims', $data, $strip) ) { - $data = ltrim($strip[1]); - } - if ( $this->convert_encoding ) $data = iconv($this->input_encoding, $this->output_encoding, $data); - if ( substr($data, -1) != "\n" ) $data .= "\n"; - $this->file_data = &$data; - return true; - } - return false; - } - - - // ============================================== - // ----- [ Internal Functions ] ----------------- - // ============================================== - - /** - * Validate a row against specified conditions - * @param row array with values from a row - * @param conditions specified conditions that the row must match - * @return true of false - */ - function _validate_row_conditions ($row = [], $conditions = null) { - if ( !empty($row) ) { - if ( !empty($conditions) ) { - $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : [$conditions] ; - $or = ''; - foreach( $conditions as $key => $value ) { - if ( strpos($value, ' AND ') !== false ) { - $value = explode(' AND ', $value); - $and = ''; - foreach( $value as $k => $v ) { - $and .= $this->_validate_row_condition($row, $v); - } - $or .= (strpos($and, '0') !== false) ? '0' : '1' ; - } else { - $or .= $this->_validate_row_condition($row, $value); - } - } - return (strpos($or, '1') !== false) ? true : false ; - } - return true; - } - return false; - } - - /** - * Validate a row against a single condition - * @param row array with values from a row - * @param condition specified condition that the row must match - * @return true of false - */ - function _validate_row_condition ($row, $condition) { - $operators = [ - '=', 'equals', 'is', - '!=', 'is not', - '<', 'is less than', - '>', 'is greater than', - '<=', 'is less than or equals', - '>=', 'is greater than or equals', - 'contains', - 'does not contain', - ]; - $operators_regex = []; - foreach( $operators as $value ) { - $operators_regex[] = preg_quote($value, '/'); - } - $operators_regex = implode('|', $operators_regex); - if ( preg_match('/^(.+) ('.$operators_regex.') (.+)$/i', trim($condition), $capture) ) { - $field = $capture[1]; - $op = $capture[2]; - $value = $capture[3]; - if ( preg_match('/^([\'\"]{1})(.*)([\'\"]{1})$/i', $value, $capture) ) { - if ( $capture[1] == $capture[3] ) { - $value = $capture[2]; - $value = str_replace('\\n', "\n", $value); - $value = str_replace('\\r', "\r", $value); - $value = str_replace('\\t', "\t", $value); - $value = stripslashes($value); - } - } - if ( array_key_exists($field, $row) ) { - if ( ($op == '=' || $op == 'equals' || $op == 'is') && $row[$field] == $value ) { - return '1'; - } elseif ( ($op == '!=' || $op == 'is not') && $row[$field] != $value ) { - return '1'; - } elseif ( ($op == '<' || $op == 'is less than' ) && $row[$field] < $value ) { - return '1'; - } elseif ( ($op == '>' || $op == 'is greater than') && $row[$field] > $value ) { - return '1'; - } elseif ( ($op == '<=' || $op == 'is less than or equals' ) && $row[$field] <= $value ) { - return '1'; - } elseif ( ($op == '>=' || $op == 'is greater than or equals') && $row[$field] >= $value ) { - return '1'; - } elseif ( $op == 'contains' && preg_match('/'.preg_quote($value, '/').'/i', $row[$field]) ) { - return '1'; - } elseif ( $op == 'does not contain' && !preg_match('/'.preg_quote($value, '/').'/i', $row[$field]) ) { - return '1'; - } else { - return '0'; - } - } - } - return '1'; - } - - /** - * Validates if the row is within the offset or not if sorting is disabled - * @param current_row the current row number being processed - * @return true of false - */ - function _validate_offset ($current_row) { - if ( $this->sort_by === null && $this->offset !== null && $current_row < $this->offset ) return false; - return true; - } - - /** - * Enclose values if needed - * - only used by unparse() - * @param value string to process - * @return Processed value - */ - function _enclose_value ($value = null) { - if ( $value !== null && $value != '' ) { - $delimiter = preg_quote($this->delimiter, '/'); - $enclosure = preg_quote($this->enclosure, '/'); - if ( preg_match('/'.$delimiter.'|'.$enclosure."|\n|\r/i", $value) || ($value{0} == ' ' || substr($value, -1) == ' ') ) { - $value = str_replace($this->enclosure, $this->enclosure.$this->enclosure, $value); - $value = $this->enclosure.$value.$this->enclosure; - } - } - return $value; - } - - /** - * Check file data - * @param file local filename - * @return true or false - */ - function _check_data ($file = null) { - if ( empty($this->file_data) ) { - if ( $file === null ) $file = $this->file; - return $this->load_data($file); - } - return true; - } - - - /** - * Check if passed info might be delimiter - * - only used by find_delimiter() - * @return special string used for delimiter selection, or false - */ - function _check_count ($char, $array, $depth, $preferred) { - if ( $depth == count($array) ) { - $first = null; - $equal = null; - $almost = false; - foreach( $array as $key => $value ) { - if ( $first == null ) { - $first = $value; - } elseif ( $value == $first && $equal !== false) { - $equal = true; - } elseif ( $value == $first+1 && $equal !== false ) { - $equal = true; - $almost = true; - } else { - $equal = false; - } - } - if ( $equal ) { - $match = ( $almost ) ? 2 : 1 ; - $pref = strpos($preferred, $char); - $pref = ( $pref !== false ) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999' ; - return $pref.$match.'.'.(99999 - str_pad($first, 5, '0', STR_PAD_LEFT)); - } else return false; - } - } - - /** - * Read local file - * @param file local filename - * @return Data from file, or false on failure - */ - function _rfile ($file = null) { - if ( is_readable($file) ) { - if ( !($fh = fopen($file, 'r')) ) return false; - $data = fread($fh, filesize($file)); - fclose($fh); - return $data; - } - return false; - } - - /** - * Write to local file - * @param file local filename - * @param string data to write to file - * @param mode fopen() mode - * @param lock flock() mode - * @return true or false - */ - function _wfile ($file, $string = '', $mode = 'wb', $lock = 2) { - if ( $fp = fopen($file, $mode) ) { - flock($fp, $lock); - $re = fwrite($fp, $string); - $re2 = fclose($fp); - if ( $re != false && $re2 != false ) return true; - } - return false; - } - + /** + * Configuration + * - set these options with $object->var_name = 'value'; + */ + + # use first line/entry as field names + public $heading = true; + + # override field names + public $fields = []; + + # sort entries by this field + public $sort_by = null; + public $sort_reverse = false; + + # delimiter (comma) and enclosure (double quote) + public $delimiter = ','; + public $enclosure = '"'; + + # basic SQL-like conditions for row matching + public $conditions = null; + + # number of rows to ignore from beginning of data + public $offset = null; + + # limits the number of returned rows to specified amount + public $limit = null; + + # number of rows to analyze when attempting to auto-detect delimiter + public $auto_depth = 15; + + # characters to ignore when attempting to auto-detect delimiter + public $auto_non_chars = "a-zA-Z0-9\n\r"; + + # preferred delimiter characters, only used when all filtering method + # returns multiple possible delimiters (happens very rarely) + public $auto_preferred = ",;\t.:|"; + + # character encoding options + public $convert_encoding = false; + public $input_encoding = 'ISO-8859-1'; + public $output_encoding = 'ISO-8859-1'; + + # used by unparse(), save(), and output() functions + public $linefeed = "\r\n"; + + # only used by output() function + public $output_delimiter = ','; + public $output_filename = 'data.csv'; + + + /** + * Internal variables + */ + + # current file + public $file; + + # loaded file contents + public $file_data; + + # array of field values in data parsed + public $titles = []; + + # two dimentional array of CSV data + public $data = []; + + + /** + * Constructor + * @param input CSV file or string + * @return nothing + */ + public function __construct($input = null, $offset = null, $limit = null, $conditions = null) + { + if ($offset !== null) { + $this->offset = $offset; + } + if ($limit !== null) { + $this->limit = $limit; + } + if (count($conditions) > 0) { + $this->conditions = $conditions; + } + if (!empty($input)) { + $this->parse($input); + } + } + + + // ============================================== + // ----- [ Main Functions ] --------------------- + // ============================================== + + /** + * Parse CSV file or string + * @param input CSV file or string + * @return nothing + */ + public function parse($input = null, $offset = null, $limit = null, $conditions = null) + { + if (!empty($input)) { + if ($offset !== null) { + $this->offset = $offset; + } + if ($limit !== null) { + $this->limit = $limit; + } + if (count($conditions) > 0) { + $this->conditions = $conditions; + } + if (is_readable($input)) { + $this->data = $this->parse_file($input); + } else { + $this->file_data = &$input; + $this->data = $this->parse_string(); + } + if ($this->data === false) { + return false; + } + } + return true; + } + + /** + * Save changes, or new file and/or data + * @param file file to save to + * @param data 2D array with data + * @param append append current data to end of target CSV if exists + * @param fields field names + * @return true or false + */ + public function save($file = null, $data = [], $append = false, $fields = []) + { + if (empty($file)) { + $file = &$this->file; + } + $mode = ($append) ? 'at' : 'wt' ; + $is_php = (preg_match('/\.php$/i', $file)) ? true : false ; + return $this->_wfile($file, $this->unparse($data, $fields, $append, $is_php), $mode); + } + + /** + * Generate CSV based string for output + * @param output if true, prints headers and strings to browser + * @param filename filename sent to browser in headers if output is true + * @param data 2D array with data + * @param fields field names + * @param delimiter delimiter used to separate data + * @return CSV data using delimiter of choice, or default + */ + public function output($output = true, $filename = null, $data = [], $fields = [], $delimiter = null) + { + if (empty($filename)) { + $filename = $this->output_filename; + } + if ($delimiter === null) { + $delimiter = $this->output_delimiter; + } + $data = $this->unparse($data, $fields, null, null, $delimiter); + if ($output) { + header('Content-type: application/csv'); + header('Content-Disposition: inline; filename="'.$filename.'"'); + echo $data; + } + return $data; + } + + /** + * Convert character encoding + * @param input input character encoding, uses default if left blank + * @param output output character encoding, uses default if left blank + * @return nothing + */ + public function encoding($input = null, $output = null) + { + $this->convert_encoding = true; + if ($input !== null) { + $this->input_encoding = $input; + } + if ($output !== null) { + $this->output_encoding = $output; + } + } + + /** + * Auto-Detect Delimiter: Find delimiter by analyzing a specific number of + * rows to determine most probable delimiter character + * @param file local CSV file + * @param parse true/false parse file directly + * @param search_depth number of rows to analyze + * @param preferred preferred delimiter characters + * @param enclosure enclosure character, default is double quote ("). + * @return delimiter character + */ + public function auto($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) + { + if ($file === null) { + $file = $this->file; + } + if (empty($search_depth)) { + $search_depth = $this->auto_depth; + } + if ($enclosure === null) { + $enclosure = $this->enclosure; + } + + if ($preferred === null) { + $preferred = $this->auto_preferred; + } + + if (empty($this->file_data)) { + if ($this->_check_data($file)) { + $data = &$this->file_data; + } else { + return false; + } + } else { + $data = &$this->file_data; + } + + $chars = []; + $strlen = strlen($data); + $enclosed = false; + $n = 1; + $to_end = true; + + // walk specific depth finding posssible delimiter characters + for ($i=0; $i < $strlen; $i++) { + $ch = $data{$i}; + $nch = (isset($data{$i+1})) ? $data{$i+1} : false ; + $pch = (isset($data{$i-1})) ? $data{$i-1} : false ; + + // open and closing quotes + if ($ch == $enclosure && (!$enclosed || $nch != $enclosure)) { + $enclosed = ($enclosed) ? false : true ; + + // inline quotes + } elseif ($ch == $enclosure && $enclosed) { + $i++; + + // end of row + } elseif (($ch == "\n" && $pch != "\r" || $ch == "\r") && !$enclosed) { + if ($n >= $search_depth) { + $strlen = 0; + $to_end = false; + } else { + $n++; + } + + // count character + } elseif (!$enclosed) { + if (!preg_match('/['.preg_quote($this->auto_non_chars, '/').']/i', $ch)) { + if (!isset($chars[$ch][$n])) { + $chars[$ch][$n] = 1; + } else { + $chars[$ch][$n]++; + } + } + } + } + + // filtering + $depth = ($to_end) ? $n-1 : $n ; + $filtered = []; + foreach ($chars as $char => $value) { + if ($match = $this->_check_count($char, $value, $depth, $preferred)) { + $filtered[$match] = $char; + } + } + + // capture most probable delimiter + ksort($filtered); + $delimiter = reset($filtered); + $this->delimiter = $delimiter; + + // parse data + if ($parse) { + $this->data = $this->parse_string(); + } + + return $delimiter; + } + + + // ============================================== + // ----- [ Core Functions ] --------------------- + // ============================================== + + /** + * Read file to string and call parse_string() + * @param file local CSV file + * @return 2D array with CSV data, or false on failure + */ + public function parse_file($file = null) + { + if ($file === null) { + $file = $this->file; + } + if (empty($this->file_data)) { + $this->load_data($file); + } + return (!empty($this->file_data)) ? $this->parse_string() : false ; + } + + /** + * Parse CSV strings to arrays + * @param data CSV string + * @return 2D array with CSV data, or false on failure + */ + public function parse_string($data = null) + { + if (empty($data)) { + if ($this->_check_data()) { + $data = &$this->file_data; + } else { + return false; + } + } + + $rows = []; + $row = []; + $row_count = 0; + $current = ''; + $head = (!empty($this->fields)) ? $this->fields : [] ; + $col = 0; + $enclosed = false; + $was_enclosed = false; + $strlen = strlen($data); + + // walk through each character + for ($i=0; $i < $strlen; $i++) { + $ch = $data{$i}; + $nch = (isset($data{$i+1})) ? $data{$i+1} : false ; + $pch = (isset($data{$i-1})) ? $data{$i-1} : false ; + + // open and closing quotes + if ($ch == $this->enclosure && (!$enclosed || $nch != $this->enclosure)) { + $enclosed = ($enclosed) ? false : true ; + if ($enclosed) { + $was_enclosed = true; + } + + // inline quotes + } elseif ($ch == $this->enclosure && $enclosed) { + $current .= $ch; + $i++; + + // end of field/row + } elseif (($ch == $this->delimiter || ($ch == "\n" && $pch != "\r") || $ch == "\r") && !$enclosed) { + if (!$was_enclosed) { + $current = trim($current); + } + $key = (!empty($head[$col])) ? $head[$col] : $col ; + $row[$key] = $current; + $current = ''; + $col++; + + // end of row + if ($ch == "\n" || $ch == "\r") { + if ($this->_validate_offset($row_count) && $this->_validate_row_conditions($row, $this->conditions)) { + if ($this->heading && empty($head)) { + $head = $row; + } elseif (empty($this->fields) || (!empty($this->fields) && (($this->heading && $row_count > 0) || !$this->heading))) { + if (!empty($this->sort_by) && !empty($row[$this->sort_by])) { + if (isset($rows[$row[$this->sort_by]])) { + $rows[$row[$this->sort_by].'_0'] = &$rows[$row[$this->sort_by]]; + unset($rows[$row[$this->sort_by]]); + for ($sn=1; isset($rows[$row[$this->sort_by].'_'.$sn]); $sn++) { + } + $rows[$row[$this->sort_by].'_'.$sn] = $row; + } else { + $rows[$row[$this->sort_by]] = $row; + } + } else { + $rows[] = $row; + } + } + } + $row = []; + $col = 0; + $row_count++; + if ($this->sort_by === null && $this->limit !== null && count($rows) == $this->limit) { + $i = $strlen; + } + } + + // append character to current field + } else { + $current .= $ch; + } + } + $this->titles = $head; + if (!empty($this->sort_by)) { + ($this->sort_reverse) ? krsort($rows) : ksort($rows) ; + if ($this->offset !== null || $this->limit !== null) { + $rows = array_slice($rows, ($this->offset === null ? 0 : $this->offset), $this->limit, true); + } + } + return $rows; + } + + /** + * Create CSV data from array + * @param data 2D array with data + * @param fields field names + * @param append if true, field names will not be output + * @param is_php if a php die() call should be put on the first + * line of the file, this is later ignored when read. + * @param delimiter field delimiter to use + * @return CSV data (text string) + */ + public function unparse($data = [], $fields = [], $append = false, $is_php = false, $delimiter = null) + { + if (!is_array($data) || empty($data)) { + $data = &$this->data; + } + if (!is_array($fields) || empty($fields)) { + $fields = &$this->titles; + } + if ($delimiter === null) { + $delimiter = $this->delimiter; + } + + $string = ($is_php) ? "".$this->linefeed : '' ; + $entry = []; + + // create heading + if ($this->heading && !$append) { + foreach ($fields as $key => $value) { + $entry[] = $this->_enclose_value($value); + } + $string .= implode($delimiter, $entry).$this->linefeed; + $entry = []; + } + + // create data + foreach ($data as $key => $row) { + foreach ($row as $field => $value) { + $entry[] = $this->_enclose_value($value); + } + $string .= implode($delimiter, $entry).$this->linefeed; + $entry = []; + } + + return $string; + } + + /** + * Load local file or string + * @param input local CSV file + * @return true or false + */ + public function load_data($input = null) + { + $data = null; + $file = null; + if ($input === null) { + $file = $this->file; + } elseif (file_exists($input)) { + $file = $input; + } else { + $data = $input; + } + if (!empty($data) || $data = $this->_rfile($file)) { + if ($this->file != $file) { + $this->file = $file; + } + if (preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ims', $data, $strip)) { + $data = ltrim($strip[1]); + } + if ($this->convert_encoding) { + $data = iconv($this->input_encoding, $this->output_encoding, $data); + } + if (substr($data, -1) != "\n") { + $data .= "\n"; + } + $this->file_data = &$data; + return true; + } + return false; + } + + + // ============================================== + // ----- [ Internal Functions ] ----------------- + // ============================================== + + /** + * Validate a row against specified conditions + * @param row array with values from a row + * @param conditions specified conditions that the row must match + * @return true of false + */ + public function _validate_row_conditions($row = [], $conditions = null) + { + if (!empty($row)) { + if (!empty($conditions)) { + $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : [$conditions] ; + $or = ''; + foreach ($conditions as $key => $value) { + if (strpos($value, ' AND ') !== false) { + $value = explode(' AND ', $value); + $and = ''; + foreach ($value as $k => $v) { + $and .= $this->_validate_row_condition($row, $v); + } + $or .= (strpos($and, '0') !== false) ? '0' : '1' ; + } else { + $or .= $this->_validate_row_condition($row, $value); + } + } + return (strpos($or, '1') !== false) ? true : false ; + } + return true; + } + return false; + } + + /** + * Validate a row against a single condition + * @param row array with values from a row + * @param condition specified condition that the row must match + * @return true of false + */ + public function _validate_row_condition($row, $condition) + { + $operators = [ + '=', 'equals', 'is', + '!=', 'is not', + '<', 'is less than', + '>', 'is greater than', + '<=', 'is less than or equals', + '>=', 'is greater than or equals', + 'contains', + 'does not contain', + ]; + $operators_regex = []; + foreach ($operators as $value) { + $operators_regex[] = preg_quote($value, '/'); + } + $operators_regex = implode('|', $operators_regex); + if (preg_match('/^(.+) ('.$operators_regex.') (.+)$/i', trim($condition), $capture)) { + $field = $capture[1]; + $op = $capture[2]; + $value = $capture[3]; + if (preg_match('/^([\'\"]{1})(.*)([\'\"]{1})$/i', $value, $capture)) { + if ($capture[1] == $capture[3]) { + $value = $capture[2]; + $value = str_replace('\\n', "\n", $value); + $value = str_replace('\\r', "\r", $value); + $value = str_replace('\\t', "\t", $value); + $value = stripslashes($value); + } + } + if (array_key_exists($field, $row)) { + if (($op == '=' || $op == 'equals' || $op == 'is') && $row[$field] == $value) { + return '1'; + } elseif (($op == '!=' || $op == 'is not') && $row[$field] != $value) { + return '1'; + } elseif (($op == '<' || $op == 'is less than') && $row[$field] < $value) { + return '1'; + } elseif (($op == '>' || $op == 'is greater than') && $row[$field] > $value) { + return '1'; + } elseif (($op == '<=' || $op == 'is less than or equals') && $row[$field] <= $value) { + return '1'; + } elseif (($op == '>=' || $op == 'is greater than or equals') && $row[$field] >= $value) { + return '1'; + } elseif ($op == 'contains' && preg_match('/'.preg_quote($value, '/').'/i', $row[$field])) { + return '1'; + } elseif ($op == 'does not contain' && !preg_match('/'.preg_quote($value, '/').'/i', $row[$field])) { + return '1'; + } else { + return '0'; + } + } + } + return '1'; + } + + /** + * Validates if the row is within the offset or not if sorting is disabled + * @param current_row the current row number being processed + * @return true of false + */ + public function _validate_offset($current_row) + { + if ($this->sort_by === null && $this->offset !== null && $current_row < $this->offset) { + return false; + } + return true; + } + + /** + * Enclose values if needed + * - only used by unparse() + * @param value string to process + * @return Processed value + */ + public function _enclose_value($value = null) + { + if ($value !== null && $value != '') { + $delimiter = preg_quote($this->delimiter, '/'); + $enclosure = preg_quote($this->enclosure, '/'); + if (preg_match('/'.$delimiter.'|'.$enclosure."|\n|\r/i", $value) || ($value{0} == ' ' || substr($value, -1) == ' ')) { + $value = str_replace($this->enclosure, $this->enclosure.$this->enclosure, $value); + $value = $this->enclosure.$value.$this->enclosure; + } + } + return $value; + } + + /** + * Check file data + * @param file local filename + * @return true or false + */ + public function _check_data($file = null) + { + if (empty($this->file_data)) { + if ($file === null) { + $file = $this->file; + } + return $this->load_data($file); + } + return true; + } + + + /** + * Check if passed info might be delimiter + * - only used by find_delimiter() + * @return special string used for delimiter selection, or false + */ + public function _check_count($char, $array, $depth, $preferred) + { + if ($depth == count($array)) { + $first = null; + $equal = null; + $almost = false; + foreach ($array as $key => $value) { + if ($first == null) { + $first = $value; + } elseif ($value == $first && $equal !== false) { + $equal = true; + } elseif ($value == $first+1 && $equal !== false) { + $equal = true; + $almost = true; + } else { + $equal = false; + } + } + if ($equal) { + $match = ($almost) ? 2 : 1 ; + $pref = strpos($preferred, $char); + $pref = ($pref !== false) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999' ; + return $pref.$match.'.'.(99999 - str_pad($first, 5, '0', STR_PAD_LEFT)); + } else { + return false; + } + } + } + + /** + * Read local file + * @param file local filename + * @return Data from file, or false on failure + */ + public function _rfile($file = null) + { + if (is_readable($file)) { + if (!($fh = fopen($file, 'r'))) { + return false; + } + $data = fread($fh, filesize($file)); + fclose($fh); + return $data; + } + return false; + } + + /** + * Write to local file + * @param file local filename + * @param string data to write to file + * @param mode fopen() mode + * @param lock flock() mode + * @return true or false + */ + public function _wfile($file, $string = '', $mode = 'wb', $lock = 2) + { + if ($fp = fopen($file, $mode)) { + flock($fp, $lock); + $re = fwrite($fp, $string); + $re2 = fclose($fp); + if ($re != false && $re2 != false) { + return true; + } + } + return false; + } } - -?> diff --git a/app/Jobs/SendNotificationEmail.php b/app/Jobs/SendNotificationEmail.php index 32eaa6c42d..73c29f66a9 100644 --- a/app/Jobs/SendNotificationEmail.php +++ b/app/Jobs/SendNotificationEmail.php @@ -62,5 +62,4 @@ class SendNotificationEmail extends Job implements ShouldQueue { $userMailer->sendNotification($this->user, $this->invoice, $this->type, $this->payment); } - } diff --git a/app/Jobs/SendPaymentEmail.php b/app/Jobs/SendPaymentEmail.php index c27c0f5f44..300b977f10 100644 --- a/app/Jobs/SendPaymentEmail.php +++ b/app/Jobs/SendPaymentEmail.php @@ -42,6 +42,4 @@ class SendPaymentEmail extends Job implements ShouldQueue { $contactMailer->sendPaymentConfirmation($this->payment); } - - } diff --git a/app/Jobs/SendPushNotification.php b/app/Jobs/SendPushNotification.php index a9774e1f08..5a60b77406 100644 --- a/app/Jobs/SendPushNotification.php +++ b/app/Jobs/SendPushNotification.php @@ -48,5 +48,4 @@ class SendPushNotification extends Job implements ShouldQueue { $pushService->sendNotification($this->invoice, $this->type); } - } diff --git a/app/Libraries/CurlUtils.php b/app/Libraries/CurlUtils.php index 4a11a90939..4904e15aea 100644 --- a/app/Libraries/CurlUtils.php +++ b/app/Libraries/CurlUtils.php @@ -43,7 +43,7 @@ class CurlUtils public static function phantom($method, $url) { - if ( ! $path = env('PHANTOMJS_BIN_PATH')) { + if (! $path = env('PHANTOMJS_BIN_PATH')) { return false; } @@ -62,6 +62,5 @@ class CurlUtils //$response->getStatus(); return false; } - } } diff --git a/app/Libraries/DateUtils.php b/app/Libraries/DateUtils.php index 9d6e639e30..bb8548a3d6 100644 --- a/app/Libraries/DateUtils.php +++ b/app/Libraries/DateUtils.php @@ -4,5 +4,4 @@ use DateTime; class DateUtils { - } diff --git a/app/Libraries/HistoryUtils.php b/app/Libraries/HistoryUtils.php index 5b8643ed65..ea6ad41343 100644 --- a/app/Libraries/HistoryUtils.php +++ b/app/Libraries/HistoryUtils.php @@ -43,25 +43,24 @@ class HistoryUtils ->limit(100) ->get(); - foreach ($activities->reverse() as $activity) - { + foreach ($activities->reverse() as $activity) { if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_CLIENT) { $entity = $activity->client; - } else if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_TASK || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_TASK) { + } elseif ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_TASK || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_TASK) { $entity = $activity->task; - if ( ! $entity) { + if (! $entity) { continue; } $entity->setRelation('client', $activity->client); - } else if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_EXPENSE || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_EXPENSE) { + } elseif ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_EXPENSE || $activity->activity_type_id == ACTIVITY_TYPE_UPDATE_EXPENSE) { $entity = $activity->expense; - if ( ! $entity) { + if (! $entity) { continue; } $entity->setRelation('client', $activity->client); } else { $entity = $activity->invoice; - if ( ! $entity) { + if (! $entity) { continue; } $entity->setRelation('client', $activity->client); @@ -82,7 +81,7 @@ class HistoryUtils ENTITY_EXPENSE ]; - if ( ! in_array($entityType, $trackedTypes)) { + if (! in_array($entityType, $trackedTypes)) { return; } @@ -151,16 +150,14 @@ class HistoryUtils $history = Session::get(RECENTLY_VIEWED, []); $history = isset($history[$accountId]) ? $history[$accountId] : []; - foreach ($history as $item) - { + foreach ($history as $item) { if ($item->entityType == ENTITY_CLIENT && isset($clientMap[$item->client_id])) { continue; } $clientMap[$item->client_id] = true; - if ($lastClientId === false || $item->client_id != $lastClientId) - { + if ($lastClientId === false || $item->client_id != $lastClientId) { $icon = ''; if ($item->client_id) { $link = url('/clients/' . $item->client_id); diff --git a/app/Libraries/OFX.php b/app/Libraries/OFX.php index 83edb3085d..4552ceee31 100644 --- a/app/Libraries/OFX.php +++ b/app/Libraries/OFX.php @@ -64,8 +64,8 @@ class Finance class Bank { public $logins; // array of class User - public $finance; // the Finance object that hold this Bank object - public $fid; + public $finance; // the Finance object that hold this Bank object + public $fid; public $org; public $url; public function __construct($finance, $fid, $url, $org) @@ -92,41 +92,41 @@ class Login public function setup() { $ofxRequest = - "OFXHEADER:100\n". - "DATA:OFXSGML\n". - "VERSION:102\n". - "SECURITY:NONE\n". - "ENCODING:USASCII\n". - "CHARSET:1252\n". - "COMPRESSION:NONE\n". - "OLDFILEUID:NONE\n". - "NEWFILEUID:NONE\n". - "\n". - "\n". - "\n". - "\n". - "20110412162900.000[-7:MST]\n". - ''.$this->id."\n". - ''.$this->pass."\n". - "N\n". - "ENG\n". - "\n". - ''.$this->bank->org."\n". - ''.$this->bank->fid."\n". - "\n". - "QWIN\n". - "2500\n". - "\n". - "\n". - "\n". - "\n". - ''.md5(time().$this->bank->url.$this->id)."\n". - "\n". - "19900101\n". - "\n". - " \n". - "\n". - "\n"; + "OFXHEADER:100\n". + "DATA:OFXSGML\n". + "VERSION:102\n". + "SECURITY:NONE\n". + "ENCODING:USASCII\n". + "CHARSET:1252\n". + "COMPRESSION:NONE\n". + "OLDFILEUID:NONE\n". + "NEWFILEUID:NONE\n". + "\n". + "\n". + "\n". + "\n". + "20110412162900.000[-7:MST]\n". + ''.$this->id."\n". + ''.$this->pass."\n". + "N\n". + "ENG\n". + "\n". + ''.$this->bank->org."\n". + ''.$this->bank->fid."\n". + "\n". + "QWIN\n". + "2500\n". + "\n". + "\n". + "\n". + "\n". + ''.md5(time().$this->bank->url.$this->id)."\n". + "\n". + "19900101\n". + "\n". + " \n". + "\n". + "\n"; $o = new OFX($this->bank, $ofxRequest); $o->go(); $x = $o->xml(); @@ -160,68 +160,68 @@ class Account public function setup($includeTransactions = true) { $ofxRequest = - "OFXHEADER:100\n". - "DATA:OFXSGML\n". - "VERSION:102\n". - "SECURITY:NONE\n". - "ENCODING:USASCII\n". - "CHARSET:1252\n". - "COMPRESSION:NONE\n". - "OLDFILEUID:NONE\n". - "NEWFILEUID:NONE\n". - "\n". - "\n". - "\n". - "\n". - "20110412162900.000[-7:MST]\n". - ''.$this->login->id."\n". - ''.$this->login->pass."\n". - "ENG\n". - "\n". - ''.$this->login->bank->org."\n". - ''.$this->login->bank->fid."\n". - "\n". - "QWIN\n". - "2500\n". - "\n". - "\n"; + "OFXHEADER:100\n". + "DATA:OFXSGML\n". + "VERSION:102\n". + "SECURITY:NONE\n". + "ENCODING:USASCII\n". + "CHARSET:1252\n". + "COMPRESSION:NONE\n". + "OLDFILEUID:NONE\n". + "NEWFILEUID:NONE\n". + "\n". + "\n". + "\n". + "\n". + "20110412162900.000[-7:MST]\n". + ''.$this->login->id."\n". + ''.$this->login->pass."\n". + "ENG\n". + "\n". + ''.$this->login->bank->org."\n". + ''.$this->login->bank->fid."\n". + "\n". + "QWIN\n". + "2500\n". + "\n". + "\n"; if ($this->type == 'BANK') { $ofxRequest .= - " \n". - " \n". - ' '.md5(time().$this->login->bank->url.$this->id)."\n". - " \n". - " \n". - ' '.$this->bankId."\n". - ' '.$this->id."\n". - ' '.$this->subType."\n". - " \n". - " \n". - " 20110301\n". - ' '.($includeTransactions ? 'Y' : 'N')."\n". - " \n". - " \n". - " \n". - " \n"; + " \n". + " \n". + ' '.md5(time().$this->login->bank->url.$this->id)."\n". + " \n". + " \n". + ' '.$this->bankId."\n". + ' '.$this->id."\n". + ' '.$this->subType."\n". + " \n". + " \n". + " 20110301\n". + ' '.($includeTransactions ? 'Y' : 'N')."\n". + " \n". + " \n". + " \n". + " \n"; } elseif ($this->type == 'CC') { $ofxRequest .= - " \n". - " \n". - ' '.md5(time().$this->login->bank->url.$this->id)."\n". - " \n". - " \n". - ' '.$this->id."\n". - " \n". - " \n". - " 20110320\n". - ' '.($includeTransactions ? 'Y' : 'N')."\n". - " \n". - " \n". - " \n". - " \n"; + " \n". + " \n". + ' '.md5(time().$this->login->bank->url.$this->id)."\n". + " \n". + " \n". + ' '.$this->id."\n". + " \n". + " \n". + " 20110320\n". + ' '.($includeTransactions ? 'Y' : 'N')."\n". + " \n". + " \n". + " \n". + " \n"; } $ofxRequest .= - ''; + ''; $o = new OFX($this->login->bank, $ofxRequest); $o->go(); $this->response = $o->response; diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 12028c660e..a98f0c5eaf 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -384,15 +384,16 @@ class Utils return intval($value); } - public static function getFromCache($id, $type) { + public static function getFromCache($id, $type) + { $cache = Cache::get($type); - if ( ! $cache) { + if (! $cache) { static::logError("Cache for {$type} is not set"); return null; } - $data = $cache->filter(function($item) use ($id) { + $data = $cache->filter(function ($item) use ($id) { return $item->id == $id; }); @@ -457,7 +458,7 @@ class Utils public static function pluralizeEntityType($type) { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { if ($module = \Module::find($type)) { return $module->get('plural', $type); } @@ -587,10 +588,11 @@ class Utils $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $dateTime = DateTime::createFromFormat($format, $date); - if(!$dateTime) + if (!$dateTime) { return $date; - else + } else { return $formatResult ? $dateTime->format('Y-m-d') : $dateTime; + } } public static function fromSqlDate($date, $formatResult = true) @@ -602,10 +604,11 @@ class Utils $format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT); $dateTime = DateTime::createFromFormat('Y-m-d', $date); - if(!$dateTime) + if (!$dateTime) { return $date; - else + } else { return $formatResult ? $dateTime->format($format) : $dateTime; + } } public static function fromSqlDateTime($date, $formatResult = true) @@ -659,7 +662,7 @@ class Utils if (count($matches) == 0) { continue; } - usort($matches, function($a, $b) { + usort($matches, function ($a, $b) { return strlen($b) - strlen($a); }); foreach ($matches as $match) { @@ -758,11 +761,13 @@ class Utils public static function getVendorDisplayName($model) { - if(is_null($model)) + if (is_null($model)) { return ''; + } - if($model->vendor_name) + if ($model->vendor_name) { return $model->vendor_name; + } return 'No vendor name'; } @@ -1089,7 +1094,7 @@ class Utils public static function getTranslatedWeekdayNames() { return collect(static::$weekdayNames)->transform(function ($day) { - return trans('texts.'.strtolower($day)); + return trans('texts.'.strtolower($day)); }); } diff --git a/app/Libraries/entity.php b/app/Libraries/entity.php index 57e447e2e2..c8802aa800 100644 --- a/app/Libraries/entity.php +++ b/app/Libraries/entity.php @@ -1,8 +1,7 @@ - - # This code is licensed under the MIT license - # + # + # A PHP auto-linking library + # + # https://github.com/iamcal/lib_autolink + # + # By Cal Henderson + # This code is licensed under the MIT license + # + + #################################################################### - #################################################################### + # + # These are global options. You can set them before calling the autolinking + # functions to change the output. + # + + $GLOBALS['autolink_options'] = [ + + # Should http:// be visibly stripped from the front + # of URLs? + 'strip_protocols' => false, + + ]; + + #################################################################### + + function autolink($text, $limit=30, $tagfill='', $auto_title = true) + { + $text = autolink_do($text, '![a-z][a-z-]+://!i', $limit, $tagfill, $auto_title); + $text = autolink_do($text, '!(mailto|skype):!i', $limit, $tagfill, $auto_title); + $text = autolink_do($text, '!www\\.!i', $limit, $tagfill, $auto_title, 'http://'); + return $text; + } + + #################################################################### + + function autolink_do($text, $sub, $limit, $tagfill, $auto_title, $force_prefix=null) + { + $text_l = StrToLower($text); + $cursor = 0; + $loop = 1; + $buffer = ''; + + while (($cursor < strlen($text)) && $loop) { + $ok = 1; + $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor); + + if (!$matched) { + $loop = 0; + $ok = 0; + } else { + $pos = $m[0][1]; + $sub_len = strlen($m[0][0]); + + $pre_hit = substr($text, $cursor, $pos-$cursor); + $hit = substr($text, $pos, $sub_len); + $pre = substr($text, 0, $pos); + $post = substr($text, $pos + $sub_len); + + $fail_text = $pre_hit.$hit; + $fail_len = strlen($fail_text); + + # + # substring found - first check to see if we're inside a link tag already... + # + + $bits = preg_split('!!i', $pre); + $last_bit = array_pop($bits); + if (preg_match("!\n"; + + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } + + # + # looks like a nice spot to autolink from - check the pre + # to see if there was whitespace before this match + # + + if ($ok) { + if ($pre) { + if (!preg_match('![\s\(\[\{>]$!s', $pre)) { + + #echo "fail 2 at $cursor ($pre)
\n"; + + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } + } + + # + # we want to autolink here - find the extent of the url + # + + if ($ok) { + if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)) { + $url = $hit.$matches[1]; + + $cursor += strlen($url) + strlen($pre_hit); + $buffer .= $pre_hit; - # - # These are global options. You can set them before calling the autolinking - # functions to change the output. - # + $url = html_entity_decode($url); - $GLOBALS['autolink_options'] = [ - # Should http:// be visibly stripped from the front - # of URLs? - 'strip_protocols' => false, + # + # remove trailing punctuation from url + # - ]; + while (preg_match('|[.,!;:?]$|', $url)) { + $url = substr($url, 0, strlen($url)-1); + $cursor--; + } + foreach (['()', '[]', '{}'] as $pair) { + $o = substr($pair, 0, 1); + $c = substr($pair, 1, 1); + if (preg_match("!^(\\$c|^)[^\\$o]+\\$c$!", $url)) { + $url = substr($url, 0, strlen($url)-1); + $cursor--; + } + } + + + # + # nice-i-fy url here + # - #################################################################### + $link_url = $url; + $display_url = $url; - function autolink($text, $limit=30, $tagfill='', $auto_title = true){ + if ($force_prefix) { + $link_url = $force_prefix.$link_url; + } - $text = autolink_do($text, '![a-z][a-z-]+://!i', $limit, $tagfill, $auto_title); - $text = autolink_do($text, '!(mailto|skype):!i', $limit, $tagfill, $auto_title); - $text = autolink_do($text, '!www\\.!i', $limit, $tagfill, $auto_title, 'http://'); - return $text; - } + if ($GLOBALS['autolink_options']['strip_protocols']) { + if (preg_match('!^(http|https)://!i', $display_url, $m)) { + $display_url = substr($display_url, strlen($m[1])+3); + } + } - #################################################################### + $display_url = autolink_label($display_url, $limit); - function autolink_do($text, $sub, $limit, $tagfill, $auto_title, $force_prefix=null){ - $text_l = StrToLower($text); - $cursor = 0; - $loop = 1; - $buffer = ''; + # + # add the url + # + + $currentTagfill = $tagfill; + if ($display_url != $link_url && !preg_match('@title=@msi', $currentTagfill) && $auto_title) { + $display_quoted = preg_quote($display_url, '!'); - while (($cursor < strlen($text)) && $loop){ + if (!preg_match("!^(http|https)://{$display_quoted}$!i", $link_url)) { + $currentTagfill .= ' title="'.$link_url.'"'; + } + } - $ok = 1; - $matched = preg_match($sub, $text_l, $m, PREG_OFFSET_CAPTURE, $cursor); + $link_url_enc = HtmlSpecialChars($link_url); + $display_url_enc = HtmlSpecialChars($display_url); - if (!$matched){ + $buffer .= "{$display_url_enc}"; + } else { + #echo "fail 3 at $cursor
\n"; - $loop = 0; - $ok = 0; + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } + } - }else{ + # + # add everything from the cursor to the end onto the buffer. + # - $pos = $m[0][1]; - $sub_len = strlen($m[0][0]); + $buffer .= substr($text, $cursor); - $pre_hit = substr($text, $cursor, $pos-$cursor); - $hit = substr($text, $pos, $sub_len); - $pre = substr($text, 0, $pos); - $post = substr($text, $pos + $sub_len); + return $buffer; + } - $fail_text = $pre_hit.$hit; - $fail_len = strlen($fail_text); + #################################################################### - # - # substring found - first check to see if we're inside a link tag already... - # + function autolink_label($text, $limit) + { + if (!$limit) { + return $text; + } - $bits = preg_split('!!i', $pre); - $last_bit = array_pop($bits); - if (preg_match("! $limit) { + return substr($text, 0, $limit-3).'...'; + } - #echo "fail 1 at $cursor
\n"; + return $text; + } - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } + #################################################################### - # - # looks like a nice spot to autolink from - check the pre - # to see if there was whitespace before this match - # + function autolink_email($text, $tagfill='') + { + $atom = '[^()<>@,;:\\\\".\\[\\]\\x00-\\x20\\x7f]+'; # from RFC822 - if ($ok){ + #die($atom); - if ($pre){ - if (!preg_match('![\s\(\[\{>]$!s', $pre)){ + $text_l = StrToLower($text); + $cursor = 0; + $loop = 1; + $buffer = ''; - #echo "fail 2 at $cursor ($pre)
\n"; + while (($cursor < strlen($text)) && $loop) { - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } - } + # + # find an '@' symbol + # - # - # we want to autolink here - find the extent of the url - # + $ok = 1; + $pos = strpos($text_l, '@', $cursor); - if ($ok){ - if (preg_match('/^([a-z0-9\-\.\/\-_%~!?=,:;&+*#@\(\)\$]+)/i', $post, $matches)){ + if ($pos === false) { + $loop = 0; + $ok = 0; + } else { + $pre = substr($text, $cursor, $pos-$cursor); + $hit = substr($text, $pos, 1); + $post = substr($text, $pos + 1); - $url = $hit.$matches[1]; + $fail_text = $pre.$hit; + $fail_len = strlen($fail_text); - $cursor += strlen($url) + strlen($pre_hit); - $buffer .= $pre_hit; + #die("$pre::$hit::$post::$fail_text"); - $url = html_entity_decode($url); + # + # substring found - first check to see if we're inside a link tag already... + # + $bits = preg_split('!!i', $pre); + $last_bit = array_pop($bits); + if (preg_match("!\n"; - while (preg_match('|[.,!;:?]$|', $url)){ - $url = substr($url, 0, strlen($url)-1); - $cursor--; - } - foreach (['()', '[]', '{}'] as $pair){ - $o = substr($pair, 0, 1); - $c = substr($pair, 1, 1); - if (preg_match("!^(\\$c|^)[^\\$o]+\\$c$!", $url)){ - $url = substr($url, 0, strlen($url)-1); - $cursor--; - } - } + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } + # + # check backwards + # - # - # nice-i-fy url here - # + if ($ok) { + if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)) { - $link_url = $url; - $display_url = $url; + # move matched part of address into $hit - if ($force_prefix) $link_url = $force_prefix.$link_url; + $len = strlen($matches[1]); + $plen = strlen($pre); - if ($GLOBALS['autolink_options']['strip_protocols']){ - if (preg_match('!^(http|https)://!i', $display_url, $m)){ + $hit = substr($pre, $plen-$len).$hit; + $pre = substr($pre, 0, $plen-$len); + } else { - $display_url = substr($display_url, strlen($m[1])+3); - } - } + #echo "fail 2 at $cursor ($pre)
\n"; - $display_url = autolink_label($display_url, $limit); + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } + # + # check forwards + # - # - # add the url - # - - $currentTagfill = $tagfill; - if ($display_url != $link_url && !preg_match('@title=@msi',$currentTagfill) && $auto_title) { + if ($ok) { + if (preg_match("!^($atom(\.$atom)*)!", $post, $matches)) { - $display_quoted = preg_quote($display_url, '!'); + # move matched part of address into $hit - if (!preg_match("!^(http|https)://{$display_quoted}$!i", $link_url)){ + $len = strlen($matches[1]); - $currentTagfill .= ' title="'.$link_url.'"'; - } - } + $hit .= substr($post, 0, $len); + $post = substr($post, $len); + } else { + #echo "fail 3 at $cursor ($post)
\n"; - $link_url_enc = HtmlSpecialChars($link_url); - $display_url_enc = HtmlSpecialChars($display_url); + $ok = 0; + $cursor += $fail_len; + $buffer .= $fail_text; + } + } - $buffer .= "{$display_url_enc}"; - - }else{ - #echo "fail 3 at $cursor
\n"; + # + # commit + # - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } + if ($ok) { + $cursor += strlen($pre) + strlen($hit); + $buffer .= $pre; + $buffer .= "$hit"; + } + } - } + # + # add everything from the cursor to the end onto the buffer. + # - # - # add everything from the cursor to the end onto the buffer. - # + $buffer .= substr($text, $cursor); - $buffer .= substr($text, $cursor); + return $buffer; + } - return $buffer; - } - - #################################################################### - - function autolink_label($text, $limit){ - - if (!$limit){ return $text; } - - if (strlen($text) > $limit){ - return substr($text, 0, $limit-3).'...'; - } - - return $text; - } - - #################################################################### - - function autolink_email($text, $tagfill=''){ - - $atom = '[^()<>@,;:\\\\".\\[\\]\\x00-\\x20\\x7f]+'; # from RFC822 - - #die($atom); - - $text_l = StrToLower($text); - $cursor = 0; - $loop = 1; - $buffer = ''; - - while(($cursor < strlen($text)) && $loop){ - - # - # find an '@' symbol - # - - $ok = 1; - $pos = strpos($text_l, '@', $cursor); - - if ($pos === false){ - - $loop = 0; - $ok = 0; - - }else{ - - $pre = substr($text, $cursor, $pos-$cursor); - $hit = substr($text, $pos, 1); - $post = substr($text, $pos + 1); - - $fail_text = $pre.$hit; - $fail_len = strlen($fail_text); - - #die("$pre::$hit::$post::$fail_text"); - - # - # substring found - first check to see if we're inside a link tag already... - # - - $bits = preg_split('!!i', $pre); - $last_bit = array_pop($bits); - if (preg_match("!\n"; - - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } - - # - # check backwards - # - - if ($ok){ - if (preg_match("!($atom(\.$atom)*)\$!", $pre, $matches)){ - - # move matched part of address into $hit - - $len = strlen($matches[1]); - $plen = strlen($pre); - - $hit = substr($pre, $plen-$len).$hit; - $pre = substr($pre, 0, $plen-$len); - - }else{ - - #echo "fail 2 at $cursor ($pre)
\n"; - - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } - - # - # check forwards - # - - if ($ok){ - if (preg_match("!^($atom(\.$atom)*)!", $post, $matches)){ - - # move matched part of address into $hit - - $len = strlen($matches[1]); - - $hit .= substr($post, 0, $len); - $post = substr($post, $len); - - }else{ - #echo "fail 3 at $cursor ($post)
\n"; - - $ok = 0; - $cursor += $fail_len; - $buffer .= $fail_text; - } - } - - # - # commit - # - - if ($ok) { - - $cursor += strlen($pre) + strlen($hit); - $buffer .= $pre; - $buffer .= "$hit"; - - } - - } - - # - # add everything from the cursor to the end onto the buffer. - # - - $buffer .= substr($text, $cursor); - - return $buffer; - } - - #################################################################### - -?> + ####################################################################; diff --git a/app/Listeners/ActivityListener.php b/app/Listeners/ActivityListener.php index 2a3985f54f..25435a3a84 100644 --- a/app/Listeners/ActivityListener.php +++ b/app/Listeners/ActivityListener.php @@ -503,7 +503,7 @@ class ActivityListener */ public function updatedTask(TaskWasUpdated $event) { - if ( ! $event->task->isChanged()) { + if (! $event->task->isChanged()) { return; } @@ -552,7 +552,7 @@ class ActivityListener public function updatedExpense(ExpenseWasUpdated $event) { - if ( ! $event->expense->isChanged()) { + if (! $event->expense->isChanged()) { return; } @@ -589,6 +589,4 @@ class ActivityListener ACTIVITY_TYPE_RESTORE_EXPENSE ); } - - } diff --git a/app/Listeners/AnalyticsListener.php b/app/Listeners/AnalyticsListener.php index ca36fd7912..c100a0feec 100644 --- a/app/Listeners/AnalyticsListener.php +++ b/app/Listeners/AnalyticsListener.php @@ -13,7 +13,7 @@ class AnalyticsListener */ public function trackRevenue(PaymentWasCreated $event) { - if ( ! Utils::isNinja() || ! env('ANALYTICS_KEY')) { + if (! Utils::isNinja() || ! env('ANALYTICS_KEY')) { return; } diff --git a/app/Listeners/HandleUserLoggedIn.php b/app/Listeners/HandleUserLoggedIn.php index f8b3bb8cfb..49906b30a6 100644 --- a/app/Listeners/HandleUserLoggedIn.php +++ b/app/Listeners/HandleUserLoggedIn.php @@ -11,7 +11,8 @@ use App\Libraries\HistoryUtils; /** * Class HandleUserLoggedIn */ -class HandleUserLoggedIn { +class HandleUserLoggedIn +{ /** * @var AccountRepository @@ -23,20 +24,20 @@ class HandleUserLoggedIn { * * @param AccountRepository $accountRepo */ - public function __construct(AccountRepository $accountRepo) - { + public function __construct(AccountRepository $accountRepo) + { $this->accountRepo = $accountRepo; - } + } - /** - * Handle the event. - * - * @param UserLoggedIn $event + /** + * Handle the event. * - * @return void - */ - public function handle(UserLoggedIn $event) - { + * @param UserLoggedIn $event + * + * @return void + */ + public function handle(UserLoggedIn $event) + { $account = Auth::user()->account; if (empty($account->last_login)) { @@ -63,5 +64,5 @@ class HandleUserLoggedIn { } elseif ($account->isLogoTooLarge()) { Session::flash('warning', trans('texts.logo_too_large', ['size' => $account->getLogoSize() . 'KB'])); } - } + } } diff --git a/app/Listeners/HandleUserSettingsChanged.php b/app/Listeners/HandleUserSettingsChanged.php index 8afd72f9a3..b45f88fc36 100644 --- a/app/Listeners/HandleUserSettingsChanged.php +++ b/app/Listeners/HandleUserSettingsChanged.php @@ -9,29 +9,30 @@ use App\Ninja\Mailers\UserMailer; /** * Class HandleUserSettingsChanged */ -class HandleUserSettingsChanged { +class HandleUserSettingsChanged +{ - /** - * Create the event handler. - * - * @param AccountRepository $accountRepo - * @param UserMailer $userMailer - */ - public function __construct(AccountRepository $accountRepo, UserMailer $userMailer) - { + /** + * Create the event handler. + * + * @param AccountRepository $accountRepo + * @param UserMailer $userMailer + */ + public function __construct(AccountRepository $accountRepo, UserMailer $userMailer) + { $this->accountRepo = $accountRepo; $this->userMailer = $userMailer; - } + } - /** - * Handle the event. - * - * @param UserSettingsChanged $event - * - * @return void - */ - public function handle(UserSettingsChanged $event) - { + /** + * Handle the event. + * + * @param UserSettingsChanged $event + * + * @return void + */ + public function handle(UserSettingsChanged $event) + { if (!Auth::check()) { return; } @@ -46,5 +47,5 @@ class HandleUserSettingsChanged { $this->userMailer->sendConfirmation($event->user); Session::flash('warning', trans('texts.verify_email')); } - } + } } diff --git a/app/Listeners/HandleUserSignedUp.php b/app/Listeners/HandleUserSignedUp.php index 11fd3b90fb..ebc8ce23fd 100644 --- a/app/Listeners/HandleUserSignedUp.php +++ b/app/Listeners/HandleUserSignedUp.php @@ -23,7 +23,7 @@ class HandleUserSignedUp /** * Create the event handler. - * + * * @param AccountRepository $accountRepo * @param UserMailer $userMailer */ diff --git a/app/Listeners/InvoiceListener.php b/app/Listeners/InvoiceListener.php index c7353c768a..f259526277 100644 --- a/app/Listeners/InvoiceListener.php +++ b/app/Listeners/InvoiceListener.php @@ -136,7 +136,7 @@ class InvoiceListener */ public function restoredPayment(PaymentWasRestored $event) { - if ( ! $event->fromDeleted) { + if (! $event->fromDeleted) { return; } diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index ad94e5767a..4a36eb148f 100644 --- a/app/Listeners/NotificationListener.php +++ b/app/Listeners/NotificationListener.php @@ -48,10 +48,8 @@ class NotificationListener */ private function sendEmails($invoice, $type, $payment = null) { - foreach ($invoice->account->users as $user) - { - if ($user->{"notify_{$type}"}) - { + foreach ($invoice->account->users as $user) { + if ($user->{"notify_{$type}"}) { $this->userMailer->sendNotification($user, $invoice, $type, $payment); } } @@ -80,7 +78,7 @@ class NotificationListener */ public function viewedInvoice(InvoiceInvitationWasViewed $event) { - if ( ! floatval($event->invoice->balance)) { + if (! floatval($event->invoice->balance)) { return; } @@ -116,7 +114,7 @@ class NotificationListener public function createdPayment(PaymentWasCreated $event) { // only send emails for online payments - if ( ! $event->payment->account_gateway_id) { + if (! $event->payment->account_gateway_id) { return; } @@ -125,5 +123,4 @@ class NotificationListener $this->pushService->sendNotification($event->payment->invoice, 'paid'); } - } diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 595bc868bb..afb097b6b3 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -66,7 +66,6 @@ class SubscriptionListener */ public function createdCredit(CreditWasCreated $event) { - } /** @@ -74,7 +73,6 @@ class SubscriptionListener */ public function createdVendor(VendorWasCreated $event) { - } /** @@ -82,43 +80,42 @@ class SubscriptionListener */ public function createdExpense(ExpenseWasCreated $event) { - } - /** - * @param InvoiceWasUpdated $event - */ + /** + * @param InvoiceWasUpdated $event + */ public function updatedInvoice(InvoiceWasUpdated $event) { - $transformer = new InvoiceTransformer($event->invoice->account); - $this->checkSubscriptions(EVENT_UPDATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); + $transformer = new InvoiceTransformer($event->invoice->account); + $this->checkSubscriptions(EVENT_UPDATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } /** - * @param InvoiceWasDeleted $event - */ + * @param InvoiceWasDeleted $event + */ public function deletedInvoice(InvoiceWasDeleted $event) { - $transformer = new InvoiceTransformer($event->invoice->account); - $this->checkSubscriptions(EVENT_DELETE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); + $transformer = new InvoiceTransformer($event->invoice->account); + $this->checkSubscriptions(EVENT_DELETE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } /** - * @param QuoteWasUpdated $event - */ + * @param QuoteWasUpdated $event + */ public function updatedQuote(QuoteWasUpdated $event) { - $transformer = new InvoiceTransformer($event->quote->account); - $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + $transformer = new InvoiceTransformer($event->quote->account); + $this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } /** - * @param InvoiceWasDeleted $event - */ + * @param InvoiceWasDeleted $event + */ public function deletedQuote(QuoteWasDeleted $event) { - $transformer = new InvoiceTransformer($event->quote->account); - $this->checkSubscriptions(EVENT_DELETE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); + $transformer = new InvoiceTransformer($event->quote->account); + $this->checkSubscriptions(EVENT_DELETE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } /** @@ -129,7 +126,7 @@ class SubscriptionListener */ private function checkSubscriptions($eventId, $entity, $transformer, $include = '') { - if ( ! EntityModel::$notifySubscriptions) { + if (! EntityModel::$notifySubscriptions) { return; } diff --git a/app/Models/Account.php b/app/Models/Account.php index cbfbe647b6..78c0ac68b5 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -287,7 +287,7 @@ class Account extends Eloquent */ public function expenses() { - return $this->hasMany('App\Models\Expense','account_id','id')->withTrashed(); + return $this->hasMany('App\Models\Expense', 'account_id', 'id')->withTrashed(); } /** @@ -295,7 +295,7 @@ class Account extends Eloquent */ public function payments() { - return $this->hasMany('App\Models\Payment','account_id','id')->withTrashed(); + return $this->hasMany('App\Models\Payment', 'account_id', 'id')->withTrashed(); } /** @@ -311,7 +311,7 @@ class Account extends Eloquent */ public function expense_categories() { - return $this->hasMany('App\Models\ExpenseCategory','account_id','id')->withTrashed(); + return $this->hasMany('App\Models\ExpenseCategory', 'account_id', 'id')->withTrashed(); } /** @@ -319,7 +319,7 @@ class Account extends Eloquent */ public function projects() { - return $this->hasMany('App\Models\Project','account_id','id')->withTrashed(); + return $this->hasMany('App\Models\Project', 'account_id', 'id')->withTrashed(); } /** @@ -352,7 +352,7 @@ class Account extends Eloquent */ public function isGatewayConfigured($gatewayId = 0) { - if ( ! $this->relationLoaded('account_gateways')) { + if (! $this->relationLoaded('account_gateways')) { $this->load('account_gateways'); } @@ -376,7 +376,7 @@ class Account extends Eloquent */ public function hasInvoicePrefix() { - if ( ! $this->invoice_number_prefix && ! $this->quote_number_prefix) { + if (! $this->invoice_number_prefix && ! $this->quote_number_prefix) { return false; } @@ -447,9 +447,9 @@ class Account extends Eloquent public function getDate($date = 'now') { - if ( ! $date) { + if (! $date) { return null; - } elseif ( ! $date instanceof \DateTime) { + } elseif (! $date instanceof \DateTime) { $date = new \DateTime($date); } @@ -511,7 +511,7 @@ class Account extends Eloquent $countryId = false; } - if ( ! $decorator) { + if (! $decorator) { $decorator = $this->show_currency_code ? CURRENCY_DECORATOR_CODE : CURRENCY_DECORATOR_SYMBOL; } @@ -534,7 +534,7 @@ class Account extends Eloquent { $date = $this->getDate($date); - if ( ! $date) { + if (! $date) { return null; } @@ -549,7 +549,7 @@ class Account extends Eloquent { $date = $this->getDateTime($date); - if ( ! $date) { + if (! $date) { return null; } @@ -564,7 +564,7 @@ class Account extends Eloquent { $date = $this->getDateTime($date); - if ( ! $date) { + if (! $date) { return null; } @@ -609,13 +609,13 @@ class Account extends Eloquent */ public function getGatewayByType($type = false) { - if ( ! $this->relationLoaded('account_gateways')) { + if (! $this->relationLoaded('account_gateways')) { $this->load('account_gateways'); } /** @var AccountGateway $accountGateway */ foreach ($this->account_gateways as $accountGateway) { - if ( ! $type) { + if (! $type) { return $accountGateway; } @@ -634,7 +634,7 @@ class Account extends Eloquent */ public function availableGatewaysIds() { - if ( ! $this->relationLoaded('account_gateways')) { + if (! $this->relationLoaded('account_gateways')) { $this->load('account_gateways'); } @@ -717,7 +717,7 @@ class Account extends Eloquent */ public function hasLogo() { - if($this->logo == ''){ + if ($this->logo == '') { $this->calculateLogoDetails(); } @@ -727,20 +727,22 @@ class Account extends Eloquent /** * @return mixed */ - public function getLogoDisk(){ + public function getLogoDisk() + { return Storage::disk(env('LOGO_FILESYSTEM', 'logos')); } - protected function calculateLogoDetails(){ + protected function calculateLogoDetails() + { $disk = $this->getLogoDisk(); - if($disk->exists($this->account_key.'.png')){ + if ($disk->exists($this->account_key.'.png')) { $this->logo = $this->account_key.'.png'; - } else if($disk->exists($this->account_key.'.jpg')) { + } elseif ($disk->exists($this->account_key.'.jpg')) { $this->logo = $this->account_key.'.jpg'; } - if(!empty($this->logo)){ + if (!empty($this->logo)) { $image = imagecreatefromstring($disk->get($this->logo)); $this->logo_width = imagesx($image); $this->logo_height = imagesy($image); @@ -754,8 +756,9 @@ class Account extends Eloquent /** * @return null */ - public function getLogoRaw(){ - if(!$this->hasLogo()){ + public function getLogoRaw() + { + if (!$this->hasLogo()) { return null; } @@ -769,14 +772,14 @@ class Account extends Eloquent */ public function getLogoURL($cachebuster = false) { - if(!$this->hasLogo()){ + if (!$this->hasLogo()) { return null; } $disk = $this->getLogoDisk(); $adapter = $disk->getAdapter(); - if($adapter instanceof \League\Flysystem\Adapter\Local) { + if ($adapter instanceof \League\Flysystem\Adapter\Local) { // Stored locally $logoUrl = url('/logo/' . $this->logo); @@ -792,7 +795,7 @@ class Account extends Eloquent public function getLogoPath() { - if ( ! $this->hasLogo()){ + if (! $this->hasLogo()) { return null; } @@ -837,7 +840,7 @@ class Account extends Eloquent */ public function getLogoWidth() { - if(!$this->hasLogo()){ + if (!$this->hasLogo()) { return null; } @@ -849,7 +852,7 @@ class Account extends Eloquent */ public function getLogoHeight() { - if(!$this->hasLogo()){ + if (!$this->hasLogo()) { return null; } @@ -882,7 +885,7 @@ class Account extends Eloquent if ($this->hasClientNumberPattern($invoice) && !$clientId) { // do nothing, we don't yet know the value - } elseif ( ! $invoice->invoice_number) { + } elseif (! $invoice->invoice_number) { $invoice->invoice_number = $this->getNextNumber($invoice); } } @@ -939,7 +942,7 @@ class Account extends Eloquent */ public function startTrial($plan) { - if ( ! Utils::isNinja()) { + if (! Utils::isNinja()) { return; } @@ -1011,7 +1014,7 @@ class Account extends Eloquent // Enterprise; No Trial allowed; grandfathered for old pro users case FEATURE_USERS:// Grandfathered for old Pro users - if($planDetails && $planDetails['trial']) { + if ($planDetails && $planDetails['trial']) { // Do they have a non-trial plan? $planDetails = $this->getPlanDetails(false, false); } @@ -1081,7 +1084,7 @@ class Account extends Eloquent $price = $this->company->plan_price; $trial_plan = $this->company->trial_plan; - if((!$plan || $plan == PLAN_FREE) && (!$trial_plan || !$include_trial)) { + if ((!$plan || $plan == PLAN_FREE) && (!$trial_plan || !$include_trial)) { return null; } @@ -1092,7 +1095,7 @@ class Account extends Eloquent $trial_expires->modify('+2 weeks'); if ($trial_expires >= date_create()) { - $trial_active = true; + $trial_active = true; } } @@ -1188,7 +1191,7 @@ class Account extends Eloquent { $planDetails = $this->getPlanDetails(true); - if(!$planDetails || !$planDetails['trial']) { + if (!$planDetails || !$planDetails['trial']) { return 0; } @@ -1220,7 +1223,7 @@ class Account extends Eloquent */ public function getLogoSize() { - if(!$this->hasLogo()){ + if (!$this->hasLogo()) { return null; } @@ -1402,7 +1405,7 @@ class Account extends Eloquent */ public function getReminderDate($reminder) { - if ( ! $this->{"enable_reminder{$reminder}"}) { + if (! $this->{"enable_reminder{$reminder}"}) { return false; } @@ -1447,7 +1450,8 @@ class Account extends Eloquent /** * @return bool */ - public function getTokenGatewayId() { + public function getTokenGatewayId() + { if ($this->isGatewayConfigured(GATEWAY_STRIPE)) { return GATEWAY_STRIPE; } elseif ($this->isGatewayConfigured(GATEWAY_BRAINTREE)) { @@ -1462,7 +1466,8 @@ class Account extends Eloquent /** * @return bool|void */ - public function getTokenGateway() { + public function getTokenGateway() + { $gatewayId = $this->getTokenGatewayId(); if (!$gatewayId) { return; @@ -1489,7 +1494,7 @@ class Account extends Eloquent if ($iframe_url) { return "{$iframe_url}/?"; - } else if ($this->subdomain) { + } elseif ($this->subdomain) { $url = Utils::replaceSubdomain($url, $this->subdomain); } @@ -1556,7 +1561,8 @@ class Account extends Eloquent /** * @return string */ - public function clientViewCSS(){ + public function clientViewCSS() + { $css = ''; if ($this->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) { @@ -1578,46 +1584,51 @@ class Account extends Eloquent * @param string $protocol * @return string */ - public function getFontsUrl($protocol = ''){ + public function getFontsUrl($protocol = '') + { $bodyFont = $this->getHeaderFontId(); $headerFont = $this->getBodyFontId(); $bodyFontSettings = Utils::getFromCache($bodyFont, 'fonts'); $google_fonts = [$bodyFontSettings['google_font']]; - if($headerFont != $bodyFont){ + if ($headerFont != $bodyFont) { $headerFontSettings = Utils::getFromCache($headerFont, 'fonts'); $google_fonts[] = $headerFontSettings['google_font']; } - return ($protocol?$protocol.':':'').'//fonts.googleapis.com/css?family='.implode('|',$google_fonts); + return ($protocol?$protocol.':':'').'//fonts.googleapis.com/css?family='.implode('|', $google_fonts); } /** * @return mixed */ - public function getHeaderFontId() { + public function getHeaderFontId() + { return ($this->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) && $this->header_font_id) ? $this->header_font_id : DEFAULT_HEADER_FONT; } /** * @return mixed */ - public function getBodyFontId() { + public function getBodyFontId() + { return ($this->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) && $this->body_font_id) ? $this->body_font_id : DEFAULT_BODY_FONT; } /** * @return null */ - public function getHeaderFontName(){ + public function getHeaderFontName() + { return Utils::getFromCache($this->getHeaderFontId(), 'fonts')['name']; } /** * @return null */ - public function getBodyFontName(){ + public function getBodyFontName() + { return Utils::getFromCache($this->getBodyFontId(), 'fonts')['name']; } @@ -1625,11 +1636,12 @@ class Account extends Eloquent * @param bool $include_weight * @return string */ - public function getHeaderFontCss($include_weight = true){ + public function getHeaderFontCss($include_weight = true) + { $font_data = Utils::getFromCache($this->getHeaderFontId(), 'fonts'); $css = 'font-family:'.$font_data['css_stack'].';'; - if($include_weight){ + if ($include_weight) { $css .= 'font-weight:'.$font_data['css_weight'].';'; } @@ -1640,11 +1652,12 @@ class Account extends Eloquent * @param bool $include_weight * @return string */ - public function getBodyFontCss($include_weight = true){ + public function getBodyFontCss($include_weight = true) + { $font_data = Utils::getFromCache($this->getBodyFontId(), 'fonts'); $css = 'font-family:'.$font_data['css_stack'].';'; - if($include_weight){ + if ($include_weight) { $css .= 'font-weight:'.$font_data['css_weight'].';'; } @@ -1654,17 +1667,19 @@ class Account extends Eloquent /** * @return array */ - public function getFonts(){ + public function getFonts() + { return array_unique([$this->getHeaderFontId(), $this->getBodyFontId()]); } /** * @return array */ - public function getFontsData(){ + public function getFontsData() + { $data = []; - foreach($this->getFonts() as $font){ + foreach ($this->getFonts() as $font) { $data[] = Utils::getFromCache($font, 'fonts'); } @@ -1674,13 +1689,16 @@ class Account extends Eloquent /** * @return array */ - public function getFontFolders(){ - return array_map(function($item){return $item['folder'];}, $this->getFontsData()); + public function getFontFolders() + { + return array_map(function ($item) { + return $item['folder']; + }, $this->getFontsData()); } public function isModuleEnabled($entityType) { - if ( ! in_array($entityType, [ + if (! in_array($entityType, [ ENTITY_RECURRING_INVOICE, ENTITY_CREDIT, ENTITY_QUOTE, @@ -1701,7 +1719,7 @@ class Account extends Eloquent public function showAcceptTerms($invoice) { - if ( ! $this->isPro() || ! $invoice->terms) { + if (! $this->isPro() || ! $invoice->terms) { return false; } @@ -1710,7 +1728,7 @@ class Account extends Eloquent public function showSignature($invoice) { - if ( ! $this->isPro()) { + if (! $this->isPro()) { return false; } @@ -1719,7 +1737,7 @@ class Account extends Eloquent public function emailMarkupEnabled() { - if ( ! Utils::isNinja()) { + if (! Utils::isNinja()) { return false; } @@ -1754,8 +1772,7 @@ class Account extends Eloquent } } -Account::updated(function ($account) -{ +Account::updated(function ($account) { // prevent firing event if the invoice/quote counter was changed // TODO: remove once counters are moved to separate table $dirty = $account->getDirty(); diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php index 241d1013f8..a974cc484f 100644 --- a/app/Models/AccountGateway.php +++ b/app/Models/AccountGateway.php @@ -122,7 +122,7 @@ class AccountGateway extends EntityModel */ public function getPublishableStripeKey() { - if ( ! $this->isGateway(GATEWAY_STRIPE)) { + if (! $this->isGateway(GATEWAY_STRIPE)) { return false; } @@ -134,7 +134,7 @@ class AccountGateway extends EntityModel */ public function getAchEnabled() { - return !empty($this->getConfigField('enableAch')); + return !empty($this->getConfigField('enableAch')); } /** @@ -150,7 +150,7 @@ class AccountGateway extends EntityModel */ public function getPlaidSecret() { - if ( ! $this->isGateway(GATEWAY_STRIPE)) { + if (! $this->isGateway(GATEWAY_STRIPE)) { return false; } @@ -162,7 +162,7 @@ class AccountGateway extends EntityModel */ public function getPlaidClientId() { - if ( ! $this->isGateway(GATEWAY_STRIPE)) { + if (! $this->isGateway(GATEWAY_STRIPE)) { return false; } @@ -174,7 +174,7 @@ class AccountGateway extends EntityModel */ public function getPlaidPublicKey() { - if ( ! $this->isGateway(GATEWAY_STRIPE)) { + if (! $this->isGateway(GATEWAY_STRIPE)) { return false; } @@ -210,6 +210,6 @@ class AccountGateway extends EntityModel { $account = $this->account ? $this->account : Account::find($this->account_id); - return \URL::to(env('WEBHOOK_PREFIX','').'payment_hook/'.$account->account_key.'/'.$this->gateway_id.env('WEBHOOK_SUFFIX','')); + return \URL::to(env('WEBHOOK_PREFIX', '').'payment_hook/'.$account->account_key.'/'.$this->gateway_id.env('WEBHOOK_SUFFIX', '')); } } diff --git a/app/Models/AccountGatewayToken.php b/app/Models/AccountGatewayToken.php index 6774db0b51..fe17b10fc9 100644 --- a/app/Models/AccountGatewayToken.php +++ b/app/Models/AccountGatewayToken.php @@ -98,5 +98,4 @@ class AccountGatewayToken extends Eloquent return false; } } - } diff --git a/app/Models/BalanceAffecting.php b/app/Models/BalanceAffecting.php index 1486b7ba82..48b4ee107f 100644 --- a/app/Models/BalanceAffecting.php +++ b/app/Models/BalanceAffecting.php @@ -6,4 +6,4 @@ interface BalanceAffecting { public function getAdjustment(); -} \ No newline at end of file +} diff --git a/app/Models/BankAccount.php b/app/Models/BankAccount.php index 617c04ae94..1d07e0830d 100644 --- a/app/Models/BankAccount.php +++ b/app/Models/BankAccount.php @@ -37,4 +37,3 @@ class BankAccount extends EntityModel return $this->hasMany('App\Models\BankSubaccount'); } } - diff --git a/app/Models/BankSubaccount.php b/app/Models/BankSubaccount.php index 4cda62da04..4bb4865f06 100644 --- a/app/Models/BankSubaccount.php +++ b/app/Models/BankSubaccount.php @@ -1,4 +1,5 @@ belongsTo('App\Models\BankAccount'); } - } - diff --git a/app/Models/Client.php b/app/Models/Client.php index 04435245ea..905bcc6642 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -258,7 +258,7 @@ class Client extends EntityModel */ public function expenses() { - return $this->hasMany('App\Models\Expense','client_id','id')->withTrashed(); + return $this->hasMany('App\Models\Expense', 'client_id', 'id')->withTrashed(); } /** @@ -283,10 +283,10 @@ class Client extends EntityModel } } - if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->account->enable_portal_password){ - if(!empty($data['password']) && $data['password']!='-%unchanged%-'){ + if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $this->account->enable_portal_password) { + if (!empty($data['password']) && $data['password']!='-%unchanged%-') { $contact->password = bcrypt($data['password']); - } else if(empty($data['password'])){ + } elseif (empty($data['password'])) { $contact->password = null; } } @@ -359,7 +359,7 @@ class Client extends EntityModel return $this->name; } - if ( ! count($this->contacts)) { + if (! count($this->contacts)) { return ''; } @@ -435,7 +435,7 @@ class Client extends EntityModel { $accountGateway = $this->account->getGatewayByType(GATEWAY_TYPE_TOKEN); - if ( ! $accountGateway) { + if (! $accountGateway) { return false; } @@ -528,7 +528,8 @@ class Client extends EntityModel /** * @return bool */ - public function hasAutoBillConfigurableInvoices(){ + public function hasAutoBillConfigurableInvoices() + { return $this->invoices()->whereIn('auto_bill', [AUTO_BILL_OPT_IN, AUTO_BILL_OPT_OUT])->count() > 0; } diff --git a/app/Models/Company.php b/app/Models/Company.php index b0213f9d01..59fa5835ee 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -56,7 +56,7 @@ class Company extends Eloquent // handle promos and discounts public function hasActiveDiscount(Carbon $date = null) { - if ( ! $this->discount || ! $this->discount_expires) { + if (! $this->discount || ! $this->discount_expires) { return false; } @@ -71,7 +71,7 @@ class Company extends Eloquent public function discountedPrice($price) { - if ( ! $this->hasActivePromo() && ! $this->hasActiveDiscount()) { + if (! $this->hasActivePromo() && ! $this->hasActiveDiscount()) { return $price; } @@ -80,7 +80,7 @@ class Company extends Eloquent public function daysUntilPlanExpires() { - if ( ! $this->hasActivePlan()) { + if (! $this->hasActivePlan()) { return 0; } @@ -103,7 +103,7 @@ class Company extends Eloquent public function hasEarnedPromo() { - if ( ! Utils::isNinjaProd() || Utils::isPro()) { + if (! Utils::isNinjaProd() || Utils::isPro()) { return false; } diff --git a/app/Models/Contact.php b/app/Models/Contact.php index 94f6c388a1..266794bb9d 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -1,6 +1,5 @@ name; } diff --git a/app/Models/Credit.php b/app/Models/Credit.php index b7d041b148..f803acb1c9 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -98,7 +98,6 @@ class Credit extends EntityModel } Credit::creating(function ($credit) { - }); Credit::created(function ($credit) { diff --git a/app/Models/DatetimeFormat.php b/app/Models/DatetimeFormat.php index a7876a29e8..06bde0ca8c 100644 --- a/app/Models/DatetimeFormat.php +++ b/app/Models/DatetimeFormat.php @@ -20,5 +20,5 @@ class DatetimeFormat extends Eloquent $date = mktime(0, 0, 0, 12, 31, date('Y')); return date($this->format, $date); - } + } } diff --git a/app/Models/Document.php b/app/Models/Document.php index f2d1e43d33..02270d45cf 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -103,7 +103,7 @@ class Document extends EntityModel { parent::fill($attributes); - if(empty($this->attributes['disk'])){ + if (empty($this->attributes['disk'])) { $this->attributes['disk'] = env('DOCUMENT_FILESYSTEM', 'documents'); } @@ -145,7 +145,8 @@ class Document extends EntityModel /** * @return mixed */ - public function getDisk(){ + public function getDisk() + { return Storage::disk(!empty($this->disk)?$this->disk:env('DOCUMENT_FILESYSTEM', 'documents')); } @@ -160,14 +161,16 @@ class Document extends EntityModel /** * @return null|string */ - public function getDirectUrl(){ + public function getDirectUrl() + { return static::getDirectFileUrl($this->path, $this->getDisk()); } /** * @return null|string */ - public function getDirectPreviewUrl(){ + public function getDirectPreviewUrl() + { return $this->preview?static::getDirectFileUrl($this->preview, $this->getDisk(), true):null; } @@ -178,11 +181,12 @@ class Document extends EntityModel * @return null|string * @throws \OpenCloud\Common\Exceptions\NoNameError */ - public static function getDirectFileUrl($path, $disk, $prioritizeSpeed = false){ + public static function getDirectFileUrl($path, $disk, $prioritizeSpeed = false) + { $adapter = $disk->getAdapter(); $fullPath = $adapter->applyPathPrefix($path); - if($adapter instanceof \League\Flysystem\AwsS3v3\AwsS3Adapter) { + if ($adapter instanceof \League\Flysystem\AwsS3v3\AwsS3Adapter) { $client = $adapter->getClient(); $command = $client->getCommand('GetObject', [ 'Bucket' => $adapter->getBucket(), @@ -190,13 +194,13 @@ class Document extends EntityModel ]); return (string) $client->createPresignedRequest($command, '+10 minutes')->getUri(); - } else if (!$prioritizeSpeed // Rackspace temp URLs are slow, so we don't use them for previews + } elseif (!$prioritizeSpeed // Rackspace temp URLs are slow, so we don't use them for previews && $adapter instanceof \League\Flysystem\Rackspace\RackspaceAdapter) { $secret = env('RACKSPACE_TEMP_URL_SECRET'); - if($secret){ + if ($secret) { $object = $adapter->getContainer()->getObject($fullPath); - if(env('RACKSPACE_TEMP_URL_SECRET_SET')){ + if (env('RACKSPACE_TEMP_URL_SECRET_SET')) { // Go ahead and set the secret too $object->getService()->getAccount()->setTempUrlSecret($secret); } @@ -216,7 +220,8 @@ class Document extends EntityModel /** * @return mixed */ - public function getRaw(){ + public function getRaw() + { $disk = $this->getDisk(); return $disk->get($this->path); @@ -225,7 +230,8 @@ class Document extends EntityModel /** * @return mixed */ - public function getStream(){ + public function getStream() + { $disk = $this->getDisk(); return $disk->readStream($this->path); @@ -234,7 +240,8 @@ class Document extends EntityModel /** * @return mixed */ - public function getRawPreview(){ + public function getRawPreview() + { $disk = $this->getDisk(); return $disk->get($this->preview); @@ -243,7 +250,8 @@ class Document extends EntityModel /** * @return \Illuminate\Contracts\Routing\UrlGenerator|string */ - public function getUrl(){ + public function getUrl() + { return url('documents/'.$this->public_id.'/'.$this->name); } @@ -251,37 +259,46 @@ class Document extends EntityModel * @param $invitation * @return \Illuminate\Contracts\Routing\UrlGenerator|string */ - public function getClientUrl($invitation){ + public function getClientUrl($invitation) + { return url('client/documents/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name); } /** * @return bool */ - public function isPDFEmbeddable(){ + public function isPDFEmbeddable() + { return $this->type == 'jpeg' || $this->type == 'png' || $this->preview; } /** * @return \Illuminate\Contracts\Routing\UrlGenerator|null|string */ - public function getVFSJSUrl(){ - if(!$this->isPDFEmbeddable())return null; + public function getVFSJSUrl() + { + if (!$this->isPDFEmbeddable()) { + return null; + } return url('documents/js/'.$this->public_id.'/'.$this->name.'.js'); } /** * @return \Illuminate\Contracts\Routing\UrlGenerator|null|string */ - public function getClientVFSJSUrl(){ - if(!$this->isPDFEmbeddable())return null; + public function getClientVFSJSUrl() + { + if (!$this->isPDFEmbeddable()) { + return null; + } return url('client/documents/js/'.$this->public_id.'/'.$this->name.'.js'); } /** * @return \Illuminate\Contracts\Routing\UrlGenerator|null|string */ - public function getPreviewUrl(){ + public function getPreviewUrl() + { return $this->preview?url('documents/preview/'.$this->public_id.'/'.$this->name.'.'.pathinfo($this->preview, PATHINFO_EXTENSION)):null; } @@ -292,8 +309,12 @@ class Document extends EntityModel { $array = parent::toArray(); - if(empty($this->visible) || in_array('url', $this->visible))$array['url'] = $this->getUrl(); - if(empty($this->visible) || in_array('preview_url', $this->visible))$array['preview_url'] = $this->getPreviewUrl(); + if (empty($this->visible) || in_array('url', $this->visible)) { + $array['url'] = $this->getUrl(); + } + if (empty($this->visible) || in_array('preview_url', $this->visible)) { + $array['preview_url'] = $this->getPreviewUrl(); + } return $array; } @@ -301,7 +322,8 @@ class Document extends EntityModel /** * @return mixed */ - public function cloneDocument(){ + public function cloneDocument() + { $document = Document::createNew($this); $document->path = $this->path; $document->preview = $this->preview; @@ -324,19 +346,18 @@ Document::deleted(function ($document) { ->where('documents.disk', '=', $document->disk) ->count(); - if(!$same_path_count){ + if (!$same_path_count) { $document->getDisk()->delete($document->path); } - if($document->preview){ + if ($document->preview) { $same_preview_count = DB::table('documents') ->where('documents.account_id', '=', $document->account_id) ->where('documents.preview', '=', $document->preview) ->where('documents.disk', '=', $document->disk) ->count(); - if(!$same_preview_count){ + if (!$same_preview_count) { $document->getDisk()->delete($document->preview); } } - }); diff --git a/app/Models/EntityModel.php b/app/Models/EntityModel.php index 05cf083bcb..a7f116bc18 100644 --- a/app/Models/EntityModel.php +++ b/app/Models/EntityModel.php @@ -66,7 +66,7 @@ class EntityModel extends Eloquent $entity->setRelation('user', $user); $entity->setRelation('account', $account); - if (method_exists($className, 'trashed')){ + if (method_exists($className, 'trashed')) { $lastEntity = $className::whereAccountId($entity->account_id)->withTrashed(); } else { $lastEntity = $className::whereAccountId($entity->account_id); @@ -192,7 +192,7 @@ class EntityModel extends Eloquent */ public static function getClassName($entityType) { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { if ($module = \Module::find($entityType)) { return "Modules\\{$module->getName()}\\Models\\{$module->getName()}"; } @@ -211,7 +211,7 @@ class EntityModel extends Eloquent */ public static function getTransformerName($entityType) { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { if ($module = \Module::find($entityType)) { return "Modules\\{$module->getName()}\\Transformers\\{$module->getName()}Transformer"; } @@ -251,16 +251,18 @@ class EntityModel extends Eloquent // Use the API request if it exists $action = $entity ? 'update' : 'create'; $requestClass = sprintf('App\\Http\\Requests\\%s%sAPIRequest', ucwords($action), ucwords($entityType)); - if ( ! class_exists($requestClass)) { + if (! class_exists($requestClass)) { $requestClass = sprintf('App\\Http\\Requests\\%s%sRequest', ucwords($action), ucwords($entityType)); } $request = new $requestClass(); - $request->setUserResolver(function() { return Auth::user(); }); + $request->setUserResolver(function () { + return Auth::user(); + }); $request->setEntity($entity); $request->replace($data); - if ( ! $request->authorize()) { + if (! $request->authorize()) { return trans('texts.not_allowed'); } @@ -346,5 +348,4 @@ class EntityModel extends Eloquent { return ''; } - } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 3a747c0d5c..a170bba07e 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -188,7 +188,9 @@ class Expense extends EntityModel { $array = parent::toArray(); - if(empty($this->visible) || in_array('converted_amount', $this->visible))$array['converted_amount'] = $this->convertedAmount(); + if (empty($this->visible) || in_array('converted_amount', $this->visible)) { + $array['converted_amount'] = $this->convertedAmount(); + } return $array; } @@ -267,7 +269,6 @@ class Expense extends EntityModel return static::calcStatusLabel($this->should_be_invoiced, $this->invoice_id, $balance); } - } Expense::creating(function ($expense) { diff --git a/app/Models/Industry.php b/app/Models/Industry.php index be4920b151..becd7c1b80 100644 --- a/app/Models/Industry.php +++ b/app/Models/Industry.php @@ -15,7 +15,7 @@ class Industry extends Eloquent /** * @return mixed */ - public function getName() + public function getName() { return $this->name; } diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 5b62b82181..85834929f1 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -64,7 +64,7 @@ class Invitation extends EntityModel */ public function getLink($type = 'view', $forceOnsite = false) { - if ( ! $this->account) { + if (! $this->account) { $this->load('account'); } @@ -147,7 +147,7 @@ class Invitation extends EntityModel public function signatureDiv() { - if ( ! $this->signature_base64) { + if (! $this->signature_base64) { return false; } diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index b05f66b19a..b36a0ca5b2 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -178,7 +178,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function getAdjustment() { - if ( ! $this->affectsBalance()) { + if (! $this->affectsBalance()) { return 0; } @@ -327,7 +327,7 @@ class Invoice extends EntityModel implements BalanceAffecting /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ - public function payments() + public function payments() { return $this->hasMany('App\Models\Payment', 'invoice_id', 'id'); } @@ -369,7 +369,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function expenses() { - return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed(); + return $this->hasMany('App\Models\Expense', 'invoice_id', 'id')->withTrashed(); } /** @@ -416,34 +416,37 @@ class Invoice extends EntityModel implements BalanceAffecting * @param $typeId * @return bool */ - public function isType($typeId) { + public function isType($typeId) + { return $this->invoice_type_id == $typeId; } /** * @return bool */ - public function isQuote() { + public function isQuote() + { return $this->isType(INVOICE_TYPE_QUOTE); } /** * @return bool */ - public function isInvoice() { + public function isInvoice() + { return $this->isType(INVOICE_TYPE_STANDARD) && ! $this->is_recurring; } public function markSentIfUnsent() { - if ( ! $this->isSent()) { + if (! $this->isSent()) { $this->markSent(); } } public function markSent() { - if ( ! $this->isSent()) { + if (! $this->isSent()) { $this->invoice_status_id = INVOICE_STATUS_SENT; } @@ -458,7 +461,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function markInvitationsSent($notify = false, $reminder = false) { - if ( ! $this->relationLoaded('invitations')) { + if (! $this->relationLoaded('invitations')) { $this->load('invitations'); } @@ -469,12 +472,12 @@ class Invoice extends EntityModel implements BalanceAffecting public function areInvitationsSent() { - if ( ! $this->relationLoaded('invitations')) { + if (! $this->relationLoaded('invitations')) { $this->load('invitations'); } foreach ($this->invitations as $invitation) { - if ( ! $invitation->isSent()) { + if (! $invitation->isSent()) { return false; } } @@ -489,7 +492,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function markInvitationSent($invitation, $messageId = false, $notify = true, $notes = false) { - if ( ! $this->isSent()) { + if (! $this->isSent()) { $this->invoice_status_id = INVOICE_STATUS_SENT; $this->save(); } @@ -600,7 +603,7 @@ class Invoice extends EntityModel implements BalanceAffecting { if ($quoteInvoiceId) { $label = 'converted'; - } else if ($class == 'danger') { + } elseif ($class == 'danger') { $label = $entityType == ENTITY_INVOICE ? 'overdue' : 'expired'; } else { $label = 'status_' . strtolower($status); @@ -624,11 +627,11 @@ class Invoice extends EntityModel implements BalanceAffecting public static function calcIsOverdue($balance, $dueDate) { - if ( ! Utils::parseFloat($balance) > 0) { + if (! Utils::parseFloat($balance) > 0) { return false; } - if ( ! $dueDate || $dueDate == '0000-00-00') { + if (! $dueDate || $dueDate == '0000-00-00') { return false; } @@ -665,7 +668,7 @@ class Invoice extends EntityModel implements BalanceAffecting public function getInvitationLink($type = 'view', $forceOnsite = false) { - if ( ! $this->relationLoaded('invitations')) { + if (! $this->relationLoaded('invitations')) { $this->load('invitations'); } @@ -958,26 +961,24 @@ class Invoice extends EntityModel implements BalanceAffecting * @param null $invoice_date * @return mixed|null */ - public function getDueDate($invoice_date = null){ - if(!$this->is_recurring) { + public function getDueDate($invoice_date = null) + { + if (!$this->is_recurring) { return $this->due_date ? $this->due_date : null; - } - else{ + } else { $now = time(); - if($invoice_date) { + if ($invoice_date) { // If $invoice_date is specified, all calculations are based on that date - if(is_numeric($invoice_date)) { + if (is_numeric($invoice_date)) { $now = $invoice_date; - } - else if(is_string($invoice_date)) { + } elseif (is_string($invoice_date)) { $now = strtotime($invoice_date); - } - elseif ($invoice_date instanceof \DateTime) { + } elseif ($invoice_date instanceof \DateTime) { $now = $invoice_date->getTimestamp(); } } - if($this->due_date && $this->due_date != '0000-00-00'){ + if ($this->due_date && $this->due_date != '0000-00-00') { // This is a recurring invoice; we're using a custom format here. // The year is always 1998; January is 1st, 2nd, last day of the month. // February is 1st Sunday after, 1st Monday after, ..., through 4th Saturday after. @@ -986,7 +987,7 @@ class Invoice extends EntityModel implements BalanceAffecting $dayVal = (int)date('j', $dueDateVal); $dueDate = false; - if($monthVal == 1) {// January; day of month + if ($monthVal == 1) {// January; day of month $currentDay = (int)date('j', $now); $lastDayOfMonth = (int)date('t', $now); @@ -994,12 +995,12 @@ class Invoice extends EntityModel implements BalanceAffecting $dueMonth = (int)date('n', $now);// This month $dueDay = $dayVal;// The day specified for the invoice - if($dueDay > $lastDayOfMonth) { + if ($dueDay > $lastDayOfMonth) { // No later than the end of the month $dueDay = $lastDayOfMonth; } - if($currentDay >= $dueDay) { + if ($currentDay >= $dueDay) { // Wait until next month // We don't need to handle the December->January wraparaound, since PHP handles month 13 as January of next year $dueMonth++; @@ -1009,15 +1010,14 @@ class Invoice extends EntityModel implements BalanceAffecting $lastDayOfMonth = (int)date('t', mktime(0, 0, 0, $dueMonth, 1, $dueYear));// The number of days in next month // Check against the last day again - if($dueDay > $lastDayOfMonth){ + if ($dueDay > $lastDayOfMonth) { // No later than the end of the month $dueDay = $lastDayOfMonth; } } $dueDate = mktime(0, 0, 0, $dueMonth, $dueDay, $dueYear); - } - else if($monthVal == 2) {// February; day of week + } elseif ($monthVal == 2) {// February; day of week $ordinals = ['first', 'second', 'third', 'fourth']; $daysOfWeek = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; @@ -1028,14 +1028,14 @@ class Invoice extends EntityModel implements BalanceAffecting $dueDate = strtotime($dayStr, $now); } - if($dueDate) { + if ($dueDate) { return date('Y-m-d', $dueDate);// SQL format } - } else if ($this->client->payment_terms != 0) { + } elseif ($this->client->payment_terms != 0) { // No custom due date set for this invoice; use the client's payment terms $days = $this->client->defaultDaysDue(); return date('Y-m-d', strtotime('+'.$days.' day', $now)); - } else if ($this->account->payment_terms != 0) { + } elseif ($this->account->payment_terms != 0) { $days = $this->account->defaultDaysDue(); return date('Y-m-d', strtotime('+'.$days.' day', $now)); } @@ -1064,7 +1064,7 @@ class Invoice extends EntityModel implements BalanceAffecting $date = $this->account->formatDate($dateStart); $dueDate = $this->getDueDate($dateStart); - if($dueDate) { + if ($dueDate) { $date .= ' (' . trans('texts.due') . ' ' . $this->account->formatDate($dueDate) . ')'; } @@ -1128,11 +1128,11 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function shouldSendToday() { - if ( ! $this->user->confirmed) { + if (! $this->user->confirmed) { return false; } - if ( ! $this->start_date || strtotime($this->start_date) > strtotime('now')) { + if (! $this->start_date || strtotime($this->start_date) > strtotime('now')) { return false; } @@ -1187,7 +1187,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ public function getPDFString() { - if ( ! env('PHANTOMJS_CLOUD_KEY') && ! env('PHANTOMJS_BIN_PATH')) { + if (! env('PHANTOMJS_CLOUD_KEY') && ! env('PHANTOMJS_BIN_PATH')) { return false; } @@ -1212,7 +1212,7 @@ class Invoice extends EntityModel implements BalanceAffecting return false; } - if ( ! $pdfString || strlen($pdfString) < 200) { + if (! $pdfString || strlen($pdfString) < 200) { Utils::logError("PhantomJS - Failed to create pdf: {$pdfString}"); return false; } @@ -1324,7 +1324,7 @@ class Invoice extends EntityModel implements BalanceAffecting */ private function calculateTax(&$taxes, $name, $rate, $amount, $paid) { - if ( ! $amount) { + if (! $amount) { return; } @@ -1332,7 +1332,7 @@ class Invoice extends EntityModel implements BalanceAffecting $paid = round($paid, 2); $key = $rate . ' ' . $name; - if ( ! isset($taxes[$key])) { + if (! isset($taxes[$key])) { $taxes[$key] = [ 'name' => $name, 'rate' => $rate+0, @@ -1348,17 +1348,23 @@ class Invoice extends EntityModel implements BalanceAffecting /** * @return bool */ - public function hasDocuments(){ - if(count($this->documents))return true; + public function hasDocuments() + { + if (count($this->documents)) { + return true; + } return $this->hasExpenseDocuments(); } /** * @return bool */ - public function hasExpenseDocuments(){ - foreach($this->expenses as $expense){ - if(count($expense->documents))return true; + public function hasExpenseDocuments() + { + foreach ($this->expenses as $expense) { + if (count($expense->documents)) { + return true; + } } return false; } @@ -1366,7 +1372,8 @@ class Invoice extends EntityModel implements BalanceAffecting /** * @return bool */ - public function getAutoBillEnabled() { + public function getAutoBillEnabled() + { if (!$this->is_recurring) { $recurInvoice = $this->recurring_invoice; } else { diff --git a/app/Models/InvoiceItem.php b/app/Models/InvoiceItem.php index ef9a43f4eb..80c61836a4 100644 --- a/app/Models/InvoiceItem.php +++ b/app/Models/InvoiceItem.php @@ -70,5 +70,4 @@ class InvoiceItem extends EntityModel { return $this->belongsTo('App\Models\Account'); } - } diff --git a/app/Models/Language.php b/app/Models/Language.php index efce90844f..f55eea6c53 100644 --- a/app/Models/Language.php +++ b/app/Models/Language.php @@ -15,7 +15,7 @@ class Language extends Eloquent /** * @return mixed */ - public function getName() + public function getName() { return $this->name; } diff --git a/app/Models/OwnedByClientTrait.php b/app/Models/OwnedByClientTrait.php index dc6e6208ae..d339089f85 100644 --- a/app/Models/OwnedByClientTrait.php +++ b/app/Models/OwnedByClientTrait.php @@ -16,4 +16,4 @@ trait OwnedByClientTrait return $this->client->trashed(); } -} \ No newline at end of file +} diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 4f08018060..0d2634c3ed 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -352,7 +352,6 @@ class Payment extends EntityModel } Payment::creating(function ($payment) { - }); Payment::created(function ($payment) { diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index 5b9a64757c..511cf632d4 100644 --- a/app/Models/PaymentMethod.php +++ b/app/Models/PaymentMethod.php @@ -113,7 +113,7 @@ class PaymentMethod extends EntityModel */ public function scopeClientId($query, $clientId) { - $query->whereHas('contact', function($query) use ($clientId) { + $query->whereHas('contact', function ($query) use ($clientId) { $query->whereClientId($clientId); }); } @@ -143,7 +143,8 @@ class PaymentMethod extends EntityModel * @param $routingNumber * @return mixed|null|\stdClass|string */ - public static function lookupBankData($routingNumber) { + public static function lookupBankData($routingNumber) + { $cached = Cache::get('bankData:'.$routingNumber); if ($cached != null) { @@ -178,7 +179,7 @@ class PaymentMethod extends EntityModel if ($thisNumber > $routingNumber) { $high = $mid - 1; - } else if ($thisNumber < $routingNumber) { + } elseif ($thisNumber < $routingNumber) { $low = $mid + 1; } else { $data = new \stdClass(); @@ -228,10 +229,10 @@ class PaymentMethod extends EntityModel } } -PaymentMethod::deleting(function($paymentMethod) { +PaymentMethod::deleting(function ($paymentMethod) { $accountGatewayToken = $paymentMethod->account_gateway_token; if ($accountGatewayToken->default_payment_method_id == $paymentMethod->id) { - $newDefault = $accountGatewayToken->payment_methods->first(function($i, $paymentMethdod) use ($accountGatewayToken){ + $newDefault = $accountGatewayToken->payment_methods->first(function ($i, $paymentMethdod) use ($accountGatewayToken) { return $paymentMethdod->id != $accountGatewayToken->default_payment_method_id; }); $accountGatewayToken->default_payment_method_id = $newDefault ? $newDefault->id : null; diff --git a/app/Models/PaymentTerm.php b/app/Models/PaymentTerm.php index 1c3397a5ab..d4abecdb8a 100644 --- a/app/Models/PaymentTerm.php +++ b/app/Models/PaymentTerm.php @@ -25,5 +25,4 @@ class PaymentTerm extends EntityModel { return ENTITY_PAYMENT_TERM; } - } diff --git a/app/Models/Project.php b/app/Models/Project.php index 7e34f0bbf1..63f576e9b7 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -52,7 +52,6 @@ class Project extends EntityModel { return $this->belongsTo('App\Models\Client')->withTrashed(); } - } Project::creating(function ($project) { diff --git a/app/Models/SecurityCode.php b/app/Models/SecurityCode.php index 1725e65889..d51e5a7c9a 100644 --- a/app/Models/SecurityCode.php +++ b/app/Models/SecurityCode.php @@ -11,5 +11,4 @@ class SecurityCode extends Eloquent * @var bool */ public $timestamps = false; - } diff --git a/app/Models/Size.php b/app/Models/Size.php index 16526d83f0..3329a0313c 100644 --- a/app/Models/Size.php +++ b/app/Models/Size.php @@ -15,8 +15,8 @@ class Size extends Eloquent /** * @return mixed */ - public function getName() + public function getName() { return $this->name; - } + } } diff --git a/app/Models/Task.php b/app/Models/Task.php index 73f0af286f..bad8a68ae8 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -102,14 +102,14 @@ class Task extends EntityModel public function getLastStartTime() { - $parts = json_decode($this->time_log) ?: []; + $parts = json_decode($this->time_log) ?: []; - if (count($parts)) { - $index = count($parts) - 1; - return $parts[$index][0]; - } else { - return ''; - } + if (count($parts)) { + $index = count($parts) - 1; + return $parts[$index][0]; + } else { + return ''; + } } /** diff --git a/app/Models/TaxRate.php b/app/Models/TaxRate.php index f9c25afc38..6bba12fc4f 100644 --- a/app/Models/TaxRate.php +++ b/app/Models/TaxRate.php @@ -45,5 +45,4 @@ class TaxRate extends EntityModel { return sprintf('%s: %s%%', $this->name, $this->rate); } - } diff --git a/app/Models/Traits/GeneratesNumbers.php b/app/Models/Traits/GeneratesNumbers.php index 8cda08d0af..ec0520ee00 100644 --- a/app/Models/Traits/GeneratesNumbers.php +++ b/app/Models/Traits/GeneratesNumbers.php @@ -53,7 +53,7 @@ trait GeneratesNumbers $this->save(); } } elseif ($entity->isType(INVOICE_TYPE_QUOTE)) { - if ( ! $this->share_counter) { + if (! $this->share_counter) { $this->quote_number_counter += $counterOffset - 1; $this->save(); } @@ -76,7 +76,7 @@ trait GeneratesNumbers */ public function getNumberPrefix($entityType) { - if ( ! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) { + if (! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) { return ''; } @@ -90,7 +90,7 @@ trait GeneratesNumbers */ public function getNumberPattern($entityType) { - if ( ! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) { + if (! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) { return false; } diff --git a/app/Models/Traits/PresentsInvoice.php b/app/Models/Traits/PresentsInvoice.php index 4fd9e225ac..e739036d54 100644 --- a/app/Models/Traits/PresentsInvoice.php +++ b/app/Models/Traits/PresentsInvoice.php @@ -143,7 +143,6 @@ trait PresentsInvoice } return $fields; - } /** @@ -238,6 +237,4 @@ trait PresentsInvoice return $data; } - - } diff --git a/app/Models/Traits/SendsEmails.php b/app/Models/Traits/SendsEmails.php index be086687c3..402293cba2 100644 --- a/app/Models/Traits/SendsEmails.php +++ b/app/Models/Traits/SendsEmails.php @@ -15,7 +15,7 @@ trait SendsEmails public function getFromEmail() { - if ( ! $this->isPro() || ! Utils::isNinja() || Utils::isReseller()) { + if (! $this->isPro() || ! Utils::isNinja() || Utils::isReseller()) { return false; } diff --git a/app/Models/User.php b/app/Models/User.php index d60a7c9889..9d328ded19 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -296,23 +296,24 @@ class User extends Authenticatable * @param mixed $value * @return $this */ - protected function setPermissionsAttribute($value){ - if(empty($value)) { + protected function setPermissionsAttribute($value) + { + if (empty($value)) { $this->attributes['permissions'] = 0; } else { $bitmask = 0; - foreach($value as $permission){ - if ( ! $permission) { - continue; - } - $bitmask = $bitmask | static::$all_permissions[$permission]; + foreach ($value as $permission) { + if (! $permission) { + continue; + } + $bitmask = $bitmask | static::$all_permissions[$permission]; } $this->attributes['permissions'] = $bitmask; } return $this; - } + } /** * Expands the value of the permissions attribute @@ -320,10 +321,11 @@ class User extends Authenticatable * @param mixed $value * @return mixed */ - protected function getPermissionsAttribute($value){ + protected function getPermissionsAttribute($value) + { $permissions = []; - foreach(static::$all_permissions as $permission => $bitmask){ - if(($value & $bitmask) == $bitmask) { + foreach (static::$all_permissions as $permission => $bitmask) { + if (($value & $bitmask) == $bitmask) { $permissions[$permission] = $permission; } } @@ -338,13 +340,14 @@ class User extends Authenticatable * @param boolean True to require all permissions, false to require only one * @return boolean */ - public function hasPermission($permission, $requireAll = false){ + public function hasPermission($permission, $requireAll = false) + { if ($this->is_admin) { return true; - } else if(is_string($permission)){ + } elseif (is_string($permission)) { return !empty($this->permissions[$permission]); - } else if(is_array($permission)) { - if($requireAll){ + } elseif (is_array($permission)) { + if ($requireAll) { return count(array_diff($permission, $this->permissions)) == 0; } else { return count(array_intersect($permission, $this->permissions)) > 0; @@ -358,23 +361,25 @@ class User extends Authenticatable * @param $entity * @return bool */ - public function owns($entity) { + public function owns($entity) + { return !empty($entity->user_id) && $entity->user_id == $this->id; } /** * @return bool|mixed */ - public function filterId() { + public function filterId() + { return $this->hasPermission('view_all') ? false : $this->id; } public function caddAddUsers() { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { return true; - } elseif ( ! $this->hasFeature(FEATURE_USERS)) { + } elseif (! $this->hasFeature(FEATURE_USERS)) { return false; } diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php index 466c6cc8fa..3fe1a6dbcb 100644 --- a/app/Models/Vendor.php +++ b/app/Models/Vendor.php @@ -201,7 +201,7 @@ class Vendor extends EntityModel */ public function expenses() { - return $this->hasMany('App\Models\Expense','vendor_id','id'); + return $this->hasMany('App\Models\Expense', 'vendor_id', 'id'); } /** diff --git a/app/Models/VendorContact.php b/app/Models/VendorContact.php index abcf4f097f..df1b40c936 100644 --- a/app/Models/VendorContact.php +++ b/app/Models/VendorContact.php @@ -1,4 +1,5 @@ resendConfirmationUrl = $url = URL::to("gateways/{$accountGateway->public_id}/resend_confirmation"); $html = link_to($url, $linkText)->toHtml(); } - } catch(\WePayException $ex){} + } catch (\WePayException $ex) { + } return $html; } @@ -111,7 +112,7 @@ class AccountGatewayDatatable extends EntityDatatable function ($model) { return $model->resendConfirmationUrl; }, - function($model) { + function ($model) { return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->resendConfirmationUrl); } ] , [ @@ -119,7 +120,7 @@ class AccountGatewayDatatable extends EntityDatatable function ($model) { return URL::to("gateways/{$model->public_id}/edit"); }, - function($model) { + function ($model) { return !$model->deleted_at; } ], [ @@ -127,7 +128,7 @@ class AccountGatewayDatatable extends EntityDatatable function ($model) { return $model->setupUrl; }, - function($model) { + function ($model) { return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY && !empty($model->setupUrl); } ], [ @@ -140,7 +141,7 @@ class AccountGatewayDatatable extends EntityDatatable 'attributes' => 'target="_blank"' ]; }, - function($model) { + function ($model) { return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY; } ], [ @@ -148,7 +149,7 @@ class AccountGatewayDatatable extends EntityDatatable function ($model) { return 'https://go.wepay.com/terms-of-service-us'; }, - function($model) { + function ($model) { return $model->gateway_id == GATEWAY_WEPAY; } ] @@ -194,5 +195,4 @@ class AccountGatewayDatatable extends EntityDatatable return static::$accountGateways[$id]; } - } diff --git a/app/Ninja/Datatables/BankAccountDatatable.php b/app/Ninja/Datatables/BankAccountDatatable.php index 6f0eb1c00e..68494013f7 100644 --- a/app/Ninja/Datatables/BankAccountDatatable.php +++ b/app/Ninja/Datatables/BankAccountDatatable.php @@ -35,6 +35,4 @@ class BankAccountDatatable extends EntityDatatable ] ]; } - - } diff --git a/app/Ninja/Datatables/ClientDatatable.php b/app/Ninja/Datatables/ClientDatatable.php index cb4850f73e..4cfe477825 100644 --- a/app/Ninja/Datatables/ClientDatatable.php +++ b/app/Ninja/Datatables/ClientDatatable.php @@ -64,7 +64,9 @@ class ClientDatatable extends EntityDatatable } ], [ - '--divider--', function(){return false;}, + '--divider--', function () { + return false; + }, function ($model) { $user = Auth::user(); return $user->can('editByOwner', [ENTITY_CLIENT, $model->user_id]) && ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)); @@ -98,7 +100,9 @@ class ClientDatatable extends EntityDatatable } ], [ - '--divider--', function(){return false;}, + '--divider--', function () { + return false; + }, function ($model) { $user = Auth::user(); return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE)); @@ -133,5 +137,4 @@ class ClientDatatable extends EntityDatatable ] ]; } - } diff --git a/app/Ninja/Datatables/CreditDatatable.php b/app/Ninja/Datatables/CreditDatatable.php index 6e2dd491b1..4d7b3e1616 100644 --- a/app/Ninja/Datatables/CreditDatatable.php +++ b/app/Ninja/Datatables/CreditDatatable.php @@ -15,7 +15,7 @@ class CreditDatatable extends EntityDatatable [ 'client_name', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } @@ -38,7 +38,7 @@ class CreditDatatable extends EntityDatatable [ 'credit_date', function ($model) { - if ( ! Auth::user()->can('viewByOwner', [ENTITY_CREDIT, $model->user_id])){ + if (! Auth::user()->can('viewByOwner', [ENTITY_CREDIT, $model->user_id])) { return Utils::fromSqlDate($model->credit_date); } diff --git a/app/Ninja/Datatables/EntityDatatable.php b/app/Ninja/Datatables/EntityDatatable.php index 8d6249c199..ef177ae2bf 100644 --- a/app/Ninja/Datatables/EntityDatatable.php +++ b/app/Ninja/Datatables/EntityDatatable.php @@ -37,7 +37,7 @@ class EntityDatatable [ 'label' => mtrans($this->entityType, 'delete_'.$this->entityType), 'url' => 'javascript:submitForm_'.$this->entityType.'("delete")', - ] + ] ]; } @@ -88,6 +88,4 @@ class EntityDatatable return $indices; } - - } diff --git a/app/Ninja/Datatables/ExpenseCategoryDatatable.php b/app/Ninja/Datatables/ExpenseCategoryDatatable.php index 82206b8f8c..f5d4a7b554 100644 --- a/app/Ninja/Datatables/ExpenseCategoryDatatable.php +++ b/app/Ninja/Datatables/ExpenseCategoryDatatable.php @@ -14,9 +14,8 @@ class ExpenseCategoryDatatable extends EntityDatatable return [ [ 'name', - function ($model) - { - if ( ! Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->user_id])) { + function ($model) { + if (! Auth::user()->can('editByOwner', [ENTITY_EXPENSE_CATEGORY, $model->user_id])) { return $model->category; } @@ -40,5 +39,4 @@ class ExpenseCategoryDatatable extends EntityDatatable ], ]; } - } diff --git a/app/Ninja/Datatables/ExpenseDatatable.php b/app/Ninja/Datatables/ExpenseDatatable.php index a818eb0b79..a7dc329cf4 100644 --- a/app/Ninja/Datatables/ExpenseDatatable.php +++ b/app/Ninja/Datatables/ExpenseDatatable.php @@ -15,10 +15,9 @@ class ExpenseDatatable extends EntityDatatable return [ [ 'vendor_name', - function ($model) - { + function ($model) { if ($model->vendor_public_id) { - if(!Auth::user()->can('viewByOwner', [ENTITY_VENDOR, $model->vendor_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_VENDOR, $model->vendor_user_id])) { return $model->vendor_name; } @@ -31,10 +30,9 @@ class ExpenseDatatable extends EntityDatatable ], [ 'client_name', - function ($model) - { + function ($model) { if ($model->client_public_id) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } @@ -48,7 +46,7 @@ class ExpenseDatatable extends EntityDatatable [ 'expense_date', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])) { return Utils::fromSqlDate($model->expense_date); } @@ -131,5 +129,4 @@ class ExpenseDatatable extends EntityDatatable return "

$label

"; } - } diff --git a/app/Ninja/Datatables/InvoiceDatatable.php b/app/Ninja/Datatables/InvoiceDatatable.php index 546c71152a..c84db083f4 100644 --- a/app/Ninja/Datatables/InvoiceDatatable.php +++ b/app/Ninja/Datatables/InvoiceDatatable.php @@ -18,7 +18,7 @@ class InvoiceDatatable extends EntityDatatable [ $entityType == ENTITY_INVOICE ? 'invoice_number' : 'quote_number', function ($model) use ($entityType) { - if(!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->user_id])) { return $model->invoice_number; } @@ -28,7 +28,7 @@ class InvoiceDatatable extends EntityDatatable [ 'client_name', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } return link_to("clients/{$model->client_public_id}", Utils::getClientDisplayName($model))->toHtml(); @@ -104,7 +104,9 @@ class InvoiceDatatable extends EntityDatatable } ], [ - '--divider--', function(){return false;}, + '--divider--', function () { + return false; + }, function ($model) { return Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]) || Auth::user()->can('create', ENTITY_PAYMENT); } diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php index ac24ed1dd3..4a3cd5066e 100644 --- a/app/Ninja/Datatables/PaymentDatatable.php +++ b/app/Ninja/Datatables/PaymentDatatable.php @@ -23,7 +23,7 @@ class PaymentDatatable extends EntityDatatable [ 'invoice_name', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->invoice_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_INVOICE, $model->invoice_user_id])) { return $model->invoice_number; } @@ -33,7 +33,7 @@ class PaymentDatatable extends EntityDatatable [ 'client_name', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } @@ -59,24 +59,24 @@ class PaymentDatatable extends EntityDatatable $code = str_replace(' ', '', strtolower($model->payment_type)); $card_type = trans('texts.card_' . $code); if ($model->payment_type_id != PAYMENT_TYPE_ACH) { - if($model->last4) { + if ($model->last4) { $expiration = Utils::fromSqlDate($model->expiration, false)->format('m/y'); return '' . htmlentities($card_type) . '  •••' . $model->last4 . ' ' . $expiration; } elseif ($model->email) { return $model->email; } } elseif ($model->last4) { - if($model->bank_name) { + if ($model->bank_name) { $bankName = $model->bank_name; } else { $bankData = PaymentMethod::lookupBankData($model->routing_number); - if($bankData) { + if ($bankData) { $bankName = $bankData->name; } } if (!empty($bankName)) { return $bankName.'  •••' . $model->last4; - } elseif($model->last4) { + } elseif ($model->last4) { return '' . htmlentities($card_type) . '  •••' . $model->last4; } } diff --git a/app/Ninja/Datatables/ProductDatatable.php b/app/Ninja/Datatables/ProductDatatable.php index bf57064f1a..023cba0571 100644 --- a/app/Ninja/Datatables/ProductDatatable.php +++ b/app/Ninja/Datatables/ProductDatatable.php @@ -52,5 +52,4 @@ class ProductDatatable extends EntityDatatable ] ]; } - } diff --git a/app/Ninja/Datatables/ProjectDatatable.php b/app/Ninja/Datatables/ProjectDatatable.php index 15b8fc6178..2e1a93ffd5 100644 --- a/app/Ninja/Datatables/ProjectDatatable.php +++ b/app/Ninja/Datatables/ProjectDatatable.php @@ -14,9 +14,8 @@ class ProjectDatatable extends EntityDatatable return [ [ 'project', - function ($model) - { - if ( ! Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id])) { + function ($model) { + if (! Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->user_id])) { return $model->project; } @@ -25,10 +24,9 @@ class ProjectDatatable extends EntityDatatable ], [ 'client_name', - function ($model) - { + function ($model) { if ($model->client_public_id) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } @@ -55,5 +53,4 @@ class ProjectDatatable extends EntityDatatable ], ]; } - } diff --git a/app/Ninja/Datatables/RecurringInvoiceDatatable.php b/app/Ninja/Datatables/RecurringInvoiceDatatable.php index 5fe1365817..454e129ecf 100644 --- a/app/Ninja/Datatables/RecurringInvoiceDatatable.php +++ b/app/Ninja/Datatables/RecurringInvoiceDatatable.php @@ -77,5 +77,4 @@ class RecurringInvoiceDatatable extends EntityDatatable ]; } - } diff --git a/app/Ninja/Datatables/TaskDatatable.php b/app/Ninja/Datatables/TaskDatatable.php index bae69b8552..43f890b51f 100644 --- a/app/Ninja/Datatables/TaskDatatable.php +++ b/app/Ninja/Datatables/TaskDatatable.php @@ -16,7 +16,7 @@ class TaskDatatable extends EntityDatatable [ 'client_name', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_CLIENT, $model->client_user_id])) { return Utils::getClientDisplayName($model); } @@ -27,7 +27,7 @@ class TaskDatatable extends EntityDatatable [ 'project', function ($model) { - if(!Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->project_user_id])){ + if (!Auth::user()->can('editByOwner', [ENTITY_PROJECT, $model->project_user_id])) { return $model->project; } @@ -37,7 +37,7 @@ class TaskDatatable extends EntityDatatable [ 'date', function ($model) { - if(!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])){ + if (!Auth::user()->can('viewByOwner', [ENTITY_EXPENSE, $model->user_id])) { return Task::calcStartTime($model); } return link_to("tasks/{$model->public_id}/edit", Task::calcStartTime($model))->toHtml(); @@ -45,7 +45,7 @@ class TaskDatatable extends EntityDatatable ], [ 'duration', - function($model) { + function ($model) { return Utils::formatTime(Task::calcDuration($model)); } ], @@ -113,6 +113,4 @@ class TaskDatatable extends EntityDatatable return "

$label

"; } - - } diff --git a/app/Ninja/Datatables/TaxRateDatatable.php b/app/Ninja/Datatables/TaxRateDatatable.php index 4cc763d87e..87f7d986ef 100644 --- a/app/Ninja/Datatables/TaxRateDatatable.php +++ b/app/Ninja/Datatables/TaxRateDatatable.php @@ -41,5 +41,4 @@ class TaxRateDatatable extends EntityDatatable ] ]; } - } diff --git a/app/Ninja/Datatables/TokenDatatable.php b/app/Ninja/Datatables/TokenDatatable.php index 7fb77ebc96..13513deb15 100644 --- a/app/Ninja/Datatables/TokenDatatable.php +++ b/app/Ninja/Datatables/TokenDatatable.php @@ -35,5 +35,4 @@ class TokenDatatable extends EntityDatatable ] ]; } - } diff --git a/app/Ninja/Datatables/UserDatatable.php b/app/Ninja/Datatables/UserDatatable.php index 2bf4f7a1cc..5523021b6d 100644 --- a/app/Ninja/Datatables/UserDatatable.php +++ b/app/Ninja/Datatables/UserDatatable.php @@ -29,7 +29,7 @@ class UserDatatable extends EntityDatatable } elseif ($model->deleted_at) { return self::getStatusLabel(USER_STATE_DISABLED); } elseif ($model->confirmed) { - if($model->is_admin){ + if ($model->is_admin) { return self::getStatusLabel(USER_STATE_ADMIN); } else { return self::getStatusLabel(USER_STATE_ACTIVE); @@ -89,6 +89,4 @@ class UserDatatable extends EntityDatatable } return "

$label

"; } - - } diff --git a/app/Ninja/Datatables/VendorDatatable.php b/app/Ninja/Datatables/VendorDatatable.php index 8898f922cc..6e0e063b3d 100644 --- a/app/Ninja/Datatables/VendorDatatable.php +++ b/app/Ninja/Datatables/VendorDatatable.php @@ -58,7 +58,9 @@ class VendorDatatable extends EntityDatatable } ], [ - '--divider--', function(){return false;}, + '--divider--', function () { + return false; + }, function ($model) { return Auth::user()->can('editByOwner', [ENTITY_VENDOR, $model->user_id]) && Auth::user()->can('create', ENTITY_EXPENSE); } @@ -75,6 +77,4 @@ class VendorDatatable extends EntityDatatable ] ]; } - - } diff --git a/app/Ninja/Import/BaseTransformer.php b/app/Ninja/Import/BaseTransformer.php index df9058a855..8c6f316d26 100644 --- a/app/Ninja/Import/BaseTransformer.php +++ b/app/Ninja/Import/BaseTransformer.php @@ -215,5 +215,4 @@ class BaseTransformer extends TransformerAbstract $name = strtolower(trim($name)); return isset($this->maps[ENTITY_EXPENSE_CATEGORY][$name]) ? $this->maps[ENTITY_EXPENSE_CATEGORY][$name] : null; } - } diff --git a/app/Ninja/Import/CSV/InvoiceTransformer.php b/app/Ninja/Import/CSV/InvoiceTransformer.php index 2d151a4560..f5e2dbfc49 100644 --- a/app/Ninja/Import/CSV/InvoiceTransformer.php +++ b/app/Ninja/Import/CSV/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->name)) { + if (! $this->getClientId($data->name)) { return false; } diff --git a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php index ef5e11571d..d8d68f426a 100644 --- a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php +++ b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->organization)) { + if (! $this->getClientId($data->organization)) { return false; } @@ -41,4 +41,4 @@ class InvoiceTransformer extends BaseTransformer ]; }); } -} \ No newline at end of file +} diff --git a/app/Ninja/Import/FreshBooks/TaskTransformer.php b/app/Ninja/Import/FreshBooks/TaskTransformer.php index 09e4095960..8d568d2668 100644 --- a/app/Ninja/Import/FreshBooks/TaskTransformer.php +++ b/app/Ninja/Import/FreshBooks/TaskTransformer.php @@ -25,4 +25,4 @@ class TaskTransformer extends BaseTransformer } } -*/ \ No newline at end of file +*/ diff --git a/app/Ninja/Import/Harvest/ContactTransformer.php b/app/Ninja/Import/Harvest/ContactTransformer.php index 2e5b667e50..6ebc7ace85 100644 --- a/app/Ninja/Import/Harvest/ContactTransformer.php +++ b/app/Ninja/Import/Harvest/ContactTransformer.php @@ -14,7 +14,7 @@ class ContactTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->hasClient($data->client)) { + if (! $this->hasClient($data->client)) { return false; } diff --git a/app/Ninja/Import/Harvest/InvoiceTransformer.php b/app/Ninja/Import/Harvest/InvoiceTransformer.php index d6b2f619b0..9b23e906dc 100644 --- a/app/Ninja/Import/Harvest/InvoiceTransformer.php +++ b/app/Ninja/Import/Harvest/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->client)) { + if (! $this->getClientId($data->client)) { return false; } diff --git a/app/Ninja/Import/Harvest/VendorContactTransformer.php b/app/Ninja/Import/Harvest/VendorContactTransformer.php index 7f3533fd78..b3191c0f84 100644 --- a/app/Ninja/Import/Harvest/VendorContactTransformer.php +++ b/app/Ninja/Import/Harvest/VendorContactTransformer.php @@ -15,7 +15,7 @@ class VendorContactTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->hasVendor($data->vendor)) { + if (! $this->hasVendor($data->vendor)) { return false; } diff --git a/app/Ninja/Import/Hiveage/InvoiceTransformer.php b/app/Ninja/Import/Hiveage/InvoiceTransformer.php index a35e0a6d65..2d1502d694 100644 --- a/app/Ninja/Import/Hiveage/InvoiceTransformer.php +++ b/app/Ninja/Import/Hiveage/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->client)) { + if (! $this->getClientId($data->client)) { return false; } diff --git a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php index 23644d81ff..4e06b91833 100644 --- a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php +++ b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->client_name)) { + if (! $this->getClientId($data->client_name)) { return false; } @@ -42,4 +42,4 @@ class InvoiceTransformer extends BaseTransformer ]; }); } -} \ No newline at end of file +} diff --git a/app/Ninja/Import/Nutcache/InvoiceTransformer.php b/app/Ninja/Import/Nutcache/InvoiceTransformer.php index 463585e89c..92eea4da0d 100644 --- a/app/Ninja/Import/Nutcache/InvoiceTransformer.php +++ b/app/Ninja/Import/Nutcache/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->client)) { + if (! $this->getClientId($data->client)) { return false; } diff --git a/app/Ninja/Import/Nutcache/TaskTransformer.php b/app/Ninja/Import/Nutcache/TaskTransformer.php index 09e4095960..8d568d2668 100644 --- a/app/Ninja/Import/Nutcache/TaskTransformer.php +++ b/app/Ninja/Import/Nutcache/TaskTransformer.php @@ -25,4 +25,4 @@ class TaskTransformer extends BaseTransformer } } -*/ \ No newline at end of file +*/ diff --git a/app/Ninja/Import/Ronin/InvoiceTransformer.php b/app/Ninja/Import/Ronin/InvoiceTransformer.php index 4f3ed70817..a1ce819442 100644 --- a/app/Ninja/Import/Ronin/InvoiceTransformer.php +++ b/app/Ninja/Import/Ronin/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->client)) { + if (! $this->getClientId($data->client)) { return false; } @@ -41,4 +41,4 @@ class InvoiceTransformer extends BaseTransformer ]; }); } -} \ No newline at end of file +} diff --git a/app/Ninja/Import/Wave/InvoiceTransformer.php b/app/Ninja/Import/Wave/InvoiceTransformer.php index 9dff9c39db..218aa71b7a 100644 --- a/app/Ninja/Import/Wave/InvoiceTransformer.php +++ b/app/Ninja/Import/Wave/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->customer)) { + if (! $this->getClientId($data->customer)) { return false; } diff --git a/app/Ninja/Import/Wave/PaymentTransformer.php b/app/Ninja/Import/Wave/PaymentTransformer.php index d08225b8e3..799f8abdfe 100644 --- a/app/Ninja/Import/Wave/PaymentTransformer.php +++ b/app/Ninja/Import/Wave/PaymentTransformer.php @@ -14,7 +14,7 @@ class PaymentTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getInvoiceClientId($data->invoice_num)) { + if (! $this->getInvoiceClientId($data->invoice_num)) { return false; } diff --git a/app/Ninja/Import/Zoho/InvoiceTransformer.php b/app/Ninja/Import/Zoho/InvoiceTransformer.php index 268c675a98..02c85d41d4 100644 --- a/app/Ninja/Import/Zoho/InvoiceTransformer.php +++ b/app/Ninja/Import/Zoho/InvoiceTransformer.php @@ -14,7 +14,7 @@ class InvoiceTransformer extends BaseTransformer */ public function transform($data) { - if ( ! $this->getClientId($data->customer_name)) { + if (! $this->getClientId($data->customer_name)) { return false; } diff --git a/app/Ninja/Intents/BaseIntent.php b/app/Ninja/Intents/BaseIntent.php index 7640e16072..4db4fa4420 100644 --- a/app/Ninja/Intents/BaseIntent.php +++ b/app/Ninja/Intents/BaseIntent.php @@ -14,7 +14,7 @@ class BaseIntent public function __construct($state, $data) { //if (true) { - if ( ! $state || is_string($state)) { + if (! $state || is_string($state)) { $state = new stdClass; foreach (['current', 'previous'] as $reference) { $state->$reference = new stdClass; @@ -33,7 +33,7 @@ class BaseIntent public static function createIntent($state, $data) { - if ( ! count($data->intents)) { + if (! count($data->intents)) { throw new Exception(trans('texts.intent_not_found')); } @@ -47,7 +47,7 @@ class BaseIntent } } - if ( ! $entityType) { + if (! $entityType) { $entityType = $state->current->entityType; } @@ -57,7 +57,7 @@ class BaseIntent //echo "Intent: $intent

"; - if ( ! class_exists($className)) { + if (! class_exists($className)) { throw new Exception(trans('texts.intent_not_supported')); } @@ -72,7 +72,7 @@ class BaseIntent public function setStateEntities($entityType, $entities) { - if ( ! is_array($entities)) { + if (! is_array($entities)) { $entities = [$entities]; } @@ -140,7 +140,7 @@ class BaseIntent { $data = []; - if ( ! isset($this->data->compositeEntities)) { + if (! isset($this->data->compositeEntities)) { return []; } @@ -154,7 +154,8 @@ class BaseIntent foreach ($compositeEntity->children as $child) { if ($child->type == 'Field') { - $field = $child->value;; + $field = $child->value; + ; } elseif ($child->type == 'Value') { $value = $child->value; } @@ -213,7 +214,7 @@ class BaseIntent } else { if ($content instanceof \Illuminate\Database\Eloquent\Collection) { // do nothing - } elseif ( ! is_array($content)) { + } elseif (! is_array($content)) { $content = [$content]; } diff --git a/app/Ninja/Intents/CreateInvoiceIntent.php b/app/Ninja/Intents/CreateInvoiceIntent.php index 96a1b9d64d..ea2647aadc 100644 --- a/app/Ninja/Intents/CreateInvoiceIntent.php +++ b/app/Ninja/Intents/CreateInvoiceIntent.php @@ -10,7 +10,7 @@ class CreateInvoiceIntent extends InvoiceIntent $client = $this->requestClient(); $invoiceItems = $this->requestInvoiceItems(); - if ( ! $client) { + if (! $client) { throw new Exception(trans('texts.client_not_found')); } @@ -30,7 +30,7 @@ class CreateInvoiceIntent extends InvoiceIntent $invoiceService = app('App\Services\InvoiceService'); $invoice = $invoiceService->save($data); - $invoiceItemIds = array_map(function($item) { + $invoiceItemIds = array_map(function ($item) { return $item['public_id']; }, $invoice->invoice_items->toArray()); diff --git a/app/Ninja/Intents/EmailInvoiceIntent.php b/app/Ninja/Intents/EmailInvoiceIntent.php index 2d857c9280..64a26c5903 100644 --- a/app/Ninja/Intents/EmailInvoiceIntent.php +++ b/app/Ninja/Intents/EmailInvoiceIntent.php @@ -12,7 +12,7 @@ class EmailInvoiceIntent extends InvoiceIntent { $invoice = $this->stateInvoice(); - if ( ! Auth::user()->can('edit', $invoice)) { + if (! Auth::user()->can('edit', $invoice)) { throw new Exception(trans('texts.not_allowed')); } diff --git a/app/Ninja/Intents/InvoiceIntent.php b/app/Ninja/Intents/InvoiceIntent.php index fdba48a560..6d876f461a 100644 --- a/app/Ninja/Intents/InvoiceIntent.php +++ b/app/Ninja/Intents/InvoiceIntent.php @@ -22,17 +22,17 @@ class InvoiceIntent extends BaseIntent { $invoiceId = $this->stateEntity(ENTITY_INVOICE); - if ( ! $invoiceId) { + if (! $invoiceId) { throw new Exception(trans('texts.intent_not_supported')); } $invoice = Invoice::scope($invoiceId)->first(); - if ( ! $invoice) { + if (! $invoice) { throw new Exception(trans('texts.intent_not_supported')); } - if ( ! Auth::user()->can('view', $invoice)) { + if (! Auth::user()->can('view', $invoice)) { throw new Exception(trans('texts.not_allowed')); } @@ -46,7 +46,7 @@ class InvoiceIntent extends BaseIntent $invoiceItems = []; $offset = 0; - if ( ! isset($this->data->compositeEntities) || ! count($this->data->compositeEntities)) { + if (! isset($this->data->compositeEntities) || ! count($this->data->compositeEntities)) { return []; } @@ -102,5 +102,4 @@ class InvoiceIntent extends BaseIntent return $invoiceItems; } - } diff --git a/app/Ninja/Intents/ListProductsIntent.php b/app/Ninja/Intents/ListProductsIntent.php index fc8c17490b..a8a5d302b0 100644 --- a/app/Ninja/Intents/ListProductsIntent.php +++ b/app/Ninja/Intents/ListProductsIntent.php @@ -4,7 +4,6 @@ use Auth; use Exception; use App\Models\Product; - class ListProductsIntent extends ProductIntent { public function process() @@ -14,7 +13,7 @@ class ListProductsIntent extends ProductIntent ->orderBy('product_key') ->limit(5) ->get() - ->transform(function($item, $key) use ($account) { + ->transform(function ($item, $key) use ($account) { $card = $item->present()->skypeBot($account); if ($this->stateEntity(ENTITY_INVOICE)) { $card->addButton('imBack', trans('texts.add_to_invoice', ['invoice' => '']), trans('texts.add_product_to_invoice', ['product' => $item->product_key])); diff --git a/app/Ninja/Intents/ProductIntent.php b/app/Ninja/Intents/ProductIntent.php index bf8b72405b..15ebc67298 100644 --- a/app/Ninja/Intents/ProductIntent.php +++ b/app/Ninja/Intents/ProductIntent.php @@ -3,7 +3,6 @@ use Auth; use Exception; - class ProductIntent extends BaseIntent { public function __construct($state, $data) diff --git a/app/Ninja/Intents/UpdateInvoiceIntent.php b/app/Ninja/Intents/UpdateInvoiceIntent.php index bcba89456d..4f4dd3bf79 100644 --- a/app/Ninja/Intents/UpdateInvoiceIntent.php +++ b/app/Ninja/Intents/UpdateInvoiceIntent.php @@ -38,7 +38,7 @@ class UpdateInvoiceIntent extends InvoiceIntent $invoice = $this->invoiceRepo->save($data, $invoice); $invoiceItems = array_slice($invoice->invoice_items->toArray(), count($invoiceItems) * -1); - $invoiceItemIds = array_map(function($item) { + $invoiceItemIds = array_map(function ($item) { return $item['public_id']; }, $invoiceItems); diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 6c18e366f5..c92e87ed56 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -91,7 +91,7 @@ class ContactMailer extends Mailer if ($account->document_email_attachment && $invoice->hasDocuments()) { $documents = $invoice->documents; - foreach($invoice->expenses as $expense){ + foreach ($invoice->expenses as $expense) { $documents = $documents->merge($expense->documents); } @@ -99,9 +99,11 @@ class ContactMailer extends Mailer $size = 0; $maxSize = MAX_EMAIL_DOCUMENTS_SIZE * 1000; - foreach($documents as $document){ + foreach ($documents as $document) { $size += $document->size; - if($size > $maxSize)break; + if ($size > $maxSize) { + break; + } $documentStrings[] = [ 'name' => $document->name, @@ -148,9 +150,7 @@ class ContactMailer extends Mailer $pdfString, $documentStrings, $reminder - ) - { - + ) { $client = $invoice->client; $account = $invoice->account; @@ -238,14 +238,14 @@ class ContactMailer extends Mailer ]; $all = ''; $password = ''; - foreach($sets as $set) - { + foreach ($sets as $set) { $password .= $set[array_rand(str_split($set))]; $all .= $set; } $all = str_split($all); - for($i = 0; $i < $length - count($sets); $i++) + for ($i = 0; $i < $length - count($sets); $i++) { $password .= $all[array_rand($all)]; + } $password = str_shuffle($password); return $password; @@ -340,5 +340,4 @@ class ContactMailer extends Mailer $this->sendTo($email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data); } - } diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index 954afc5d6d..7750baff5e 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -37,7 +37,6 @@ class Mailer try { $response = Mail::send($views, $data, function ($message) use ($toEmail, $fromEmail, $fromName, $subject, $data) { - $toEmail = strtolower($toEmail); $replyEmail = $fromEmail; $fromEmail = CONTACT_EMAIL; @@ -64,8 +63,8 @@ class Mailer } // Attach documents to the email - if (!empty($data['documents'])){ - foreach($data['documents'] as $document){ + if (!empty($data['documents'])) { + foreach ($data['documents'] as $document) { $message->attachData($document['data'], $document['name']); } } @@ -130,7 +129,7 @@ class Mailer $invitation = $data['invitation']; $invitation->email_error = $emailError; $invitation->save(); - } elseif ( ! Utils::isNinjaProd()) { + } elseif (! Utils::isNinjaProd()) { Utils::logError(Utils::getErrorString($exception)); } diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php index 95295813ef..c463cd7811 100644 --- a/app/Ninja/Mailers/UserMailer.php +++ b/app/Ninja/Mailers/UserMailer.php @@ -1,6 +1,5 @@ email || $user->cannot('view', $invoice)) { return; } diff --git a/app/Ninja/Notifications/PushFactory.php b/app/Ninja/Notifications/PushFactory.php index 6e69ac80bb..eaaec846dd 100644 --- a/app/Ninja/Notifications/PushFactory.php +++ b/app/Ninja/Notifications/PushFactory.php @@ -58,11 +58,9 @@ class PushFactory PushNotification::app($device) ->to($token) ->send($message); - } - catch(\Exception $e) { + } catch (\Exception $e) { Log::error($e->getMessage()); } - } /** @@ -81,7 +79,6 @@ class PushFactory */ public function getFeedback($token, $message = '', $device) { - $feedback = PushNotification::app($device) ->to($token) ->send($message); diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php index a2436e0b2c..af531ac5a9 100644 --- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php @@ -123,7 +123,7 @@ class BasePaymentDriver $gateway = $this->accountGateway->gateway; - if ( ! $this->meetsGatewayTypeLimits($this->gatewayType)) { + if (! $this->meetsGatewayTypeLimits($this->gatewayType)) { // The customer must have hacked the URL Session::flash('error', trans('texts.limits_not_met')); return redirect()->to('view/' . $this->invitation->invitation_key); @@ -201,14 +201,13 @@ class BasePaymentDriver $rules = []; if ($this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) { - $rules = array_merge($rules, [ 'first_name' => 'required', 'last_name' => 'required', ]); // TODO check this is always true - if ( ! $this->tokenize()) { + if (! $this->tokenize()) { $rules = array_merge($rules, [ 'card_number' => 'required', 'expiration_month' => 'required', @@ -254,13 +253,13 @@ class BasePaymentDriver // load or create token if ($this->isGatewayType(GATEWAY_TYPE_TOKEN)) { - if ( ! $paymentMethod) { + if (! $paymentMethod) { $paymentMethod = PaymentMethod::clientId($this->client()->id) ->wherePublicId($this->sourceId) ->firstOrFail(); } - if ( ! $this->meetsGatewayTypeLimits($paymentMethod->payment_type->gateway_type_id)) { + if (! $this->meetsGatewayTypeLimits($paymentMethod->payment_type->gateway_type_id)) { // The customer must have hacked the URL Session::flash('error', trans('texts.limits_not_met')); return redirect()->to('view/' . $this->invitation->invitation_key); @@ -270,7 +269,7 @@ class BasePaymentDriver $paymentMethod = $this->createToken(); } - if ( ! $this->meetsGatewayTypeLimits($this->gatewayType)) { + if (! $this->meetsGatewayTypeLimits($this->gatewayType)) { // The customer must have hacked the URL Session::flash('error', trans('texts.limits_not_met')); return redirect()->to('view/' . $this->invitation->invitation_key); @@ -318,17 +317,17 @@ class BasePaymentDriver private function updateClient() { - if ( ! $this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) { + if (! $this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD)) { return; } // update the contact info - if ( ! $this->contact()->getFullName()) { + if (! $this->contact()->getFullName()) { $this->contact()->first_name = $this->input['first_name']; $this->contact()->last_name = $this->input['last_name']; } - if ( ! $this->contact()->email) { + if (! $this->contact()->email) { $this->contact()->email = $this->input['email']; } @@ -336,7 +335,7 @@ class BasePaymentDriver $this->contact()->save(); } - if ( ! $this->accountGateway->show_address || ! $this->accountGateway->update_address) { + if (! $this->accountGateway->show_address || ! $this->accountGateway->update_address) { return; } @@ -459,7 +458,7 @@ class BasePaymentDriver return true; } - if ( ! $this->handles(GATEWAY_TYPE_TOKEN)) { + if (! $this->handles(GATEWAY_TYPE_TOKEN)) { return false; } @@ -489,7 +488,7 @@ class BasePaymentDriver return $this->customer; } - if ( ! $clientId) { + if (! $clientId) { $clientId = $this->client()->id; } @@ -529,7 +528,7 @@ class BasePaymentDriver { $account = $this->account(); - if ( ! $customer = $this->customer()) { + if (! $customer = $this->customer()) { $customer = new AccountGatewayToken(); $customer->account_id = $account->id; $customer->contact_id = $this->invitation->contact_id; @@ -586,7 +585,6 @@ class BasePaymentDriver public function deleteToken() { - } public function createPayment($ref = false, $paymentMethod = null) @@ -650,7 +648,7 @@ class BasePaymentDriver $account = Account::with('users')->find($invoice->client->public_id); $company = $account->company; - if( + if ( $company->plan != $plan || DateTime::createFromFormat('Y-m-d', $account->company->plan_expires) <= date_create('-7 days') ) { @@ -735,7 +733,7 @@ class BasePaymentDriver $amount = $payment->getCompletedAmount(); } - if ( ! $amount) { + if (! $amount) { return false; } @@ -784,20 +782,19 @@ class BasePaymentDriver $ref = array_get($this->input, 'token') ?: $this->invitation->transaction_reference; if (method_exists($this->gateway(), 'completePurchase')) { - $details = $this->paymentDetails(); $response = $this->gateway()->completePurchase($details)->send(); $ref = $response->getTransactionReference() ?: $ref; if ($response->isCancelled()) { return false; - } elseif ( ! $response->isSuccessful()) { + } elseif (! $response->isSuccessful()) { throw new Exception($response->getMessage()); } } // check invoice still has balance - if ( ! floatval($this->invoice()->balance)) { + if (! floatval($this->invoice()->balance)) { throw new Exception(trans('texts.payment_error_code', ['code' => 'NB'])); } @@ -813,7 +810,7 @@ class BasePaymentDriver public function tokenLinks() { - if ( ! $this->customer()) { + if (! $this->customer()) { return []; } @@ -825,7 +822,7 @@ class BasePaymentDriver continue; } - if ( ! $this->meetsGatewayTypeLimits($paymentMethod->payment_type->gateway_type_id)) { + if (! $this->meetsGatewayTypeLimits($paymentMethod->payment_type->gateway_type_id)) { continue; } @@ -861,7 +858,7 @@ class BasePaymentDriver continue; } - if ( ! $this->meetsGatewayTypeLimits($gatewayTypeId)) { + if (! $this->meetsGatewayTypeLimits($gatewayTypeId)) { continue; } @@ -887,7 +884,7 @@ class BasePaymentDriver protected function meetsGatewayTypeLimits($gatewayTypeId) { - if ( !$gatewayTypeId ) { + if (!$gatewayTypeId) { return true; } @@ -928,7 +925,8 @@ class BasePaymentDriver return $url; } - protected function parseCardType($cardName) { + protected function parseCardType($cardName) + { $cardTypes = [ 'visa' => PAYMENT_TYPE_VISA, 'americanexpress' => PAYMENT_TYPE_AMERICAN_EXPRESS, diff --git a/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php b/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php index df1821acdb..1b0a2397d9 100644 --- a/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BitPayPaymentDriver.php @@ -8,5 +8,4 @@ class BitPayPaymentDriver extends BasePaymentDriver GATEWAY_TYPE_BITCOIN ]; } - } diff --git a/app/Ninja/PaymentDrivers/BraintreePaymentDriver.php b/app/Ninja/PaymentDrivers/BraintreePaymentDriver.php index 88da5d324d..1cc425c61c 100644 --- a/app/Ninja/PaymentDrivers/BraintreePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/BraintreePaymentDriver.php @@ -49,7 +49,7 @@ class BraintreePaymentDriver extends BasePaymentDriver protected function checkCustomerExists($customer) { - if ( ! parent::checkCustomerExists($customer)) { + if (! parent::checkCustomerExists($customer)) { return false; } @@ -74,7 +74,7 @@ class BraintreePaymentDriver extends BasePaymentDriver $data['ButtonSource'] = 'InvoiceNinja_SP'; } - if ( ! $paymentMethod && ! empty($this->input['sourceToken'])) { + if (! $paymentMethod && ! empty($this->input['sourceToken'])) { $data['token'] = $this->input['sourceToken']; } @@ -169,7 +169,7 @@ class BraintreePaymentDriver extends BasePaymentDriver protected function attemptVoidPayment($response, $payment, $amount) { - if ( ! parent::attemptVoidPayment($response, $payment, $amount)) { + if (! parent::attemptVoidPayment($response, $payment, $amount)) { return false; } diff --git a/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php b/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php index ede0b67823..1d8ee7a21d 100644 --- a/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/CheckoutComPaymentDriver.php @@ -31,5 +31,4 @@ class CheckoutComPaymentDriver extends BasePaymentDriver return $data; } - } diff --git a/app/Ninja/PaymentDrivers/CustomPaymentDriver.php b/app/Ninja/PaymentDrivers/CustomPaymentDriver.php index 1dcbc7095b..dbe8e6a9ce 100644 --- a/app/Ninja/PaymentDrivers/CustomPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/CustomPaymentDriver.php @@ -8,5 +8,4 @@ class CustomPaymentDriver extends BasePaymentDriver GATEWAY_TYPE_CUSTOM ]; } - } diff --git a/app/Ninja/PaymentDrivers/MolliePaymentDriver.php b/app/Ninja/PaymentDrivers/MolliePaymentDriver.php index 51510fdb07..e110423d45 100644 --- a/app/Ninja/PaymentDrivers/MolliePaymentDriver.php +++ b/app/Ninja/PaymentDrivers/MolliePaymentDriver.php @@ -14,11 +14,10 @@ class MolliePaymentDriver extends BasePaymentDriver if ($response->isCancelled()) { return false; - } elseif ( ! $response->isSuccessful()) { + } elseif (! $response->isSuccessful()) { throw new Exception($response->getMessage()); } return $this->createPayment($response->getTransactionReference()); } - } diff --git a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php index 74f98635e2..8143ad9bf3 100644 --- a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -1,6 +1,5 @@ fetchCustomer(['customerReference' => $customer->token]) ->send(); - if ( ! $response->isSuccessful()) { + if (! $response->isSuccessful()) { return false; } $this->tokenResponse = $response->getData(); // import Stripe tokens created before payment methods table was added - if ( ! count($customer->payment_methods)) { + if (! count($customer->payment_methods)) { if ($paymentMethod = $this->createPaymentMethod($customer)) { $customer->default_payment_method_id = $paymentMethod->id; $customer->save(); @@ -94,12 +94,12 @@ class StripePaymentDriver extends BasePaymentDriver // Stripe complains if the email field is set unset($data['email']); - if ( ! empty($this->input['sourceToken'])) { + if (! empty($this->input['sourceToken'])) { $data['token'] = $this->input['sourceToken']; unset($data['card']); } - if ( ! empty($this->input['plaidPublicToken'])) { + if (! empty($this->input['plaidPublicToken'])) { $data['plaidPublicToken'] = $this->input['plaidPublicToken']; $data['plaidAccountId'] = $this->input['plaidAccountId']; unset($data['card']); @@ -116,7 +116,7 @@ class StripePaymentDriver extends BasePaymentDriver $data = $this->paymentDetails(); $data['description'] = $client->getDisplayName(); - if ( ! empty($data['plaidPublicToken'])) { + if (! empty($data['plaidPublicToken'])) { $plaidResult = $this->getPlaidToken($data['plaidPublicToken'], $data['plaidAccountId']); unset($data['plaidPublicToken']); unset($data['plaidAccountId']); @@ -164,7 +164,7 @@ class StripePaymentDriver extends BasePaymentDriver $source = $data['card']; } - if ( ! $source) { + if (! $source) { return false; } @@ -174,12 +174,9 @@ class StripePaymentDriver extends BasePaymentDriver // For older users the Stripe account may just have the customer token but not the card version // In that case we'd use GATEWAY_TYPE_TOKEN even though we're creating the credit card if ($this->isGatewayType(GATEWAY_TYPE_CREDIT_CARD) || $this->isGatewayType(GATEWAY_TYPE_TOKEN)) { - $paymentMethod->expiration = $source['exp_year'] . '-' . $source['exp_month'] . '-01'; $paymentMethod->payment_type_id = $this->parseCardType($source['brand']); - } elseif ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) { - $paymentMethod->routing_number = $source['routing_number']; $paymentMethod->payment_type_id = PAYMENT_TYPE_ACH; $paymentMethod->status = $source['status']; @@ -189,7 +186,6 @@ class StripePaymentDriver extends BasePaymentDriver $paymentMethod->currency_id = $currency->id; $paymentMethod->setRelation('currency', $currency); } - } return $paymentMethod; @@ -208,7 +204,7 @@ class StripePaymentDriver extends BasePaymentDriver { parent::removePaymentMethod($paymentMethod); - if ( ! $paymentMethod->relationLoaded('account_gateway_token')) { + if (! $paymentMethod->relationLoaded('account_gateway_token')) { $paymentMethod->load('account_gateway_token'); } @@ -288,7 +284,7 @@ class StripePaymentDriver extends BasePaymentDriver $paymentMethod->status = PAYMENT_METHOD_STATUS_VERIFIED; $paymentMethod->save(); - if ( ! $customer->default_payment_method_id) { + if (! $customer->default_payment_method_id) { $customer->default_payment_method_id = $paymentMethod->id; $customer->save(); } @@ -304,7 +300,7 @@ class StripePaymentDriver extends BasePaymentDriver return 'No API key set'; } - try{ + try { $options = [ 'headers' => ['content-type' => 'application/x-www-form-urlencoded'], 'auth' => [$apiKey, ''], @@ -398,7 +394,7 @@ class StripePaymentDriver extends BasePaymentDriver } elseif ($eventType == 'charge.refunded') { $payment->recordRefund($charge['amount_refunded'] / 100 - $payment->refunded); } - } elseif($eventType == 'customer.source.updated' || $eventType == 'customer.source.deleted' || $eventType == 'customer.bank_account.deleted') { + } elseif ($eventType == 'customer.source.updated' || $eventType == 'customer.source.deleted' || $eventType == 'customer.bank_account.deleted') { $source = $eventDetails['data']['object']; $sourceRef = $source['id']; diff --git a/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php b/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php index 005611d4a0..cbbf062bbf 100644 --- a/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/TwoCheckoutPaymentDriver.php @@ -9,5 +9,4 @@ class TwoCheckoutPaymentDriver extends BasePaymentDriver { return $this->createPayment($input['order_number']); } - } diff --git a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php index 755c039762..8030ccab36 100644 --- a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php @@ -132,7 +132,7 @@ class WePayPaymentDriver extends BasePaymentDriver $paymentMethod->bank_name = $source->bank_name; $paymentMethod->source_reference = $source->payment_bank_id; - switch($source->state) { + switch ($source->state) { case 'new': case 'pending': $paymentMethod->status = 'new'; @@ -187,7 +187,7 @@ class WePayPaymentDriver extends BasePaymentDriver protected function attemptVoidPayment($response, $payment, $amount) { - if ( ! parent::attemptVoidPayment($response, $payment, $amount)) { + if (! parent::attemptVoidPayment($response, $payment, $amount)) { return false; } @@ -283,5 +283,4 @@ class WePayPaymentDriver extends BasePaymentDriver return 'Ignoring event'; } } - } diff --git a/app/Ninja/Presenters/ClientPresenter.php b/app/Ninja/Presenters/ClientPresenter.php index f4c8adeb05..06c12fa54d 100644 --- a/app/Ninja/Presenters/ClientPresenter.php +++ b/app/Ninja/Presenters/ClientPresenter.php @@ -1,8 +1,7 @@ entity->country ? $this->entity->country->name : ''; diff --git a/app/Ninja/Presenters/CompanyPresenter.php b/app/Ninja/Presenters/CompanyPresenter.php index 46ba7ab9f5..b6eea9a5d0 100644 --- a/app/Ninja/Presenters/CompanyPresenter.php +++ b/app/Ninja/Presenters/CompanyPresenter.php @@ -4,7 +4,7 @@ class CompanyPresenter extends EntityPresenter { public function promoMessage() { - if ( ! $this->entity->hasActivePromo()) { + if (! $this->entity->hasActivePromo()) { return ''; } @@ -16,7 +16,7 @@ class CompanyPresenter extends EntityPresenter public function discountMessage() { - if ( ! $this->entity->hasActiveDiscount()) { + if (! $this->entity->hasActiveDiscount()) { return ''; } @@ -25,5 +25,4 @@ class CompanyPresenter extends EntityPresenter 'amount' => (int)($this->discount * 100) . '%' ]); } - } diff --git a/app/Ninja/Presenters/ExpensePresenter.php b/app/Ninja/Presenters/ExpensePresenter.php index d014374a72..91960da41c 100644 --- a/app/Ninja/Presenters/ExpensePresenter.php +++ b/app/Ninja/Presenters/ExpensePresenter.php @@ -39,5 +39,4 @@ class ExpensePresenter extends EntityPresenter { return $this->entity->expense_category ? $this->entity->expense_category->name : ''; } - } diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php index 8eee2c48f5..726a5e8c9a 100644 --- a/app/Ninja/Presenters/InvoicePresenter.php +++ b/app/Ninja/Presenters/InvoicePresenter.php @@ -6,8 +6,8 @@ use Utils; use DropdownButton; use App\Libraries\Skype\InvoiceCard; -class InvoicePresenter extends EntityPresenter { - +class InvoicePresenter extends EntityPresenter +{ public function client() { return $this->entity->client ? $this->entity->client->getDisplayName() : ''; @@ -47,7 +47,7 @@ class InvoicePresenter extends EntityPresenter { public function age() { - if ( ! $this->entity->due_date || $this->entity->date_date == '0000-00-00') { + if (! $this->entity->due_date || $this->entity->date_date == '0000-00-00') { return 0; } @@ -100,7 +100,7 @@ class InvoicePresenter extends EntityPresenter { // https://schema.org/PaymentStatusType public function paymentStatus() { - if ( ! $this->entity->balance) { + if (! $this->entity->balance) { return 'PaymentComplete'; } elseif ($this->entity->isOverdue()) { return 'PaymentPastDue'; @@ -152,7 +152,7 @@ class InvoicePresenter extends EntityPresenter { $client = $this->entity->client; $paymentMethod = $client->defaultPaymentMethod(); - if ( ! $paymentMethod) { + if (! $paymentMethod) { return false; } diff --git a/app/Ninja/Presenters/PaymentPresenter.php b/app/Ninja/Presenters/PaymentPresenter.php index 6997eae3ce..617358ba66 100644 --- a/app/Ninja/Presenters/PaymentPresenter.php +++ b/app/Ninja/Presenters/PaymentPresenter.php @@ -3,8 +3,8 @@ use Carbon; use Utils; -class PaymentPresenter extends EntityPresenter { - +class PaymentPresenter extends EntityPresenter +{ public function amount() { return Utils::formatMoney($this->entity->amount, $this->entity->client->currency_id); diff --git a/app/Ninja/Presenters/ProductPresenter.php b/app/Ninja/Presenters/ProductPresenter.php index 786e61cba7..8c68558633 100644 --- a/app/Ninja/Presenters/ProductPresenter.php +++ b/app/Ninja/Presenters/ProductPresenter.php @@ -20,5 +20,4 @@ class ProductPresenter extends EntityPresenter return $card; } - } diff --git a/app/Ninja/Reports/AbstractReport.php b/app/Ninja/Reports/AbstractReport.php index 6af6a9d54c..5f7d5d4723 100644 --- a/app/Ninja/Reports/AbstractReport.php +++ b/app/Ninja/Reports/AbstractReport.php @@ -25,7 +25,6 @@ class AbstractReport public function run() { - } public function results() @@ -41,11 +40,11 @@ class AbstractReport { $currencyId = $currencyId ?: Auth::user()->account->getCurrencyId(); - if ( ! isset($this->totals[$currencyId][$dimension])) { + if (! isset($this->totals[$currencyId][$dimension])) { $this->totals[$currencyId][$dimension] = []; } - if ( ! isset($this->totals[$currencyId][$dimension][$field])) { + if (! isset($this->totals[$currencyId][$dimension][$field])) { $this->totals[$currencyId][$dimension][$field] = 0; } diff --git a/app/Ninja/Reports/AgingReport.php b/app/Ninja/Reports/AgingReport.php index aaf87c47d0..8895504389 100644 --- a/app/Ninja/Reports/AgingReport.php +++ b/app/Ninja/Reports/AgingReport.php @@ -24,7 +24,7 @@ class AgingReport extends AbstractReport $clients = Client::scope() ->withArchived() ->with('contacts') - ->with(['invoices' => function($query) { + ->with(['invoices' => function ($query) { $query->invoices() ->whereIsPublic(true) ->withArchived() @@ -36,7 +36,6 @@ class AgingReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { - $this->data[] = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, $this->isExport ? $invoice->invoice_number : $invoice->present()->link, diff --git a/app/Ninja/Reports/ClientReport.php b/app/Ninja/Reports/ClientReport.php index a511def125..a7ffac2db0 100644 --- a/app/Ninja/Reports/ClientReport.php +++ b/app/Ninja/Reports/ClientReport.php @@ -21,7 +21,7 @@ class ClientReport extends AbstractReport $clients = Client::scope() ->withArchived() ->with('contacts') - ->with(['invoices' => function($query) { + ->with(['invoices' => function ($query) { $query->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) ->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD) diff --git a/app/Ninja/Reports/InvoiceDetailsReport.php b/app/Ninja/Reports/InvoiceDetailsReport.php index 4a100a16ca..a279145b85 100644 --- a/app/Ninja/Reports/InvoiceDetailsReport.php +++ b/app/Ninja/Reports/InvoiceDetailsReport.php @@ -26,7 +26,7 @@ class InvoiceDetailsReport extends AbstractReport $clients = Client::scope() ->withArchived() ->with('contacts') - ->with(['invoices' => function($query) use ($status) { + ->with(['invoices' => function ($query) use ($status) { if ($status == 'draft') { $query->whereIsPublic(false); } elseif ($status == 'unpaid' || $status == 'paid') { diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index b9c1c1f028..140db87ee4 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -25,7 +25,7 @@ class InvoiceReport extends AbstractReport $clients = Client::scope() ->withArchived() ->with('contacts') - ->with(['invoices' => function($query) use ($status) { + ->with(['invoices' => function ($query) use ($status) { if ($status == 'draft') { $query->whereIsPublic(false); } elseif ($status == 'unpaid' || $status == 'paid') { @@ -35,8 +35,8 @@ class InvoiceReport extends AbstractReport ->withArchived() ->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) - ->with(['payments' => function($query) { - $query->withArchived() + ->with(['payments' => function ($query) { + $query->withArchived() ->excludeFailed() ->with('payment_type', 'account_gateway.gateway'); }, 'invoice_items']); @@ -44,10 +44,9 @@ class InvoiceReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { - $payments = count($invoice->payments) ? $invoice->payments : [false]; foreach ($payments as $payment) { - if ( ! $payment && $status == 'paid') { + if (! $payment && $status == 'paid') { continue; } elseif ($payment && $status == 'unpaid') { continue; diff --git a/app/Ninja/Reports/PaymentReport.php b/app/Ninja/Reports/PaymentReport.php index 7521af2e3e..4f40e4265e 100644 --- a/app/Ninja/Reports/PaymentReport.php +++ b/app/Ninja/Reports/PaymentReport.php @@ -24,10 +24,10 @@ class PaymentReport extends AbstractReport $payments = Payment::scope() ->withArchived() ->excludeFailed() - ->whereHas('client', function($query) { + ->whereHas('client', function ($query) { $query->where('is_deleted', '=', false); }) - ->whereHas('invoice', function($query) { + ->whereHas('invoice', function ($query) { $query->where('is_deleted', '=', false); }) ->with('client.contacts', 'invoice', 'payment_type', 'account_gateway.gateway') diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index c611f9a201..48fc62033c 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -23,7 +23,7 @@ class ProductReport extends AbstractReport ->withTrashed() ->with('contacts') ->where('is_deleted', '=', false) - ->with(['invoices' => function($query) { + ->with(['invoices' => function ($query) { $query->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) ->where('is_deleted', '=', false) @@ -35,7 +35,6 @@ class ProductReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { - foreach ($invoice->invoice_items as $invoiceItem) { $this->data[] = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, diff --git a/app/Ninja/Reports/TaxRateReport.php b/app/Ninja/Reports/TaxRateReport.php index 800914c841..787c37f465 100644 --- a/app/Ninja/Reports/TaxRateReport.php +++ b/app/Ninja/Reports/TaxRateReport.php @@ -21,19 +21,19 @@ class TaxRateReport extends AbstractReport $clients = Client::scope() ->withArchived() ->with('contacts') - ->with(['invoices' => function($query) { + ->with(['invoices' => function ($query) { $query->with('invoice_items')->withArchived(); if ($this->options['date_field'] == FILTER_INVOICE_DATE) { $query->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) ->with('payments'); } else { - $query->whereHas('payments', function($query) { - $query->where('payment_date', '>=', $this->startDate) + $query->whereHas('payments', function ($query) { + $query->where('payment_date', '>=', $this->startDate) ->where('payment_date', '<=', $this->endDate) ->withArchived(); - }) - ->with(['payments' => function($query) { + }) + ->with(['payments' => function ($query) { $query->where('payment_date', '>=', $this->startDate) ->where('payment_date', '<=', $this->endDate) ->withArchived(); @@ -49,7 +49,7 @@ class TaxRateReport extends AbstractReport foreach ($client->invoices as $invoice) { foreach ($invoice->getTaxes(true) as $key => $tax) { - if ( ! isset($taxTotals[$currencyId])) { + if (! isset($taxTotals[$currencyId])) { $taxTotals[$currencyId] = []; } if (isset($taxTotals[$currencyId][$key])) { diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index d9d77380ef..dc642d8ee5 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -116,7 +116,7 @@ class AccountRepository } else { $clients = Client::scope() ->where('user_id', '=', $user->id) - ->with(['contacts', 'invoices' => function($query) use ($user) { + ->with(['contacts', 'invoices' => function ($query) use ($user) { $query->where('user_id', '=', $user->id); }])->get(); } @@ -208,7 +208,7 @@ class AccountRepository $settings = array_merge(Account::$basicSettings, Account::$advancedSettings); - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { $settings[] = ACCOUNT_SYSTEM_SETTINGS; } @@ -589,13 +589,14 @@ class AccountRepository return $data; } - public function loadAccounts($userId) { + public function loadAccounts($userId) + { $record = self::findUserAccounts($userId); return self::prepareUsersData($record); } - public function associateAccounts($userId1, $userId2) { - + public function associateAccounts($userId1, $userId2) + { $record = self::findUserAccounts($userId1, $userId2); if ($record) { @@ -618,7 +619,7 @@ class AccountRepository foreach ($users as $user) { if (!$user->public_id) { $useAsPrimary = false; - if(empty($primaryUser)) { + if (empty($primaryUser)) { $useAsPrimary = true; } @@ -639,7 +640,7 @@ class AccountRepository } } - if ($useAsPrimary) { + if ($useAsPrimary) { $primaryUser = $user; $primaryUserPlanLevel = $planLevel; if ($planDetails) { @@ -669,7 +670,8 @@ class AccountRepository return $users; } - public function unlinkAccount($account) { + public function unlinkAccount($account) + { foreach ($account->users as $user) { if ($userAccount = self::findUserAccounts($user->id)) { $userAccount->removeUserId($user->id); @@ -678,7 +680,8 @@ class AccountRepository } } - public function unlinkUser($userAccountId, $userId) { + public function unlinkUser($userAccountId, $userId) + { $userAccount = UserAccount::whereId($userAccountId)->first(); if ($userAccount->hasUserId($userId)) { $userAccount->removeUserId($userId); diff --git a/app/Ninja/Repositories/ActivityRepository.php b/app/Ninja/Repositories/ActivityRepository.php index 6a1b1a1740..10d1465a86 100644 --- a/app/Ninja/Repositories/ActivityRepository.php +++ b/app/Ninja/Repositories/ActivityRepository.php @@ -110,5 +110,4 @@ class ActivityRepository 'expenses.public_id as expense_public_id' ); } - } diff --git a/app/Ninja/Repositories/BankAccountRepository.php b/app/Ninja/Repositories/BankAccountRepository.php index 3a4186d299..dd8f2d61b0 100644 --- a/app/Ninja/Repositories/BankAccountRepository.php +++ b/app/Ninja/Repositories/BankAccountRepository.php @@ -36,7 +36,7 @@ class BankAccountRepository extends BaseRepository $account->bank_accounts()->save($bankAccount); foreach ($input['bank_accounts'] as $data) { - if ( ! isset($data['include']) || ! filter_var($data['include'], FILTER_VALIDATE_BOOLEAN)) { + if (! isset($data['include']) || ! filter_var($data['include'], FILTER_VALIDATE_BOOLEAN)) { continue; } diff --git a/app/Ninja/Repositories/BaseRepository.php b/app/Ninja/Repositories/BaseRepository.php index 71d8c1b9fb..59ada09281 100644 --- a/app/Ninja/Repositories/BaseRepository.php +++ b/app/Ninja/Repositories/BaseRepository.php @@ -58,7 +58,7 @@ class BaseRepository */ public function restore($entity) { - if ( ! $entity->trashed()) { + if (! $entity->trashed()) { return; } @@ -106,7 +106,7 @@ class BaseRepository */ public function bulk($ids, $action) { - if ( ! $ids ) { + if (! $ids) { return 0; } @@ -155,7 +155,7 @@ class BaseRepository $query->orWhere(function ($query) use ($table) { $query->whereNotNull($table . '.deleted_at'); - if ( ! in_array($table, ['users'])) { + if (! in_array($table, ['users'])) { $query->where($table . '.is_deleted', '=', 0); } }); diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 5156298e45..f5c893d601 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -75,7 +75,7 @@ class ClientRepository extends BaseRepository $publicId = isset($data['public_id']) ? $data['public_id'] : false; if ($client) { - // do nothing + // do nothing } elseif (!$publicId || $publicId == '-1') { $client = Client::createNew(); if (Auth::check() && Auth::user()->account->client_number_counter && empty($data['id_number'])) { @@ -92,7 +92,7 @@ class ClientRepository extends BaseRepository // convert currency code to id if (isset($data['currency_code'])) { $currencyCode = strtolower($data['currency_code']); - $currency = Cache::get('currencies')->filter(function($item) use ($currencyCode) { + $currency = Cache::get('currencies')->filter(function ($item) use ($currencyCode) { return strtolower($item->code) == $currencyCode; })->first(); if ($currency) { @@ -128,7 +128,7 @@ class ClientRepository extends BaseRepository $first = false; } - if ( ! $client->wasRecentlyCreated) { + if (! $client->wasRecentlyCreated) { foreach ($client->contacts as $contact) { if (!in_array($contact->public_id, $contactIds)) { $contact->delete(); @@ -158,7 +158,7 @@ class ClientRepository extends BaseRepository foreach ($clients as $client) { $map[$client->id] = $client; - if ( ! $client->name) { + if (! $client->name) { continue; } @@ -173,7 +173,7 @@ class ClientRepository extends BaseRepository $contacts = Contact::scope()->get(['client_id', 'first_name', 'last_name', 'public_id']); foreach ($contacts as $contact) { - if ( ! $contact->getFullName() || ! isset($map[$contact->client_id])) { + if (! $contact->getFullName() || ! isset($map[$contact->client_id])) { continue; } @@ -187,5 +187,4 @@ class ClientRepository extends BaseRepository return ($clientId && isset($map[$clientId])) ? $map[$clientId] : null; } - } diff --git a/app/Ninja/Repositories/ContactRepository.php b/app/Ninja/Repositories/ContactRepository.php index 6f157c1c40..e3bc389f5d 100644 --- a/app/Ninja/Repositories/ContactRepository.php +++ b/app/Ninja/Repositories/ContactRepository.php @@ -23,4 +23,4 @@ class ContactRepository extends BaseRepository return $contact; } -} \ No newline at end of file +} diff --git a/app/Ninja/Repositories/CreditRepository.php b/app/Ninja/Repositories/CreditRepository.php index f7f4637ca3..48fb30ff3a 100644 --- a/app/Ninja/Repositories/CreditRepository.php +++ b/app/Ninja/Repositories/CreditRepository.php @@ -75,9 +75,15 @@ class CreditRepository extends BaseRepository ); $table = \Datatable::query($query) - ->addColumn('credit_date', function ($model) { return Utils::fromSqlDate($model->credit_date); }) - ->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); }) - ->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); }) + ->addColumn('credit_date', function ($model) { + return Utils::fromSqlDate($model->credit_date); + }) + ->addColumn('amount', function ($model) { + return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); + }) + ->addColumn('balance', function ($model) { + return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); + }) ->make(); return $table; diff --git a/app/Ninja/Repositories/DashboardRepository.php b/app/Ninja/Repositories/DashboardRepository.php index 325ee77c56..209a22edc5 100644 --- a/app/Ninja/Repositories/DashboardRepository.php +++ b/app/Ninja/Repositories/DashboardRepository.php @@ -36,7 +36,6 @@ class DashboardRepository } foreach ($entitTypes as $entityType) { - $data = []; $count = 0; $balance = 0; @@ -108,7 +107,7 @@ class DashboardRepository private function rawChartData($entityType, $account, $groupBy, $startDate, $endDate, $currencyId) { - if ( ! in_array($groupBy, ['DAYOFYEAR', 'WEEK', 'MONTH'])) { + if (! in_array($groupBy, ['DAYOFYEAR', 'WEEK', 'MONTH'])) { return []; } @@ -168,10 +167,10 @@ class DashboardRepository ->where('invoices.is_recurring', '=', false) ->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD); - if (!$viewAll){ - $metrics = $metrics->where(function($query) use($userId){ + if (!$viewAll) { + $metrics = $metrics->where(function ($query) use ($userId) { $query->where('invoices.user_id', '=', $userId); - $query->orwhere(function($query) use($userId){ + $query->orwhere(function ($query) use ($userId) { $query->where('invoices.user_id', '=', null); $query->where('clients.user_id', '=', $userId); }); @@ -198,7 +197,7 @@ class DashboardRepository ->where('payments.is_deleted', '=', false) ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]); - if (!$viewAll){ + if (!$viewAll) { $paidToDate->where('invoices.user_id', '=', $userId); } @@ -231,7 +230,7 @@ class DashboardRepository ->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD) ->where('invoices.is_recurring', '=', false); - if (!$viewAll){ + if (!$viewAll) { $averageInvoice->where('invoices.user_id', '=', $userId); } @@ -271,7 +270,7 @@ class DashboardRepository $activities = Activity::where('activities.account_id', '=', $accountId) ->where('activities.activity_type_id', '>', 0); - if (!$viewAll){ + if (!$viewAll) { $activities = $activities->where('activities.user_id', '=', $userId); } @@ -297,7 +296,7 @@ class DashboardRepository ->where('contacts.is_primary', '=', true) ->where('invoices.due_date', '<', date('Y-m-d')); - if (!$viewAll){ + if (!$viewAll) { $pastDue = $pastDue->where('invoices.user_id', '=', $userId); } @@ -324,7 +323,7 @@ class DashboardRepository ->where('invoices.due_date', '>=', date('Y-m-d')) ->orderBy('invoices.due_date', 'asc'); - if (!$viewAll){ + if (!$viewAll) { $upcoming = $upcoming->where('invoices.user_id', '=', $userId); } @@ -347,7 +346,7 @@ class DashboardRepository ->where('contacts.is_primary', '=', true) ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]); - if (!$viewAll){ + if (!$viewAll) { $payments = $payments->where('payments.user_id', '=', $userId); } @@ -373,7 +372,7 @@ class DashboardRepository ->where('accounts.id', '=', $accountId) ->where('expenses.is_deleted', '=', false); - if (!$viewAll){ + if (!$viewAll) { $paidToDate = $paidToDate->where('expenses.user_id', '=', $userId); } diff --git a/app/Ninja/Repositories/DocumentRepository.php b/app/Ninja/Repositories/DocumentRepository.php index 2a950a7726..97fd0bf203 100644 --- a/app/Ninja/Repositories/DocumentRepository.php +++ b/app/Ninja/Repositories/DocumentRepository.php @@ -54,14 +54,13 @@ class DocumentRepository extends BaseRepository { $uploaded = $data['file']; $extension = strtolower($uploaded->getClientOriginalExtension()); - if(empty(Document::$types[$extension]) && !empty(Document::$extraExtensions[$extension])){ + if (empty(Document::$types[$extension]) && !empty(Document::$extraExtensions[$extension])) { $documentType = Document::$extraExtensions[$extension]; - } - else{ + } else { $documentType = $extension; } - if(empty(Document::$types[$documentType])){ + if (empty(Document::$types[$documentType])) { return 'Unsupported file type'; } @@ -71,7 +70,7 @@ class DocumentRepository extends BaseRepository $name = $uploaded->getClientOriginalName(); $size = filesize($filePath); - if($size/1000 > MAX_DOCUMENT_SIZE){ + if ($size/1000 > MAX_DOCUMENT_SIZE) { return 'File too large'; } @@ -87,28 +86,28 @@ class DocumentRepository extends BaseRepository $document->fill($data); $disk = $document->getDisk(); - if(!$disk->exists($filename)){// Have we already stored the same file + if (!$disk->exists($filename)) {// Have we already stored the same file $stream = fopen($filePath, 'r'); $disk->getDriver()->putStream($filename, $stream, ['mimetype'=>$documentTypeData['mime']]); fclose($stream); } // This is an image; check if we need to create a preview - if(in_array($documentType, ['jpeg','png','gif','bmp','tiff','psd'])){ + if (in_array($documentType, ['jpeg','png','gif','bmp','tiff','psd'])) { $makePreview = false; $imageSize = getimagesize($filePath); $width = $imageSize[0]; $height = $imageSize[1]; $imgManagerConfig = []; - if(in_array($documentType, ['gif','bmp','tiff','psd'])){ + if (in_array($documentType, ['gif','bmp','tiff','psd'])) { // Needs to be converted $makePreview = true; - } else if($width > DOCUMENT_PREVIEW_SIZE || $height > DOCUMENT_PREVIEW_SIZE){ + } elseif ($width > DOCUMENT_PREVIEW_SIZE || $height > DOCUMENT_PREVIEW_SIZE) { $makePreview = true; } - if(in_array($documentType,['bmp','tiff','psd'])){ - if(!class_exists('Imagick')){ + if (in_array($documentType, ['bmp','tiff','psd'])) { + if (!class_exists('Imagick')) { // Cant't read this $makePreview = false; } else { @@ -116,24 +115,24 @@ class DocumentRepository extends BaseRepository } } - if($makePreview){ + if ($makePreview) { $previewType = 'jpeg'; - if(in_array($documentType, ['png','gif','tiff','psd'])){ + if (in_array($documentType, ['png','gif','tiff','psd'])) { // Has transparency $previewType = 'png'; } $document->preview = \Auth::user()->account->account_key.'/'.$hash.'.'.$documentType.'.x'.DOCUMENT_PREVIEW_SIZE.'.'.$previewType; - if(!$disk->exists($document->preview)){ + if (!$disk->exists($document->preview)) { // We haven't created a preview yet $imgManager = new ImageManager($imgManagerConfig); $img = $imgManager->make($filePath); - if($width <= DOCUMENT_PREVIEW_SIZE && $height <= DOCUMENT_PREVIEW_SIZE){ + if ($width <= DOCUMENT_PREVIEW_SIZE && $height <= DOCUMENT_PREVIEW_SIZE) { $previewWidth = $width; $previewHeight = $height; - } else if($width > $height) { + } elseif ($width > $height) { $previewWidth = DOCUMENT_PREVIEW_SIZE; $previewHeight = $height * DOCUMENT_PREVIEW_SIZE / $width; } else { @@ -146,11 +145,10 @@ class DocumentRepository extends BaseRepository $previewContent = (string) $img->encode($previewType); $disk->put($document->preview, $previewContent); $base64 = base64_encode($previewContent); - } - else{ + } else { $base64 = base64_encode($disk->get($document->preview)); } - }else{ + } else { $base64 = base64_encode(file_get_contents($filePath)); } } @@ -161,7 +159,7 @@ class DocumentRepository extends BaseRepository $document->hash = $hash; $document->name = substr($name, -255); - if(!empty($imageSize)){ + if (!empty($imageSize)) { $document->width = $imageSize[0]; $document->height = $imageSize[1]; } @@ -169,7 +167,7 @@ class DocumentRepository extends BaseRepository $document->save(); $doc_array = $document->toArray(); - if(!empty($base64)){ + if (!empty($base64)) { $mime = Document::$types[!empty($previewType)?$previewType:$documentType]['mime']; $doc_array['base64'] = 'data:'.$mime.';base64,'.$base64; } @@ -179,8 +177,7 @@ class DocumentRepository extends BaseRepository public function getClientDatatable($contactId, $entityType, $search) { - - $query = DB::table('invitations') + $query = DB::table('invitations') ->join('accounts', 'accounts.id', '=', 'invitations.account_id') ->join('invoices', 'invoices.id', '=', 'invitations.invoice_id') ->join('documents', 'documents.invoice_id', '=', 'invitations.invoice_id') diff --git a/app/Ninja/Repositories/ExpenseCategoryRepository.php b/app/Ninja/Repositories/ExpenseCategoryRepository.php index a9224b4266..14409a8aef 100644 --- a/app/Ninja/Repositories/ExpenseCategoryRepository.php +++ b/app/Ninja/Repositories/ExpenseCategoryRepository.php @@ -44,7 +44,7 @@ class ExpenseCategoryRepository extends BaseRepository { $publicId = isset($data['public_id']) ? $data['public_id'] : false; - if ( ! $category) { + if (! $category) { $category = ExpenseCategory::createNew(); } diff --git a/app/Ninja/Repositories/ExpenseRepository.php b/app/Ninja/Repositories/ExpenseRepository.php index 85bae1501a..5c8d886a1e 100644 --- a/app/Ninja/Repositories/ExpenseRepository.php +++ b/app/Ninja/Repositories/ExpenseRepository.php @@ -107,7 +107,7 @@ class ExpenseRepository extends BaseRepository } if (in_array(EXPENSE_STATUS_INVOICED, $statuses)) { $query->orWhere('expenses.invoice_id', '>', 0); - if ( ! in_array(EXPENSE_STATUS_PAID, $statuses)) { + if (! in_array(EXPENSE_STATUS_PAID, $statuses)) { $query->where('invoices.balance', '>', 0); } } @@ -123,7 +123,8 @@ class ExpenseRepository extends BaseRepository $query->where('expenses.public_notes', 'like', '%'.$filter.'%') ->orWhere('clients.name', 'like', '%'.$filter.'%') ->orWhere('vendors.name', 'like', '%'.$filter.'%') - ->orWhere('expense_categories.name', 'like', '%'.$filter.'%');; + ->orWhere('expense_categories.name', 'like', '%'.$filter.'%'); + ; }); } @@ -158,10 +159,10 @@ class ExpenseRepository extends BaseRepository $expense->should_be_invoiced = isset($input['should_be_invoiced']) && floatval($input['should_be_invoiced']) || $expense->client_id ? true : false; - if ( ! $expense->expense_currency_id) { + if (! $expense->expense_currency_id) { $expense->expense_currency_id = \Auth::user()->account->getCurrencyId(); } - if ( ! $expense->invoice_currency_id) { + if (! $expense->invoice_currency_id) { $expense->invoice_currency_id = \Auth::user()->account->getCurrencyId(); } @@ -174,12 +175,13 @@ class ExpenseRepository extends BaseRepository $expense->save(); // Documents - $document_ids = !empty($input['document_ids'])?array_map('intval', $input['document_ids']):[];; - foreach ($document_ids as $document_id){ + $document_ids = !empty($input['document_ids'])?array_map('intval', $input['document_ids']):[]; + ; + foreach ($document_ids as $document_id) { // check document completed upload before user submitted form if ($document_id) { $document = Document::scope($document_id)->first(); - if($document && Auth::user()->can('edit', $document)){ + if ($document && Auth::user()->can('edit', $document)) { $document->invoice_id = null; $document->expense_id = $expense->id; $document->save(); @@ -188,9 +190,9 @@ class ExpenseRepository extends BaseRepository } // prevent loading all of the documents if we don't have to - if ( ! $expense->wasRecentlyCreated) { - foreach ($expense->documents as $document){ - if ( ! in_array($document->public_id, $document_ids)){ + if (! $expense->wasRecentlyCreated) { + foreach ($expense->documents as $document) { + if (! in_array($document->public_id, $document_ids)) { // Not checking permissions; deleting a document is just editing the invoice $document->delete(); } diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index 20ab70652d..e22042b91c 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -208,10 +208,18 @@ class InvoiceRepository extends BaseRepository ); $table = \Datatable::query($query) - ->addColumn('frequency', function ($model) { return $model->frequency; }) - ->addColumn('start_date', function ($model) { return Utils::fromSqlDate($model->start_date); }) - ->addColumn('end_date', function ($model) { return Utils::fromSqlDate($model->end_date); }) - ->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); }) + ->addColumn('frequency', function ($model) { + return $model->frequency; + }) + ->addColumn('start_date', function ($model) { + return Utils::fromSqlDate($model->start_date); + }) + ->addColumn('end_date', function ($model) { + return Utils::fromSqlDate($model->end_date); + }) + ->addColumn('amount', function ($model) { + return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); + }) ->addColumn('client_enable_auto_bill', function ($model) { if ($model->client_enable_auto_bill) { return trans('texts.enabled') . ' - '.trans('texts.disable').''; @@ -259,9 +267,15 @@ class InvoiceRepository extends BaseRepository ); $table = \Datatable::query($query) - ->addColumn('invoice_number', function ($model) use ($entityType) { return link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml(); }) - ->addColumn('invoice_date', function ($model) { return Utils::fromSqlDate($model->invoice_date); }) - ->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); }); + ->addColumn('invoice_number', function ($model) use ($entityType) { + return link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml(); + }) + ->addColumn('invoice_date', function ($model) { + return Utils::fromSqlDate($model->invoice_date); + }) + ->addColumn('amount', function ($model) { + return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); + }); if ($entityType == ENTITY_INVOICE) { $table->addColumn('balance', function ($model) { @@ -274,7 +288,9 @@ class InvoiceRepository extends BaseRepository }); } - return $table->addColumn('due_date', function ($model) { return Utils::fromSqlDate($model->due_date); }) + return $table->addColumn('due_date', function ($model) { + return Utils::fromSqlDate($model->due_date); + }) ->make(); } @@ -328,7 +344,7 @@ class InvoiceRepository extends BaseRepository if (isset($data['is_public']) && filter_var($data['is_public'], FILTER_VALIDATE_BOOLEAN)) { $invoice->is_public = true; - if ( ! $invoice->isSent()) { + if (! $invoice->isSent()) { $invoice->invoice_status_id = INVOICE_STATUS_SENT; } } @@ -362,8 +378,8 @@ class InvoiceRepository extends BaseRepository $invoice->invoice_date = Utils::toSqlDate($data['invoice_date']); } - if(isset($data['invoice_status_id'])) { - if($data['invoice_status_id'] == 0) { + if (isset($data['invoice_status_id'])) { + if ($data['invoice_status_id'] == 0) { $data['invoice_status_id'] = INVOICE_STATUS_DRAFT; } $invoice->invoice_status_id = $data['invoice_status_id']; @@ -380,7 +396,7 @@ class InvoiceRepository extends BaseRepository $invoice->client_enable_auto_bill = isset($data['client_enable_auto_bill']) && $data['client_enable_auto_bill'] ? true : false; $invoice->auto_bill = array_get($data, 'auto_bill_id') ?: array_get($data, 'auto_bill', AUTO_BILL_OFF); - if ($invoice->auto_bill < AUTO_BILL_OFF || $invoice->auto_bill > AUTO_BILL_ALWAYS ) { + if ($invoice->auto_bill < AUTO_BILL_OFF || $invoice->auto_bill > AUTO_BILL_ALWAYS) { $invoice->auto_bill = AUTO_BILL_OFF; } @@ -410,7 +426,7 @@ class InvoiceRepository extends BaseRepository $invoice->public_notes = isset($data['public_notes']) ? trim($data['public_notes']) : ''; // process date variables if not recurring - if(!$invoice->is_recurring) { + if (!$invoice->is_recurring) { $invoice->terms = Utils::processVariables($invoice->terms); $invoice->invoice_footer = Utils::processVariables($invoice->invoice_footer); $invoice->public_notes = Utils::processVariables($invoice->public_notes); @@ -525,7 +541,7 @@ class InvoiceRepository extends BaseRepository } if (isset($data['partial'])) { - $invoice->partial = max(0,min(round(Utils::parseFloat($data['partial']), 2), $invoice->balance)); + $invoice->partial = max(0, min(round(Utils::parseFloat($data['partial']), 2), $invoice->balance)); } $invoice->amount = $total; @@ -535,13 +551,12 @@ class InvoiceRepository extends BaseRepository $invoice->invoice_items()->forceDelete(); } - if ( ! empty($data['document_ids'])) { + if (! empty($data['document_ids'])) { $document_ids = array_map('intval', $data['document_ids']); - foreach ($document_ids as $document_id){ + foreach ($document_ids as $document_id) { $document = Document::scope($document_id)->first(); - if($document && Auth::user()->can('edit', $document)){ - - if($document->invoice_id && $document->invoice_id != $invoice->id){ + if ($document && Auth::user()->can('edit', $document)) { + if ($document->invoice_id && $document->invoice_id != $invoice->id) { // From a clone $document = $document->cloneDocument(); $document_ids[] = $document->public_id;// Don't remove this document @@ -553,12 +568,12 @@ class InvoiceRepository extends BaseRepository } } - if ( ! $invoice->wasRecentlyCreated) { - foreach ($invoice->documents as $document){ - if(!in_array($document->public_id, $document_ids)){ + if (! $invoice->wasRecentlyCreated) { + foreach ($invoice->documents as $document) { + if (!in_array($document->public_id, $document_ids)) { // Removed // Not checking permissions; deleting a document is just editing the invoice - if($document->invoice_id == $invoice->id){ + if ($document->invoice_id == $invoice->id) { // Make sure the document isn't on a clone $document->delete(); } @@ -576,7 +591,7 @@ class InvoiceRepository extends BaseRepository $task = false; if (isset($item['task_public_id']) && $item['task_public_id']) { $task = Task::scope($item['task_public_id'])->where('invoice_id', '=', null)->firstOrFail(); - if(Auth::user()->can('edit', $task)){ + if (Auth::user()->can('edit', $task)) { $task->invoice_id = $invoice->id; $task->client_id = $invoice->client_id; $task->save(); @@ -586,7 +601,7 @@ class InvoiceRepository extends BaseRepository $expense = false; if (isset($item['expense_public_id']) && $item['expense_public_id']) { $expense = Expense::scope($item['expense_public_id'])->where('invoice_id', '=', null)->firstOrFail(); - if(Auth::user()->can('edit', $expense)){ + if (Auth::user()->can('edit', $expense)) { $expense->invoice_id = $invoice->id; $expense->client_id = $invoice->client_id; $expense->save(); @@ -600,8 +615,7 @@ class InvoiceRepository extends BaseRepository if (Auth::user()->can('create', ENTITY_PRODUCT)) { $product = Product::createNew(); $product->product_key = trim($item['product_key']); - } - else{ + } else { $product = null; } } @@ -780,7 +794,7 @@ class InvoiceRepository extends BaseRepository */ public function markPaid(Invoice $invoice) { - if ( ! $invoice->canBePaid()) { + if (! $invoice->canBePaid()) { return; } diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php index b6f37de724..8624cc50a6 100644 --- a/app/Ninja/Repositories/PaymentRepository.php +++ b/app/Ninja/Repositories/PaymentRepository.php @@ -193,7 +193,7 @@ class PaymentRepository extends BaseRepository $remaining = $amount; foreach ($credits as $credit) { $remaining -= $credit->apply($remaining); - if ( ! $remaining) { + if (! $remaining) { break; } } diff --git a/app/Ninja/Repositories/ProductRepository.php b/app/Ninja/Repositories/ProductRepository.php index 6500124c51..bdd9c5d4ec 100644 --- a/app/Ninja/Repositories/ProductRepository.php +++ b/app/Ninja/Repositories/ProductRepository.php @@ -20,7 +20,7 @@ class ProductRepository extends BaseRepository public function find($accountId, $filter = null) { $query = DB::table('products') - ->leftJoin('tax_rates', function($join) { + ->leftJoin('tax_rates', function ($join) { $join->on('tax_rates.id', '=', 'products.default_tax_rate_id') ->whereNull('tax_rates.deleted_at'); }) @@ -80,7 +80,7 @@ class ProductRepository extends BaseRepository ->get(); foreach ($products as $product) { - if ( ! $product->product_key) { + if (! $product->product_key) { continue; } @@ -95,6 +95,4 @@ class ProductRepository extends BaseRepository return ($productId && isset($map[$productId])) ? $map[$productId] : null; } - - } diff --git a/app/Ninja/Repositories/ProjectRepository.php b/app/Ninja/Repositories/ProjectRepository.php index 64ba210ba3..838057c7c2 100644 --- a/app/Ninja/Repositories/ProjectRepository.php +++ b/app/Ninja/Repositories/ProjectRepository.php @@ -63,7 +63,7 @@ class ProjectRepository extends BaseRepository { $publicId = isset($data['public_id']) ? $data['public_id'] : false; - if ( ! $project) { + if (! $project) { $project = Project::createNew(); $project['client_id'] = $input['client_id']; } diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index 579ef71e68..4dc19f1a28 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -74,7 +74,7 @@ class TaskRepository extends BaseRepository } if (in_array(TASK_STATUS_INVOICED, $statuses)) { $query->orWhere('tasks.invoice_id', '>', 0); - if ( ! in_array(TASK_STATUS_PAID, $statuses)) { + if (! in_array(TASK_STATUS_PAID, $statuses)) { $query->where('invoices.balance', '>', 0); } } @@ -137,10 +137,10 @@ class TaskRepository extends BaseRepository if ($data['action'] == 'start') { $task->is_running = true; $timeLog[] = [strtotime('now'), false]; - } else if ($data['action'] == 'resume') { + } elseif ($data['action'] == 'resume') { $task->is_running = true; $timeLog[] = [strtotime('now'), false]; - } else if ($data['action'] == 'stop' && $task->is_running) { + } elseif ($data['action'] == 'stop' && $task->is_running) { $timeLog[count($timeLog)-1][1] = time(); $task->is_running = false; } @@ -151,5 +151,4 @@ class TaskRepository extends BaseRepository return $task; } - } diff --git a/app/Ninja/Repositories/TokenRepository.php b/app/Ninja/Repositories/TokenRepository.php index 5d3fc6bf26..42b304bcf2 100644 --- a/app/Ninja/Repositories/TokenRepository.php +++ b/app/Ninja/Repositories/TokenRepository.php @@ -15,7 +15,8 @@ class TokenRepository extends BaseRepository { $query = DB::table('account_tokens') ->where('account_tokens.user_id', '=', $userId) - ->whereNull('account_tokens.deleted_at');; + ->whereNull('account_tokens.deleted_at'); + ; return $query->select('account_tokens.public_id', 'account_tokens.name', 'account_tokens.token', 'account_tokens.public_id', 'account_tokens.deleted_at'); } diff --git a/app/Ninja/Repositories/VendorContactRepository.php b/app/Ninja/Repositories/VendorContactRepository.php index a348f05977..0b443f8ca7 100644 --- a/app/Ninja/Repositories/VendorContactRepository.php +++ b/app/Ninja/Repositories/VendorContactRepository.php @@ -24,4 +24,4 @@ class VendorContactRepository extends BaseRepository return $contact; } -} \ No newline at end of file +} diff --git a/app/Ninja/Repositories/VendorRepository.php b/app/Ninja/Repositories/VendorRepository.php index b64716fe7b..db7f81a305 100644 --- a/app/Ninja/Repositories/VendorRepository.php +++ b/app/Ninja/Repositories/VendorRepository.php @@ -92,7 +92,7 @@ class VendorRepository extends BaseRepository $first = false; } - if ( ! $vendor->wasRecentlyCreated) { + if (! $vendor->wasRecentlyCreated) { foreach ($vendor->vendor_contacts as $contact) { if (!in_array($contact->public_id, $vendorcontactIds)) { $contact->delete(); diff --git a/app/Ninja/Transformers/AccountTokenTransformer.php b/app/Ninja/Transformers/AccountTokenTransformer.php index 22d1407be5..2ff3c087fa 100644 --- a/app/Ninja/Transformers/AccountTokenTransformer.php +++ b/app/Ninja/Transformers/AccountTokenTransformer.php @@ -20,4 +20,4 @@ class AccountTokenTransformer extends TransformerAbstract 'token' => $account_token->token ]; } -} \ No newline at end of file +} diff --git a/app/Ninja/Transformers/ClientTransformer.php b/app/Ninja/Transformers/ClientTransformer.php index 67239fa9b2..eb8805b6f1 100644 --- a/app/Ninja/Transformers/ClientTransformer.php +++ b/app/Ninja/Transformers/ClientTransformer.php @@ -125,4 +125,4 @@ class ClientTransformer extends EntityTransformer 'custom_value2' => $client->custom_value2, ]); } -} \ No newline at end of file +} diff --git a/app/Ninja/Transformers/CreditTransformer.php b/app/Ninja/Transformers/CreditTransformer.php index 9fb303ded2..4e6d876ada 100644 --- a/app/Ninja/Transformers/CreditTransformer.php +++ b/app/Ninja/Transformers/CreditTransformer.php @@ -25,4 +25,4 @@ class CreditTransformer extends EntityTransformer 'private_notes' => $credit->private_notes, ]); } -} \ No newline at end of file +} diff --git a/app/Ninja/Transformers/TaskTransformer.php b/app/Ninja/Transformers/TaskTransformer.php index 24acd0d977..eedc06b509 100644 --- a/app/Ninja/Transformers/TaskTransformer.php +++ b/app/Ninja/Transformers/TaskTransformer.php @@ -23,7 +23,6 @@ class TaskTransformer extends EntityTransformer public function __construct(Account $account) { parent::__construct($account); - } public function includeClient(Task $task) diff --git a/app/Ninja/Transformers/TaxRateTransformer.php b/app/Ninja/Transformers/TaxRateTransformer.php index 07b8aa565a..fc09b80354 100644 --- a/app/Ninja/Transformers/TaxRateTransformer.php +++ b/app/Ninja/Transformers/TaxRateTransformer.php @@ -8,7 +8,7 @@ use App\Models\TaxRate; class TaxRateTransformer extends EntityTransformer { - /** + /** * @SWG\Property(property="id", type="integer", example=1, readOnly=true) * @SWG\Property(property="name", type="string", example="GST") * @SWG\Property(property="account_key", type="string", example="asimplestring", readOnly=true) diff --git a/app/Ninja/Transformers/UserTransformer.php b/app/Ninja/Transformers/UserTransformer.php index a22308f096..905fc669f3 100644 --- a/app/Ninja/Transformers/UserTransformer.php +++ b/app/Ninja/Transformers/UserTransformer.php @@ -29,4 +29,4 @@ class UserTransformer extends EntityTransformer 'permissions' => (int) $user->getOriginal('permissions'), ]; } -} \ No newline at end of file +} diff --git a/app/Ninja/Transformers/VendorContactTransformer.php b/app/Ninja/Transformers/VendorContactTransformer.php index b06981475f..14bae701f9 100644 --- a/app/Ninja/Transformers/VendorContactTransformer.php +++ b/app/Ninja/Transformers/VendorContactTransformer.php @@ -18,4 +18,4 @@ class VendorContactTransformer extends EntityTransformer 'phone' => $contact->phone, ]); } -} \ No newline at end of file +} diff --git a/app/Ninja/Transformers/VendorTransformer.php b/app/Ninja/Transformers/VendorTransformer.php index 81eb6f5d51..ce1e7d6c44 100644 --- a/app/Ninja/Transformers/VendorTransformer.php +++ b/app/Ninja/Transformers/VendorTransformer.php @@ -85,4 +85,4 @@ class VendorTransformer extends EntityTransformer 'currency_id' => (int) $vendor->currency_id ]); } -} \ No newline at end of file +} diff --git a/app/Policies/AccountGatewayPolicy.php b/app/Policies/AccountGatewayPolicy.php index 0cfd295136..a7397eedfb 100644 --- a/app/Policies/AccountGatewayPolicy.php +++ b/app/Policies/AccountGatewayPolicy.php @@ -15,7 +15,8 @@ class AccountGatewayPolicy extends EntityPolicy * @param $item * @return bool */ - public static function edit(User $user, $item) { + public static function edit(User $user, $item) + { return $user->hasPermission('admin'); } @@ -23,7 +24,8 @@ class AccountGatewayPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->hasPermission('admin'); } } diff --git a/app/Policies/BankAccountPolicy.php b/app/Policies/BankAccountPolicy.php index 9c8e6794dc..94831c587a 100644 --- a/app/Policies/BankAccountPolicy.php +++ b/app/Policies/BankAccountPolicy.php @@ -14,7 +14,8 @@ class BankAccountPolicy extends EntityPolicy * @param $item * @return bool */ - public static function edit(User $user, $item) { + public static function edit(User $user, $item) + { return $user->hasPermission('admin'); } @@ -22,7 +23,8 @@ class BankAccountPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->hasPermission('admin'); } } diff --git a/app/Policies/ClientPolicy.php b/app/Policies/ClientPolicy.php index 4610c139fb..c33343a576 100644 --- a/app/Policies/ClientPolicy.php +++ b/app/Policies/ClientPolicy.php @@ -2,4 +2,6 @@ namespace App\Policies; -class ClientPolicy extends EntityPolicy {} \ No newline at end of file +class ClientPolicy extends EntityPolicy +{ +} diff --git a/app/Policies/CreditPolicy.php b/app/Policies/CreditPolicy.php index 539bc7e518..6699810023 100644 --- a/app/Policies/CreditPolicy.php +++ b/app/Policies/CreditPolicy.php @@ -2,4 +2,6 @@ namespace App\Policies; -class CreditPolicy extends EntityPolicy {} \ No newline at end of file +class CreditPolicy extends EntityPolicy +{ +} diff --git a/app/Policies/EntityPolicy.php b/app/Policies/EntityPolicy.php index e2fa9af8e6..a046e15064 100644 --- a/app/Policies/EntityPolicy.php +++ b/app/Policies/EntityPolicy.php @@ -16,8 +16,9 @@ class EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { - if ( ! static::checkModuleEnabled($user, $item)) { + public static function create(User $user, $item) + { + if (! static::checkModuleEnabled($user, $item)) { return false; } @@ -30,8 +31,9 @@ class EntityPolicy * * @return bool */ - public static function edit(User $user, $item) { - if ( ! static::checkModuleEnabled($user, $item)) { + public static function edit(User $user, $item) + { + if (! static::checkModuleEnabled($user, $item)) { return false; } @@ -44,8 +46,9 @@ class EntityPolicy * * @return bool */ - public static function view(User $user, $item) { - if ( ! static::checkModuleEnabled($user, $item)) { + public static function view(User $user, $item) + { + if (! static::checkModuleEnabled($user, $item)) { return false; } @@ -57,7 +60,8 @@ class EntityPolicy * @param $ownerUserId * @return bool */ - public static function viewByOwner(User $user, $ownerUserId) { + public static function viewByOwner(User $user, $ownerUserId) + { return $user->hasPermission('view_all') || $user->id == $ownerUserId; } @@ -66,7 +70,8 @@ class EntityPolicy * @param $ownerUserId * @return bool */ - public static function editByOwner(User $user, $ownerUserId) { + public static function editByOwner(User $user, $ownerUserId) + { return $user->hasPermission('edit_all') || $user->id == $ownerUserId; } diff --git a/app/Policies/ExpenseCategoryPolicy.php b/app/Policies/ExpenseCategoryPolicy.php index 2eeb3d7e96..b503026b45 100644 --- a/app/Policies/ExpenseCategoryPolicy.php +++ b/app/Policies/ExpenseCategoryPolicy.php @@ -11,7 +11,8 @@ class ExpenseCategoryPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->is_admin; } @@ -21,7 +22,8 @@ class ExpenseCategoryPolicy extends EntityPolicy * * @return bool */ - public static function edit(User $user, $item) { + public static function edit(User $user, $item) + { return $user->is_admin; } @@ -31,7 +33,8 @@ class ExpenseCategoryPolicy extends EntityPolicy * * @return bool */ - public static function view(User $user, $item) { + public static function view(User $user, $item) + { return true; } @@ -40,7 +43,8 @@ class ExpenseCategoryPolicy extends EntityPolicy * @param $ownerUserId * @return bool */ - public static function viewByOwner(User$user, $ownerUserId) { + public static function viewByOwner(User$user, $ownerUserId) + { return true; } @@ -49,8 +53,8 @@ class ExpenseCategoryPolicy extends EntityPolicy * @param $ownerUserId * @return bool */ - public static function editByOwner(User $user, $ownerUserId) { + public static function editByOwner(User $user, $ownerUserId) + { return $user->is_admin; } - } diff --git a/app/Policies/ExpensePolicy.php b/app/Policies/ExpensePolicy.php index 92a22ac580..582713777d 100644 --- a/app/Policies/ExpensePolicy.php +++ b/app/Policies/ExpensePolicy.php @@ -10,12 +10,12 @@ class ExpensePolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { - if ( ! parent::create($user, $item)) { + public static function create(User $user, $item) + { + if (! parent::create($user, $item)) { return false; } return $user->hasFeature(FEATURE_EXPENSES); } - } diff --git a/app/Policies/GenericEntityPolicy.php b/app/Policies/GenericEntityPolicy.php index e2afc039e4..8d5c6bf438 100644 --- a/app/Policies/GenericEntityPolicy.php +++ b/app/Policies/GenericEntityPolicy.php @@ -2,7 +2,6 @@ namespace App\Policies; - use Utils; use App\Models\User; use Illuminate\Support\Str; @@ -21,7 +20,8 @@ class GenericEntityPolicy * @param $ownerUserId * @return bool|mixed */ - public static function editByOwner(User $user, $entityType, $ownerUserId) { + public static function editByOwner(User $user, $entityType, $ownerUserId) + { $className = static::className($entityType); if (method_exists($className, 'editByOwner')) { return call_user_func([$className, 'editByOwner'], $user, $ownerUserId); @@ -36,7 +36,8 @@ class GenericEntityPolicy * @param $ownerUserId * @return bool|mixed */ - public static function viewByOwner(User $user, $entityType, $ownerUserId) { + public static function viewByOwner(User $user, $entityType, $ownerUserId) + { $className = static::className($entityType); if (method_exists($className, 'viewByOwner')) { return call_user_func([$className, 'viewByOwner'], $user, $ownerUserId); @@ -50,7 +51,8 @@ class GenericEntityPolicy * @param $entityType * @return bool|mixed */ - public static function create(User $user, $entityType) { + public static function create(User $user, $entityType) + { $className = static::className($entityType); if (method_exists($className, 'create')) { return call_user_func([$className, 'create'], $user, $entityType); @@ -64,7 +66,8 @@ class GenericEntityPolicy * @param $entityType * @return bool|mixed */ - public static function view(User $user, $entityType) { + public static function view(User $user, $entityType) + { $className = static::className($entityType); if (method_exists($className, 'view')) { return call_user_func([$className, 'view'], $user, $entityType); @@ -75,7 +78,7 @@ class GenericEntityPolicy private static function className($entityType) { - if ( ! Utils::isNinjaProd()) { + if (! Utils::isNinjaProd()) { if ($module = \Module::find($entityType)) { return "Modules\\{$module->getName()}\\Policies\\{$module->getName()}Policy"; } @@ -84,5 +87,4 @@ class GenericEntityPolicy $studly = Str::studly($entityType); return "App\\Policies\\{$studly}Policy"; } - } diff --git a/app/Policies/InvoicePolicy.php b/app/Policies/InvoicePolicy.php index aa72b4c053..f06b147d08 100644 --- a/app/Policies/InvoicePolicy.php +++ b/app/Policies/InvoicePolicy.php @@ -2,4 +2,6 @@ namespace App\Policies; -class InvoicePolicy extends EntityPolicy {} +class InvoicePolicy extends EntityPolicy +{ +} diff --git a/app/Policies/PaymentPolicy.php b/app/Policies/PaymentPolicy.php index e9c3fc582a..97763936b1 100644 --- a/app/Policies/PaymentPolicy.php +++ b/app/Policies/PaymentPolicy.php @@ -2,4 +2,6 @@ namespace App\Policies; -class PaymentPolicy extends EntityPolicy {} \ No newline at end of file +class PaymentPolicy extends EntityPolicy +{ +} diff --git a/app/Policies/PaymentTermPolicy.php b/app/Policies/PaymentTermPolicy.php index e1ee2e494b..054b88d0e2 100644 --- a/app/Policies/PaymentTermPolicy.php +++ b/app/Policies/PaymentTermPolicy.php @@ -15,7 +15,8 @@ class PaymentTermPolicy extends EntityPolicy * @param $item * @return mixed */ - public static function edit(User $user, $item) { + public static function edit(User $user, $item) + { return $user->hasPermission('admin'); } @@ -23,7 +24,8 @@ class PaymentTermPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->hasPermission('admin'); } } diff --git a/app/Policies/ProductPolicy.php b/app/Policies/ProductPolicy.php index 23ce11fc75..7cabfeec80 100644 --- a/app/Policies/ProductPolicy.php +++ b/app/Policies/ProductPolicy.php @@ -9,5 +9,4 @@ use App\Models\User; */ class ProductPolicy extends EntityPolicy { - } diff --git a/app/Policies/ProjectPolicy.php b/app/Policies/ProjectPolicy.php index a88d3a3790..813ba4913e 100644 --- a/app/Policies/ProjectPolicy.php +++ b/app/Policies/ProjectPolicy.php @@ -6,5 +6,4 @@ use App\Models\User; class ProjectPolicy extends EntityPolicy { - } diff --git a/app/Policies/QuotePolicy.php b/app/Policies/QuotePolicy.php index 6d1920d16c..20909f3df7 100644 --- a/app/Policies/QuotePolicy.php +++ b/app/Policies/QuotePolicy.php @@ -10,12 +10,12 @@ class QuotePolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { - if ( ! parent::create($user, $item)) { + public static function create(User $user, $item) + { + if (! parent::create($user, $item)) { return false; } return $user->hasFeature(FEATURE_QUOTES); } - } diff --git a/app/Policies/RecurringInvoicePolicy.php b/app/Policies/RecurringInvoicePolicy.php index 85e7037f88..20113fb0a6 100644 --- a/app/Policies/RecurringInvoicePolicy.php +++ b/app/Policies/RecurringInvoicePolicy.php @@ -2,4 +2,6 @@ namespace App\Policies; -class RecurringInvoicePolicy extends EntityPolicy {} +class RecurringInvoicePolicy extends EntityPolicy +{ +} diff --git a/app/Policies/TaskPolicy.php b/app/Policies/TaskPolicy.php index aa0a2ef762..d6ab2bba90 100644 --- a/app/Policies/TaskPolicy.php +++ b/app/Policies/TaskPolicy.php @@ -10,12 +10,12 @@ class TaskPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { - if ( ! parent::create($user, $item)) { + public static function create(User $user, $item) + { + if (! parent::create($user, $item)) { return false; } return $user->hasFeature(FEATURE_TASKS); } - } diff --git a/app/Policies/TaxRatePolicy.php b/app/Policies/TaxRatePolicy.php index 5f70694890..d2142e375e 100644 --- a/app/Policies/TaxRatePolicy.php +++ b/app/Policies/TaxRatePolicy.php @@ -11,7 +11,8 @@ class TaxRatePolicy extends EntityPolicy * @param $item * @return bool */ - public static function edit(User $user, $item) { + public static function edit(User $user, $item) + { return $user->hasPermission('admin'); } @@ -19,7 +20,8 @@ class TaxRatePolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->hasPermission('admin'); } } diff --git a/app/Policies/TokenPolicy.php b/app/Policies/TokenPolicy.php index 419a288262..c620e5889c 100644 --- a/app/Policies/TokenPolicy.php +++ b/app/Policies/TokenPolicy.php @@ -4,12 +4,15 @@ namespace App\Policies; use App\Models\User; -class TokenPolicy extends EntityPolicy { - public static function edit(User $user, $item) { +class TokenPolicy extends EntityPolicy +{ + public static function edit(User $user, $item) + { return $user->hasPermission('admin'); } - public static function create(User $user, $item) { + public static function create(User $user, $item) + { return $user->hasPermission('admin'); } } diff --git a/app/Policies/VendorPolicy.php b/app/Policies/VendorPolicy.php index f806ae8260..8f993e2ed9 100644 --- a/app/Policies/VendorPolicy.php +++ b/app/Policies/VendorPolicy.php @@ -10,12 +10,12 @@ class VendorPolicy extends EntityPolicy * @param User $user * @return bool */ - public static function create(User $user, $item) { - if ( ! parent::create($user, $item)) { + public static function create(User $user, $item) + { + if (! parent::create($user, $item)) { return false; } return $user->hasFeature(FEATURE_EXPENSES); } - } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 1a0a7751d6..4b68229e9f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -14,53 +14,52 @@ use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { - /** - * Bootstrap any application services. - * - * @return void - */ - public function boot() - { - Form::macro('image_data', function($image, $contents = false) { - if(!$contents){ + /** + * Bootstrap any application services. + * + * @return void + */ + public function boot() + { + Form::macro('image_data', function ($image, $contents = false) { + if (!$contents) { $contents = file_get_contents($image); - } - else{ + } else { $contents = $image; } return 'data:image/jpeg;base64,' . base64_encode($contents); }); - Form::macro('nav_link', function($url, $text) { + Form::macro('nav_link', function ($url, $text) { //$class = ( Request::is($url) || Request::is($url.'/*') || Request::is($url2.'/*') ) ? ' class="active"' : ''; - $class = ( Request::is($url) || Request::is($url.'/*') ) ? ' class="active"' : ''; + $class = (Request::is($url) || Request::is($url.'/*')) ? ' class="active"' : ''; $title = trans("texts.$text") . Utils::getProLabel($text); return ''.$title.''; }); - Form::macro('tab_link', function($url, $text, $active = false) { + Form::macro('tab_link', function ($url, $text, $active = false) { $class = $active ? ' class="active"' : ''; return ''.$text.''; }); - Form::macro('menu_link', function($type) { + Form::macro('menu_link', function ($type) { $types = $type.'s'; $Type = ucfirst($type); $Types = ucfirst($types); - $class = ( Request::is($types) || Request::is('*'.$type.'*')) && !Request::is('*settings*') ? ' active' : ''; + $class = (Request::is($types) || Request::is('*'.$type.'*')) && !Request::is('*settings*') ? ' active' : ''; return '

'; }); - Form::macro('flatButton', function($label, $color) { + Form::macro('flatButton', function ($label, $color) { return ''; }); - Form::macro('emailViewButton', function($link = '#', $entityType = ENTITY_INVOICE) { + Form::macro('emailViewButton', function ($link = '#', $entityType = ENTITY_INVOICE) { return view('partials.email_button') ->with([ 'link' => $link, @@ -70,7 +69,7 @@ class AppServiceProvider extends ServiceProvider ->render(); }); - Form::macro('emailPaymentButton', function($link = '#') { + Form::macro('emailPaymentButton', function ($link = '#') { return view('partials.email_button') ->with([ 'link' => $link, @@ -80,7 +79,7 @@ class AppServiceProvider extends ServiceProvider ->render(); }); - Form::macro('breadcrumbs', function($status = false) { + Form::macro('breadcrumbs', function ($status = false) { $str = ''; }); - Form::macro('human_filesize', function($bytes, $decimals = 1) { + Form::macro('human_filesize', function ($bytes, $decimals = 1) { $size = ['B','kB','MB','GB','TB','PB','EB','ZB','YB']; $factor = floor((strlen($bytes) - 1) / 3); - if($factor == 0)$decimals=0;// There aren't fractional bytes + if ($factor == 0) { + $decimals=0; + }// There aren't fractional bytes return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor]; }); - Validator::extend('positive', function($attribute, $value, $parameters) { + Validator::extend('positive', function ($attribute, $value, $parameters) { return Utils::parseFloat($value) >= 0; }); - Validator::extend('has_credit', function($attribute, $value, $parameters) { + Validator::extend('has_credit', function ($attribute, $value, $parameters) { $publicClientId = $parameters[0]; $amount = $parameters[1]; @@ -151,7 +152,7 @@ class AppServiceProvider extends ServiceProvider }); // check that the time log elements don't overlap - Validator::extend('time_log', function($attribute, $value, $parameters) { + Validator::extend('time_log', function ($attribute, $value, $parameters) { $lastTime = 0; $value = json_decode($value); array_multisort($value); @@ -171,11 +172,11 @@ class AppServiceProvider extends ServiceProvider return true; }); - Validator::extend('has_counter', function($attribute, $value, $parameters) { + Validator::extend('has_counter', function ($attribute, $value, $parameters) { return !$value || strstr($value, '{$counter}'); }); - Validator::extend('valid_contacts', function($attribute, $value, $parameters) { + Validator::extend('valid_contacts', function ($attribute, $value, $parameters) { foreach ($value as $contact) { $validator = Validator::make($contact, [ 'email' => 'email|required_without:first_name', @@ -188,7 +189,7 @@ class AppServiceProvider extends ServiceProvider return true; }); - Validator::extend('valid_invoice_items', function($attribute, $value, $parameters) { + Validator::extend('valid_invoice_items', function ($attribute, $value, $parameters) { $total = 0; foreach ($value as $item) { $qty = !empty($item['qty']) ? $item['qty'] : 1; @@ -198,26 +199,25 @@ class AppServiceProvider extends ServiceProvider return $total <= MAX_INVOICE_AMOUNT; }); - Validator::extend('valid_subdomain', function($attribute, $value, $parameters) { - return ! in_array($value, ['www', 'app', 'mail', 'admin', 'blog', 'user', 'contact', 'payment', 'payments', 'billing', 'invoice', 'business', 'owner', 'info', 'ninja', 'docs', 'doc', 'documents', 'download']); - }); - } - - /** - * Register any application services. - * - * This service provider is a great spot to register your various container - * bindings with the application. As you can see, we are registering our - * "Registrar" implementation here. You can add your own bindings too! - * - * @return void - */ - public function register() - { - $this->app->bind( - 'Illuminate\Contracts\Auth\Registrar', - 'App\Services\Registrar' - ); - } + Validator::extend('valid_subdomain', function ($attribute, $value, $parameters) { + return ! in_array($value, ['www', 'app', 'mail', 'admin', 'blog', 'user', 'contact', 'payment', 'payments', 'billing', 'invoice', 'business', 'owner', 'info', 'ninja', 'docs', 'doc', 'documents', 'download']); + }); + } + /** + * Register any application services. + * + * This service provider is a great spot to register your various container + * bindings with the application. As you can see, we are registering our + * "Registrar" implementation here. You can add your own bindings too! + * + * @return void + */ + public function register() + { + $this->app->bind( + 'Illuminate\Contracts\Auth\Registrar', + 'App\Services\Registrar' + ); + } } diff --git a/app/Providers/ComposerServiceProvider.php b/app/Providers/ComposerServiceProvider.php index 17aeef6caf..6a515e12a6 100644 --- a/app/Providers/ComposerServiceProvider.php +++ b/app/Providers/ComposerServiceProvider.php @@ -47,6 +47,5 @@ class ComposerServiceProvider extends ServiceProvider */ public function register() { - } } diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index 739564c6ef..27871ce566 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -2,20 +2,19 @@ use Illuminate\Support\ServiceProvider; -class ConfigServiceProvider extends ServiceProvider { - - /** - * Overwrite any vendor / package configuration. - * - * This service provider is intended to provide a convenient location for you - * to overwrite any "vendor" or package configuration that you may want to - * modify before the application handles the incoming request / command. - * - * @return void - */ - public function register() - { - - } +class ConfigServiceProvider extends ServiceProvider +{ + /** + * Overwrite any vendor / package configuration. + * + * This service provider is intended to provide a convenient location for you + * to overwrite any "vendor" or package configuration that you may want to + * modify before the application handles the incoming request / command. + * + * @return void + */ + public function register() + { + } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 4a23769092..e2ae516499 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -3,14 +3,15 @@ use Illuminate\Contracts\Events\Dispatcher as DispatcherContract; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; -class EventServiceProvider extends ServiceProvider { +class EventServiceProvider extends ServiceProvider +{ - /** - * The event handler mappings for the application. - * - * @var array - */ - protected $listen = [ + /** + * The event handler mappings for the application. + * + * @var array + */ + protected $listen = [ // Clients 'App\Events\ClientWasCreated' => [ @@ -158,33 +159,33 @@ class EventServiceProvider extends ServiceProvider { 'App\Events\TaskWasCreated' => [ 'App\Listeners\ActivityListener@createdTask', ], - 'App\Events\TaskWasUpdated' => [ + 'App\Events\TaskWasUpdated' => [ 'App\Listeners\ActivityListener@updatedTask', ], - 'App\Events\TaskWasRestored' => [ + 'App\Events\TaskWasRestored' => [ 'App\Listeners\ActivityListener@restoredTask', ], - 'App\Events\TaskWasArchived' => [ + 'App\Events\TaskWasArchived' => [ 'App\Listeners\ActivityListener@archivedTask', ], - 'App\Events\TaskWasDeleted' => [ + 'App\Events\TaskWasDeleted' => [ 'App\Listeners\ActivityListener@deletedTask', ], - // Expense events + // Expense events 'App\Events\ExpenseWasCreated' => [ 'App\Listeners\ActivityListener@createdExpense', ], - 'App\Events\ExpenseWasUpdated' => [ + 'App\Events\ExpenseWasUpdated' => [ 'App\Listeners\ActivityListener@updatedExpense', ], - 'App\Events\ExpenseWasRestored' => [ + 'App\Events\ExpenseWasRestored' => [ 'App\Listeners\ActivityListener@restoredExpense', ], - 'App\Events\ExpenseWasArchived' => [ + 'App\Events\ExpenseWasArchived' => [ 'App\Listeners\ActivityListener@archivedExpense', ], - 'App\Events\ExpenseWasDeleted' => [ + 'App\Events\ExpenseWasDeleted' => [ 'App\Listeners\ActivityListener@deletedExpense', ], @@ -192,19 +193,18 @@ class EventServiceProvider extends ServiceProvider { \Codedge\Updater\Events\UpdateAvailable::class => [ \Codedge\Updater\Listeners\SendUpdateAvailableNotification::class ], - ]; + ]; - /** - * Register any other events for your application. - * - * @param \Illuminate\Contracts\Events\Dispatcher $events - * @return void - */ - public function boot(DispatcherContract $events) - { - parent::boot($events); - - // - } + /** + * Register any other events for your application. + * + * @param \Illuminate\Contracts\Events\Dispatcher $events + * @return void + */ + public function boot(DispatcherContract $events) + { + parent::boot($events); + // + } } diff --git a/app/Services/BaseService.php b/app/Services/BaseService.php index 5bc2314518..5342e9836b 100644 --- a/app/Services/BaseService.php +++ b/app/Services/BaseService.php @@ -25,7 +25,7 @@ class BaseService */ public function bulk($ids, $action) { - if ( ! $ids ) { + if (! $ids) { return 0; } diff --git a/app/Services/CreditService.php b/app/Services/CreditService.php index 5b83b3640c..85949889ed 100644 --- a/app/Services/CreditService.php +++ b/app/Services/CreditService.php @@ -60,7 +60,7 @@ class CreditService extends BaseService $datatable = new CreditDatatable(true, $clientPublicId); $query = $this->creditRepo->find($clientPublicId, $search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('credits.user_id', '=', Auth::user()->id); } diff --git a/app/Services/DatatableService.php b/app/Services/DatatableService.php index b9ddc20c52..de497bd225 100644 --- a/app/Services/DatatableService.php +++ b/app/Services/DatatableService.php @@ -79,7 +79,7 @@ class DatatableService if (count($action)) { // if show function isn't set default to true if (count($action) == 2) { - $action[] = function() { + $action[] = function () { return true; }; } @@ -101,17 +101,17 @@ class DatatableService $lastIsDivider = false; } } - } elseif ( ! $lastIsDivider) { + } elseif (! $lastIsDivider) { $dropdown_contents .= '
  • '; $lastIsDivider = true; } } - if ( ! $hasAction) { + if (! $hasAction) { return ''; } - if ( $can_edit && ! $lastIsDivider) { + if ($can_edit && ! $lastIsDivider) { $dropdown_contents .= '
  • '; } @@ -119,7 +119,7 @@ class DatatableService $dropdown_contents .= "
  • entityType}('archive', {$model->public_id})\">" . mtrans($datatable->entityType, "archive_{$datatable->entityType}") . '
  • '; } - } else if($can_edit) { + } elseif ($can_edit) { $dropdown_contents .= "
  • entityType}('restore', {$model->public_id})\">" . mtrans($datatable->entityType, "restore_{$datatable->entityType}") . '
  • '; } diff --git a/app/Services/EmailService.php b/app/Services/EmailService.php index c148dbdede..ce754761da 100644 --- a/app/Services/EmailService.php +++ b/app/Services/EmailService.php @@ -66,4 +66,4 @@ class EmailService return true; } -} \ No newline at end of file +} diff --git a/app/Services/ExpenseService.php b/app/Services/ExpenseService.php index c07e3f29e0..fc71ab2eee 100644 --- a/app/Services/ExpenseService.php +++ b/app/Services/ExpenseService.php @@ -69,7 +69,7 @@ class ExpenseService extends BaseService { $query = $this->expenseRepo->find($search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('expenses.user_id', '=', Auth::user()->id); } @@ -86,7 +86,7 @@ class ExpenseService extends BaseService $query = $this->expenseRepo->findVendor($vendorPublicId); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('expenses.user_id', '=', Auth::user()->id); } diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php index 0a17f72231..7923fc14c4 100644 --- a/app/Services/ImportService.php +++ b/app/Services/ImportService.php @@ -121,8 +121,7 @@ class ImportService ExpenseRepository $expenseRepo, VendorRepository $vendorRepo, ExpenseCategoryRepository $expenseCategoryRepo - ) - { + ) { $this->fractal = $manager; $this->fractal->setSerializer(new ArraySerializer()); @@ -167,7 +166,6 @@ class ImportService } foreach ($json['clients'] as $jsonClient) { - if (EntityModel::validate($jsonClient, ENTITY_CLIENT) === true) { $client = $this->clientRepo->save($jsonClient); $this->addClientToMaps($client); @@ -302,15 +300,15 @@ class ImportService // Create expesnse category if ($entityType == ENTITY_EXPENSE) { - if ( ! empty($row->expense_category)) { + if (! empty($row->expense_category)) { $categoryId = $transformer->getExpenseCategoryId($row->expense_category); - if ( ! $categoryId) { + if (! $categoryId) { $category = $this->expenseCategoryRepo->save(['name' => $row->expense_category]); $this->addExpenseCategoryToMaps($category); } } - if ( ! empty($row->vendor) && ($vendorName = trim($row->vendor))) { - if ( ! $transformer->getVendorId($vendorName)) { + if (! empty($row->vendor) && ($vendorName = trim($row->vendor))) { + if (! $transformer->getVendorId($vendorName)) { $vendor = $this->vendorRepo->save(['name' => $vendorName, 'vendor_contact' => []]); $this->addVendorToMaps($vendor); } diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php index ff0ec559f5..c9df5ae6bb 100644 --- a/app/Services/InvoiceService.php +++ b/app/Services/InvoiceService.php @@ -38,8 +38,7 @@ class InvoiceService extends BaseService ClientRepository $clientRepo, InvoiceRepository $invoiceRepo, DatatableService $datatableService - ) - { + ) { $this->clientRepo = $clientRepo; $this->invoiceRepo = $invoiceRepo; $this->datatableService = $datatableService; @@ -92,7 +91,7 @@ class InvoiceService extends BaseService } // if no contacts are selected auto-select the first to enusre there's an invitation - if ( ! count($sendInvoiceIds)) { + if (! count($sendInvoiceIds)) { $sendInvoiceIds[] = $client->contacts[0]->id; } @@ -136,7 +135,7 @@ class InvoiceService extends BaseService { $account = $quote->account; - if ( ! $account->hasFeature(FEATURE_QUOTES) || ! $quote->isType(INVOICE_TYPE_QUOTE) || $quote->quote_invoice_id) { + if (! $account->hasFeature(FEATURE_QUOTES) || ! $quote->isType(INVOICE_TYPE_QUOTE) || $quote->quote_invoice_id) { return null; } @@ -165,11 +164,10 @@ class InvoiceService extends BaseService $query = $this->invoiceRepo->getInvoices($accountId, $clientPublicId, $entityType, $search) ->where('invoices.invoice_type_id', '=', $entityType == ENTITY_QUOTE ? INVOICE_TYPE_QUOTE : INVOICE_TYPE_STANDARD); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('invoices.user_id', '=', Auth::user()->id); } return $this->datatableService->createDatatable($datatable, $query); } - } diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 36b6c96c24..582682f173 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -24,8 +24,7 @@ class PaymentService extends BaseService PaymentRepository $paymentRepo, AccountRepository $accountRepo, DatatableService $datatableService - ) - { + ) { $this->datatableService = $datatableService; $this->paymentRepo = $paymentRepo; $this->accountRepo = $accountRepo; @@ -45,7 +44,7 @@ class PaymentService extends BaseService */ public function autoBillInvoice(Invoice $invoice) { - if ( ! $invoice->canBePaid()) { + if (! $invoice->canBePaid()) { return false; } @@ -58,7 +57,7 @@ class PaymentService extends BaseService /** @var \App\Models\Invitation $invitation */ $invitation = $invoice->invitations->first(); - if ( ! $invitation) { + if (! $invitation) { return false; } @@ -81,13 +80,13 @@ class PaymentService extends BaseService $paymentDriver = $account->paymentDriver($invitation, GATEWAY_TYPE_TOKEN); - if ( ! $paymentDriver) { + if (! $paymentDriver) { return false; } $customer = $paymentDriver->customer(); - if ( ! $customer) { + if (! $customer) { return false; } @@ -139,7 +138,7 @@ class PaymentService extends BaseService $datatable = new PaymentDatatable(true, $clientPublicId); $query = $this->paymentRepo->find($clientPublicId, $search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('payments.user_id', '=', Auth::user()->id); } @@ -150,7 +149,7 @@ class PaymentService extends BaseService public function bulk($ids, $action, $params = []) { if ($action == 'refund') { - if ( ! $ids ) { + if (! $ids) { return 0; } diff --git a/app/Services/ProductService.php b/app/Services/ProductService.php index 3fcab2fb35..36e9ff988e 100644 --- a/app/Services/ProductService.php +++ b/app/Services/ProductService.php @@ -46,7 +46,7 @@ class ProductService extends BaseService $datatable = new ProductDatatable(true); $query = $this->productRepo->find($accountId, $search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('products.user_id', '=', Auth::user()->id); } diff --git a/app/Services/PushService.php b/app/Services/PushService.php index 759e0271cb..8dc5998ec4 100644 --- a/app/Services/PushService.php +++ b/app/Services/PushService.php @@ -31,18 +31,19 @@ class PushService public function sendNotification(Invoice $invoice, $type) { //check user has registered for push notifications - if(!$this->checkDeviceExists($invoice->account)) + if (!$this->checkDeviceExists($invoice->account)) { return; + } //Harvest an array of devices that are registered for this notification type - $devices = json_decode($invoice->account->devices, TRUE); + $devices = json_decode($invoice->account->devices, true); - foreach($devices as $device) - { - if(($device["notify_{$type}"] == TRUE) && ($device['device'] == 'ios') && IOS_DEVICE) + foreach ($devices as $device) { + if (($device["notify_{$type}"] == true) && ($device['device'] == 'ios') && IOS_DEVICE) { $this->pushMessage($invoice, $device['token'], $type, IOS_DEVICE); - elseif(($device["notify_{$type}"] == TRUE) && ($device['device'] == 'fcm') && ANDROID_DEVICE) + } elseif (($device["notify_{$type}"] == true) && ($device['device'] == 'fcm') && ANDROID_DEVICE) { $this->pushMessage($invoice, $device['token'], $type, ANDROID_DEVICE); + } } } @@ -71,12 +72,13 @@ class PushService */ private function checkDeviceExists(Account $account) { - $devices = json_decode($account->devices, TRUE); + $devices = json_decode($account->devices, true); - if(count($devices) >= 1) - return TRUE; - else - return FALSE; + if (count($devices) >= 1) { + return true; + } else { + return false; + } } /** @@ -91,8 +93,7 @@ class PushService */ private function messageType(Invoice $invoice, $type) { - switch($type) - { + switch ($type) { case 'sent': return $this->entitySentMessage($invoice); break; @@ -117,10 +118,11 @@ class PushService */ private function entitySentMessage(Invoice $invoice) { - if($invoice->isType(INVOICE_TYPE_QUOTE)) + if ($invoice->isType(INVOICE_TYPE_QUOTE)) { return trans('texts.notification_quote_sent_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); - else + } else { return trans('texts.notification_invoice_sent_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); + } } /** @@ -147,9 +149,10 @@ class PushService */ private function entityViewedMessage(Invoice $invoice) { - if($invoice->isType(INVOICE_TYPE_QUOTE)) + if ($invoice->isType(INVOICE_TYPE_QUOTE)) { return trans('texts.notification_quote_viewed_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); - else + } else { return trans('texts.notification_invoice_viewed_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); + } } -} \ No newline at end of file +} diff --git a/app/Services/RecurringInvoiceService.php b/app/Services/RecurringInvoiceService.php index 9c90b37b7a..9226ec04ba 100644 --- a/app/Services/RecurringInvoiceService.php +++ b/app/Services/RecurringInvoiceService.php @@ -21,11 +21,10 @@ class RecurringInvoiceService extends BaseService $datatable = new RecurringInvoiceDatatable(true, $clientPublicId); $query = $this->invoiceRepo->getRecurringInvoices($accountId, $clientPublicId, $search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('invoices.user_id', '=', Auth::user()->id); } return $this->datatableService->createDatatable($datatable, $query); } - } diff --git a/app/Services/TaskService.php b/app/Services/TaskService.php index a0b8c67911..5cab333860 100644 --- a/app/Services/TaskService.php +++ b/app/Services/TaskService.php @@ -43,7 +43,7 @@ class TaskService extends BaseService $datatable = new TaskDatatable(true, $clientPublicId); $query = $this->taskRepo->find($clientPublicId, $search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('tasks.user_id', '=', Auth::user()->id); } diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php index fe20a55c4a..c4220d2771 100644 --- a/app/Services/TemplateService.php +++ b/app/Services/TemplateService.php @@ -30,11 +30,11 @@ class TemplateService if ($account->hasFeature(FEATURE_DOCUMENTS) && $invoice->hasDocuments()) { $documentsHTML .= trans('texts.email_documents_header').'
      '; - foreach($invoice->documents as $document){ + foreach ($invoice->documents as $document) { $documentsHTML .= '
    • '.HTML::entities($document->name).'
    • '; } - foreach($invoice->expenses as $expense){ - foreach($expense->documents as $document){ + foreach ($invoice->expenses as $expense) { + foreach ($expense->documents as $document) { $documentsHTML .= '
    • '.HTML::entities($document->name).'
    • '; } } @@ -85,8 +85,7 @@ class TemplateService if (!$includesPasswordPlaceholder && $passwordHTML) { $pos = strrpos($str, '$password'); - if ($pos !== false) - { + if ($pos !== false) { $str = substr_replace($str, $passwordHTML, $pos, 9/* length of "$password" */); } } diff --git a/app/Services/VendorService.php b/app/Services/VendorService.php index 51f81d33d6..af49313489 100644 --- a/app/Services/VendorService.php +++ b/app/Services/VendorService.php @@ -33,8 +33,7 @@ class VendorService extends BaseService VendorRepository $vendorRepo, DatatableService $datatableService, NinjaRepository $ninjaRepo - ) - { + ) { $this->vendorRepo = $vendorRepo; $this->ninjaRepo = $ninjaRepo; $this->datatableService = $datatableService; @@ -71,7 +70,7 @@ class VendorService extends BaseService $datatable = new VendorDatatable(); $query = $this->vendorRepo->find($search); - if(!Utils::hasPermission('view_all')){ + if (!Utils::hasPermission('view_all')) { $query->where('vendors.user_id', '=', Auth::user()->id); } diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 018da7b235..4b6486f316 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,7 +1,7 @@ define(Contact::class, function (Faker\Generator $faker) { return [ - 'client_id' => function() { + 'client_id' => function () { return factory(Client::class)->create()->id; }, 'user_id' => 1, @@ -43,6 +43,6 @@ $factory->define(Client::class, function (Faker\Generator $faker) { 'city' => $faker->city, 'state' => $faker->state, 'postal_code' => $faker->postcode, - 'country_id' => Country::all()->random()->id, + 'country_id' => Country::all()->random()->id, ]; -}); \ No newline at end of file +}); diff --git a/database/migrations/2013_11_05_180133_confide_setup_users_table.php b/database/migrations/2013_11_05_180133_confide_setup_users_table.php index a6538f20a4..3d61b2a65a 100644 --- a/database/migrations/2013_11_05_180133_confide_setup_users_table.php +++ b/database/migrations/2013_11_05_180133_confide_setup_users_table.php @@ -1,7 +1,8 @@ increments('id'); $table->string('capital', 255)->nullable(); $table->string('citizenship', 255)->nullable(); @@ -56,49 +56,42 @@ class ConfideSetupUsersTable extends Migration { $table->boolean('eea')->default(0); }); - Schema::create('themes', function($t) - { + Schema::create('themes', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('payment_types', function($t) - { + Schema::create('payment_types', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('payment_terms', function($t) - { + Schema::create('payment_terms', function ($t) { $t->increments('id'); $t->integer('num_days'); $t->string('name'); }); - Schema::create('timezones', function($t) - { + Schema::create('timezones', function ($t) { $t->increments('id'); $t->string('name'); $t->string('location'); }); - Schema::create('date_formats', function($t) - { + Schema::create('date_formats', function ($t) { $t->increments('id'); $t->string('format'); $t->string('picker_format'); $t->string('label'); }); - Schema::create('datetime_formats', function($t) - { + Schema::create('datetime_formats', function ($t) { $t->increments('id'); $t->string('format'); $t->string('label'); }); - Schema::create('currencies', function($t) - { + Schema::create('currencies', function ($t) { $t->increments('id'); $t->string('name'); @@ -109,20 +102,17 @@ class ConfideSetupUsersTable extends Migration { $t->string('code'); }); - Schema::create('sizes', function($t) - { + Schema::create('sizes', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('industries', function($t) - { + Schema::create('industries', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('accounts', function($t) - { + Schema::create('accounts', function ($t) { $t->increments('id'); $t->unsignedInteger('timezone_id')->nullable(); $t->unsignedInteger('date_format_id')->nullable(); @@ -160,8 +150,7 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('size_id')->references('id')->on('sizes'); }); - Schema::create('gateways', function($t) - { + Schema::create('gateways', function ($t) { $t->increments('id'); $t->timestamps(); @@ -170,8 +159,7 @@ class ConfideSetupUsersTable extends Migration { $t->boolean('visible')->default(true); }); - Schema::create('users', function($t) - { + Schema::create('users', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id')->index(); $t->timestamps(); @@ -195,11 +183,10 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $t->unsignedInteger('public_id')->nullable(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('account_gateways', function($t) - { + Schema::create('account_gateways', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id'); $t->unsignedInteger('user_id'); @@ -214,20 +201,18 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('password_reminders', function($t) - { + Schema::create('password_reminders', function ($t) { $t->string('email'); $t->timestamps(); $t->string('token'); }); - Schema::create('clients', function($t) - { + Schema::create('clients', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); @@ -261,11 +246,10 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('currency_id')->references('id')->on('currencies'); $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('contacts', function($t) - { + Schema::create('contacts', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id'); $t->unsignedInteger('user_id'); @@ -282,26 +266,24 @@ class ConfideSetupUsersTable extends Migration { $t->timestamp('last_login')->nullable(); $t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->unsignedInteger('public_id')->nullable(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('invoice_statuses', function($t) - { + Schema::create('invoice_statuses', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('frequencies', function($t) - { + Schema::create('frequencies', function ($t) { $t->increments('id'); $t->string('name'); }); - Schema::create('invoices', function($t) - { + Schema::create('invoices', function ($t) { $t->increments('id'); $t->unsignedInteger('client_id')->index(); $t->unsignedInteger('user_id'); @@ -338,13 +320,12 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('recurring_invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); - $t->unique( array('account_id','invoice_number') ); + $t->unique(array('account_id','public_id')); + $t->unique(array('account_id','invoice_number')); }); - Schema::create('invitations', function($t) - { + Schema::create('invitations', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id'); $t->unsignedInteger('user_id'); @@ -358,16 +339,16 @@ class ConfideSetupUsersTable extends Migration { $t->timestamp('sent_date')->nullable(); $t->timestamp('viewed_date')->nullable(); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('tax_rates', function($t) - { + Schema::create('tax_rates', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id')->index(); $t->unsignedInteger('user_id'); @@ -378,14 +359,14 @@ class ConfideSetupUsersTable extends Migration { $t->decimal('rate', 13, 3); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->unsignedInteger('public_id'); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('products', function($t) - { + Schema::create('products', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id')->index(); $t->unsignedInteger('user_id'); @@ -398,15 +379,15 @@ class ConfideSetupUsersTable extends Migration { $t->decimal('qty', 13, 2)->nullable(); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->unsignedInteger('public_id'); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('invoice_items', function($t) - { + Schema::create('invoice_items', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id'); $t->unsignedInteger('user_id'); @@ -425,14 +406,14 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); $t->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->unsignedInteger('public_id'); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('payments', function($t) - { + Schema::create('payments', function ($t) { $t->increments('id'); $t->unsignedInteger('invoice_id')->index(); $t->unsignedInteger('account_id')->index(); @@ -456,15 +437,15 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); $t->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $t->foreign('account_gateway_id')->references('id')->on('account_gateways')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->foreign('payment_type_id')->references('id')->on('payment_types'); $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('credits', function($t) - { + Schema::create('credits', function ($t) { $t->increments('id'); $t->unsignedInteger('account_id')->index(); $t->unsignedInteger('client_id')->index(); @@ -481,14 +462,14 @@ class ConfideSetupUsersTable extends Migration { $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');; + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + ; $t->unsignedInteger('public_id')->index(); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('activities', function($t) - { + Schema::create('activities', function ($t) { $t->increments('id'); $t->timestamps(); diff --git a/database/migrations/2013_11_28_195703_setup_countries_table.php b/database/migrations/2013_11_28_195703_setup_countries_table.php index 09e8c8eca2..e6528c3d9b 100644 --- a/database/migrations/2013_11_28_195703_setup_countries_table.php +++ b/database/migrations/2013_11_28_195703_setup_countries_table.php @@ -1,47 +1,47 @@ integer('id')->index(); - $table->string('capital', 255)->nullable(); - $table->string('citizenship', 255)->nullable(); - $table->string('country_code', 3)->default(''); - $table->string('currency', 255)->nullable(); - $table->string('currency_code', 255)->nullable(); - $table->string('currency_sub_unit', 255)->nullable(); - $table->string('full_name', 255)->nullable(); - $table->string('iso_3166_2', 2)->default(''); - $table->string('iso_3166_3', 3)->default(''); - $table->string('name', 255)->default(''); - $table->string('region_code', 3)->default(''); - $table->string('sub_region_code', 3)->default(''); - $table->boolean('eea')->default(0); - - $table->primary('id'); - }); - */ - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + // Creates the users table + /* + Schema::create('countries', function($table) + { + $table->integer('id')->index(); + $table->string('capital', 255)->nullable(); + $table->string('citizenship', 255)->nullable(); + $table->string('country_code', 3)->default(''); + $table->string('currency', 255)->nullable(); + $table->string('currency_code', 255)->nullable(); + $table->string('currency_sub_unit', 255)->nullable(); + $table->string('full_name', 255)->nullable(); + $table->string('iso_3166_2', 2)->default(''); + $table->string('iso_3166_3', 3)->default(''); + $table->string('name', 255)->default(''); + $table->string('region_code', 3)->default(''); + $table->string('sub_region_code', 3)->default(''); + $table->boolean('eea')->default(0); - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - //Schema::drop('countries'); - } + $table->primary('id'); + }); + */ + } -} \ No newline at end of file + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + //Schema::drop('countries'); + } +} diff --git a/database/migrations/2014_02_13_151500_add_cascase_drops.php b/database/migrations/2014_02_13_151500_add_cascase_drops.php index 66d362317d..5a99eb6f15 100644 --- a/database/migrations/2014_02_13_151500_add_cascase_drops.php +++ b/database/migrations/2014_02_13_151500_add_cascase_drops.php @@ -3,30 +3,28 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCascaseDrops extends Migration { +class AddCascaseDrops extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoices', function($table) - { - $table->dropForeign('invoices_account_id_foreign'); - $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoices', function ($table) { + $table->dropForeign('invoices_account_id_foreign'); + $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } } diff --git a/database/migrations/2014_02_19_151817_add_support_for_invoice_designs.php b/database/migrations/2014_02_19_151817_add_support_for_invoice_designs.php index 4bd8daf912..dfb6bc108d 100644 --- a/database/migrations/2014_02_19_151817_add_support_for_invoice_designs.php +++ b/database/migrations/2014_02_19_151817_add_support_for_invoice_designs.php @@ -3,70 +3,63 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddSupportForInvoiceDesigns extends Migration { +class AddSupportForInvoiceDesigns extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('invoice_designs', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $table->increments('id'); - $table->string('name'); - }); + Schema::create('invoice_designs', function ($table) { + $table->increments('id'); + $table->string('name'); + }); - DB::table('invoice_designs')->insert(['name' => 'Clean']); - DB::table('invoice_designs')->insert(['name' => 'Bold']); - DB::table('invoice_designs')->insert(['name' => 'Modern']); - DB::table('invoice_designs')->insert(['name' => 'Plain']); + DB::table('invoice_designs')->insert(['name' => 'Clean']); + DB::table('invoice_designs')->insert(['name' => 'Bold']); + DB::table('invoice_designs')->insert(['name' => 'Modern']); + DB::table('invoice_designs')->insert(['name' => 'Plain']); - Schema::table('invoices', function($table) - { - $table->unsignedInteger('invoice_design_id')->default(1); - }); + Schema::table('invoices', function ($table) { + $table->unsignedInteger('invoice_design_id')->default(1); + }); - Schema::table('accounts', function($table) - { - $table->unsignedInteger('invoice_design_id')->default(1); - }); + Schema::table('accounts', function ($table) { + $table->unsignedInteger('invoice_design_id')->default(1); + }); - DB::table('invoices')->update(['invoice_design_id' => 1]); - DB::table('accounts')->update(['invoice_design_id' => 1]); + DB::table('invoices')->update(['invoice_design_id' => 1]); + DB::table('accounts')->update(['invoice_design_id' => 1]); - Schema::table('invoices', function($table) - { - $table->foreign('invoice_design_id')->references('id')->on('invoice_designs'); - }); - - Schema::table('accounts', function($table) - { - $table->foreign('invoice_design_id')->references('id')->on('invoice_designs'); - }); - } + Schema::table('invoices', function ($table) { + $table->foreign('invoice_design_id')->references('id')->on('invoice_designs'); + }); + + Schema::table('accounts', function ($table) { + $table->foreign('invoice_design_id')->references('id')->on('invoice_designs'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) - { - $table->dropForeign('invoices_invoice_design_id_foreign'); - $table->dropColumn('invoice_design_id'); - }); + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { + $table->dropForeign('invoices_invoice_design_id_foreign'); + $table->dropColumn('invoice_design_id'); + }); - Schema::table('accounts', function($table) - { - $table->dropForeign('accounts_invoice_design_id_foreign'); - $table->dropColumn('invoice_design_id'); - }); - - Schema::dropIfExists('invoice_designs'); - } + Schema::table('accounts', function ($table) { + $table->dropForeign('accounts_invoice_design_id_foreign'); + $table->dropColumn('invoice_design_id'); + }); + Schema::dropIfExists('invoice_designs'); + } } diff --git a/database/migrations/2014_03_03_155556_add_phone_to_account.php b/database/migrations/2014_03_03_155556_add_phone_to_account.php index 79e03e9d18..202994b47a 100644 --- a/database/migrations/2014_03_03_155556_add_phone_to_account.php +++ b/database/migrations/2014_03_03_155556_add_phone_to_account.php @@ -3,34 +3,32 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddPhoneToAccount extends Migration { +class AddPhoneToAccount extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('work_phone')->nullable(); - $table->string('work_email')->nullable(); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('work_phone')->nullable(); + $table->string('work_email')->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('work_phone'); - $table->dropColumn('work_email'); - }); - } - -} \ No newline at end of file + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('work_phone'); + $table->dropColumn('work_email'); + }); + } +} diff --git a/database/migrations/2014_03_19_201454_add_language_support.php b/database/migrations/2014_03_19_201454_add_language_support.php index 97bb13fc5b..b9db4e33a1 100644 --- a/database/migrations/2014_03_19_201454_add_language_support.php +++ b/database/migrations/2014_03_19_201454_add_language_support.php @@ -3,21 +3,21 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddLanguageSupport extends Migration { +class AddLanguageSupport extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('languages', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $table->increments('id'); - $table->string('name'); - $table->string('locale'); - }); + Schema::create('languages', function ($table) { + $table->increments('id'); + $table->string('name'); + $table->string('locale'); + }); //DB::table('languages')->insert(['name' => 'English', 'locale' => 'en']); //DB::table('languages')->insert(['name' => 'Italian', 'locale' => 'it']); @@ -28,33 +28,29 @@ class AddLanguageSupport extends Migration { //DB::table('languages')->insert(['name' => 'Spanish', 'locale' => 'es']); //DB::table('languages')->insert(['name' => 'Norwegian', 'locale' => 'nb_NO']); - Schema::table('accounts', function($table) - { - $table->unsignedInteger('language_id')->default(1); - }); + Schema::table('accounts', function ($table) { + $table->unsignedInteger('language_id')->default(1); + }); - DB::table('accounts')->update(['language_id' => 1]); + DB::table('accounts')->update(['language_id' => 1]); - Schema::table('accounts', function($table) - { - $table->foreign('language_id')->references('id')->on('languages'); - }); - } + Schema::table('accounts', function ($table) { + $table->foreign('language_id')->references('id')->on('languages'); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropForeign('accounts_language_id_foreign'); - $table->dropColumn('language_id'); - }); - - Schema::drop('languages'); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropForeign('accounts_language_id_foreign'); + $table->dropColumn('language_id'); + }); + Schema::drop('languages'); + } } diff --git a/database/migrations/2014_03_20_200300_create_payment_libraries.php b/database/migrations/2014_03_20_200300_create_payment_libraries.php index dc8074c913..c8c689d036 100644 --- a/database/migrations/2014_03_20_200300_create_payment_libraries.php +++ b/database/migrations/2014_03_20_200300_create_payment_libraries.php @@ -3,56 +3,51 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreatePaymentLibraries extends Migration { +class CreatePaymentLibraries extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::dropIfExists('payment_libraries'); - - Schema::create('payment_libraries', function($t) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $t->increments('id'); - $t->timestamps(); + Schema::dropIfExists('payment_libraries'); - $t->string('name'); - $t->boolean('visible')->default(true); - }); + Schema::create('payment_libraries', function ($t) { + $t->increments('id'); + $t->timestamps(); - Schema::table('gateways', function($table) - { - $table->unsignedInteger('payment_library_id')->default(1); - }); + $t->string('name'); + $t->boolean('visible')->default(true); + }); - DB::table('gateways')->update(['payment_library_id' => 1]); + Schema::table('gateways', function ($table) { + $table->unsignedInteger('payment_library_id')->default(1); + }); - Schema::table('gateways', function($table) - { - $table->foreign('payment_library_id')->references('id')->on('payment_libraries')->onDelete('cascade'); - }); - } + DB::table('gateways')->update(['payment_library_id' => 1]); - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - if (Schema::hasColumn('gateways', 'payment_library_id')) - { - Schema::table('gateways', function($table) - { - $table->dropForeign('gateways_payment_library_id_foreign'); - $table->dropColumn('payment_library_id'); - }); - } + Schema::table('gateways', function ($table) { + $table->foreign('payment_library_id')->references('id')->on('payment_libraries')->onDelete('cascade'); + }); + } - Schema::dropIfExists('payment_libraries'); - } - -} \ No newline at end of file + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + if (Schema::hasColumn('gateways', 'payment_library_id')) { + Schema::table('gateways', function ($table) { + $table->dropForeign('gateways_payment_library_id_foreign'); + $table->dropColumn('payment_library_id'); + }); + } + + Schema::dropIfExists('payment_libraries'); + } +} diff --git a/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php b/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php index 30d7c664e4..2687a8ea38 100644 --- a/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php +++ b/database/migrations/2014_03_23_051736_enable_forcing_jspdf.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class EnableForcingJspdf extends Migration { +class EnableForcingJspdf extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('users', function($table) - { - $table->boolean('force_pdfjs')->default(false); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { - $table->dropColumn('force_pdfjs'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { + $table->boolean('force_pdfjs')->default(false); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { + $table->dropColumn('force_pdfjs'); + }); + } } diff --git a/database/migrations/2014_03_25_102200_add_sort_and_recommended_to_gateways.php b/database/migrations/2014_03_25_102200_add_sort_and_recommended_to_gateways.php index a49fe8f855..fbf9b65707 100644 --- a/database/migrations/2014_03_25_102200_add_sort_and_recommended_to_gateways.php +++ b/database/migrations/2014_03_25_102200_add_sort_and_recommended_to_gateways.php @@ -3,47 +3,41 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddSortAndRecommendedToGateways extends Migration { +class AddSortAndRecommendedToGateways extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('gateways', function($table) - { - $table->unsignedInteger('sort_order')->default(10000); - $table->boolean('recommended')->default(0); - $table->string('site_url', 200)->nullable(); - }); - } - - public function down() - { - if (Schema::hasColumn('gateways', 'sort_order')) - { - Schema::table('gateways', function($table) - { - $table->dropColumn('sort_order'); - }); - } - - if (Schema::hasColumn('gateways', 'recommended')) - { - Schema::table('gateways', function($table) - { - $table->dropColumn('recommended'); - }); - } - - if (Schema::hasColumn('gateways', 'site_url')) - { - Schema::table('gateways', function($table) - { - $table->dropColumn('site_url'); - }); - } - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('gateways', function ($table) { + $table->unsignedInteger('sort_order')->default(10000); + $table->boolean('recommended')->default(0); + $table->string('site_url', 200)->nullable(); + }); + } + + public function down() + { + if (Schema::hasColumn('gateways', 'sort_order')) { + Schema::table('gateways', function ($table) { + $table->dropColumn('sort_order'); + }); + } + + if (Schema::hasColumn('gateways', 'recommended')) { + Schema::table('gateways', function ($table) { + $table->dropColumn('recommended'); + }); + } + + if (Schema::hasColumn('gateways', 'site_url')) { + Schema::table('gateways', function ($table) { + $table->dropColumn('site_url'); + }); + } + } } diff --git a/database/migrations/2014_04_03_191105_add_pro_plan.php b/database/migrations/2014_04_03_191105_add_pro_plan.php index cbc714971f..f96245455f 100644 --- a/database/migrations/2014_04_03_191105_add_pro_plan.php +++ b/database/migrations/2014_04_03_191105_add_pro_plan.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddProPlan extends Migration { +class AddProPlan extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->date('pro_plan_paid')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('pro_plan_paid'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->date('pro_plan_paid')->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('pro_plan_paid'); + }); + } } diff --git a/database/migrations/2014_04_17_100523_add_remember_token.php b/database/migrations/2014_04_17_100523_add_remember_token.php index 6a43600107..1a6900ac96 100644 --- a/database/migrations/2014_04_17_100523_add_remember_token.php +++ b/database/migrations/2014_04_17_100523_add_remember_token.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddRememberToken extends Migration { +class AddRememberToken extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('users', function($table) - { - $table->string('remember_token', 100)->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { - $table->dropColumn('remember_token'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { + $table->string('remember_token', 100)->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { + $table->dropColumn('remember_token'); + }); + } } diff --git a/database/migrations/2014_04_17_145108_add_custom_fields.php b/database/migrations/2014_04_17_145108_add_custom_fields.php index f6ff7c8f45..5864388340 100644 --- a/database/migrations/2014_04_17_145108_add_custom_fields.php +++ b/database/migrations/2014_04_17_145108_add_custom_fields.php @@ -3,58 +3,54 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCustomFields extends Migration { +class AddCustomFields extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('custom_label1')->nullable(); - $table->string('custom_value1')->nullable(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('custom_label1')->nullable(); + $table->string('custom_value1')->nullable(); - $table->string('custom_label2')->nullable(); - $table->string('custom_value2')->nullable(); + $table->string('custom_label2')->nullable(); + $table->string('custom_value2')->nullable(); - $table->string('custom_client_label1')->nullable(); - $table->string('custom_client_label2')->nullable(); - }); + $table->string('custom_client_label1')->nullable(); + $table->string('custom_client_label2')->nullable(); + }); - Schema::table('clients', function($table) - { - $table->string('custom_value1')->nullable(); - $table->string('custom_value2')->nullable(); - }); - } + Schema::table('clients', function ($table) { + $table->string('custom_value1')->nullable(); + $table->string('custom_value2')->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('custom_label1'); - $table->dropColumn('custom_value1'); + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('custom_label1'); + $table->dropColumn('custom_value1'); - $table->dropColumn('custom_label2'); - $table->dropColumn('custom_value2'); + $table->dropColumn('custom_label2'); + $table->dropColumn('custom_value2'); - $table->dropColumn('custom_client_label1'); - $table->dropColumn('custom_client_label2'); - }); - - Schema::table('clients', function($table) - { - $table->dropColumn('custom_value1'); - $table->dropColumn('custom_value2'); - }); - } + $table->dropColumn('custom_client_label1'); + $table->dropColumn('custom_client_label2'); + }); + Schema::table('clients', function ($table) { + $table->dropColumn('custom_value1'); + $table->dropColumn('custom_value2'); + }); + } } diff --git a/database/migrations/2014_04_23_170909_add_products_settings.php b/database/migrations/2014_04_23_170909_add_products_settings.php index a5e5541177..5d758f4db8 100644 --- a/database/migrations/2014_04_23_170909_add_products_settings.php +++ b/database/migrations/2014_04_23_170909_add_products_settings.php @@ -3,37 +3,35 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddProductsSettings extends Migration { +class AddProductsSettings extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->boolean('fill_products')->default(true); - $table->boolean('update_products')->default(true); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->boolean('fill_products')->default(true); + $table->boolean('update_products')->default(true); + }); - DB::table('accounts')->update(['fill_products' => true]); - DB::table('accounts')->update(['update_products' => true]); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('fill_products'); - $table->dropColumn('update_products'); - }); - } + DB::table('accounts')->update(['fill_products' => true]); + DB::table('accounts')->update(['update_products' => true]); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('fill_products'); + $table->dropColumn('update_products'); + }); + } } diff --git a/database/migrations/2014_04_29_174315_add_advanced_settings.php b/database/migrations/2014_04_29_174315_add_advanced_settings.php index ae91740d21..3cb9714bc7 100644 --- a/database/migrations/2014_04_29_174315_add_advanced_settings.php +++ b/database/migrations/2014_04_29_174315_add_advanced_settings.php @@ -3,40 +3,37 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddAdvancedSettings extends Migration { +class AddAdvancedSettings extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('primary_color')->nullable(); - $table->string('secondary_color')->nullable(); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('primary_color')->nullable(); + $table->string('secondary_color')->nullable(); + }); - Schema::table('payments', function($table) - { - $table->dropForeign('payments_invoice_id_foreign'); - $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('primary_color'); - $table->dropColumn('secondary_color'); - }); - } + Schema::table('payments', function ($table) { + $table->dropForeign('payments_invoice_id_foreign'); + $table->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('primary_color'); + $table->dropColumn('secondary_color'); + }); + } } diff --git a/database/migrations/2014_05_17_175626_add_quotes.php b/database/migrations/2014_05_17_175626_add_quotes.php index a75ca8ba76..4bc605890e 100644 --- a/database/migrations/2014_05_17_175626_add_quotes.php +++ b/database/migrations/2014_05_17_175626_add_quotes.php @@ -3,36 +3,34 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddQuotes extends Migration { +class AddQuotes extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoices', function($table) - { - $table->boolean('invoice_type_id')->default(0); - $table->unsignedInteger('quote_id')->nullable(); - $table->unsignedInteger('quote_invoice_id')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) - { - $table->dropColumn('invoice_type_id'); - $table->dropColumn('quote_id'); - $table->dropColumn('quote_invoice_id'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoices', function ($table) { + $table->boolean('invoice_type_id')->default(0); + $table->unsignedInteger('quote_id')->nullable(); + $table->unsignedInteger('quote_invoice_id')->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { + $table->dropColumn('invoice_type_id'); + $table->dropColumn('quote_id'); + $table->dropColumn('quote_invoice_id'); + }); + } } diff --git a/database/migrations/2014_06_17_131940_add_accepted_credit_cards_to_account_gateways.php b/database/migrations/2014_06_17_131940_add_accepted_credit_cards_to_account_gateways.php index dfcbdc9055..097fcdd136 100644 --- a/database/migrations/2014_06_17_131940_add_accepted_credit_cards_to_account_gateways.php +++ b/database/migrations/2014_06_17_131940_add_accepted_credit_cards_to_account_gateways.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddAcceptedCreditCardsToAccountGateways extends Migration { +class AddAcceptedCreditCardsToAccountGateways extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('account_gateways', function($table) - { - $table->unsignedInteger('accepted_credit_cards')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('account_gateways', function($table) - { - $table->dropColumn('accepted_credit_cards'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('account_gateways', function ($table) { + $table->unsignedInteger('accepted_credit_cards')->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('account_gateways', function ($table) { + $table->dropColumn('accepted_credit_cards'); + }); + } } diff --git a/database/migrations/2014_07_13_142654_one_click_install.php b/database/migrations/2014_07_13_142654_one_click_install.php index 943117bed3..4956533f38 100644 --- a/database/migrations/2014_07_13_142654_one_click_install.php +++ b/database/migrations/2014_07_13_142654_one_click_install.php @@ -3,56 +3,54 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class OneClickInstall extends Migration { +class OneClickInstall extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('affiliates', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); + Schema::create('affiliates', function ($table) { + $table->increments('id'); + $table->timestamps(); + $table->softDeletes(); - $table->string('name'); - $table->string('affiliate_key')->unique(); + $table->string('name'); + $table->string('affiliate_key')->unique(); - $table->text('payment_title'); - $table->text('payment_subtitle'); - }); + $table->text('payment_title'); + $table->text('payment_subtitle'); + }); - Schema::create('licenses', function($table) - { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->unsignedInteger('affiliate_id'); + Schema::create('licenses', function ($table) { + $table->increments('id'); + $table->timestamps(); + $table->softDeletes(); + $table->unsignedInteger('affiliate_id'); - $table->string('first_name'); - $table->string('last_name'); - $table->string('email'); + $table->string('first_name'); + $table->string('last_name'); + $table->string('email'); - $table->string('license_key')->unique(); - $table->boolean('is_claimed'); - $table->string('transaction_reference'); + $table->string('license_key')->unique(); + $table->boolean('is_claimed'); + $table->string('transaction_reference'); - $table->foreign('affiliate_id')->references('id')->on('affiliates'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('licenses'); - Schema::dropIfExists('affiliates'); - } + $table->foreign('affiliate_id')->references('id')->on('affiliates'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('licenses'); + Schema::dropIfExists('affiliates'); + } } diff --git a/database/migrations/2014_07_17_205900_support_hiding_quantity.php b/database/migrations/2014_07_17_205900_support_hiding_quantity.php index c7104ef88c..5721888c23 100644 --- a/database/migrations/2014_07_17_205900_support_hiding_quantity.php +++ b/database/migrations/2014_07_17_205900_support_hiding_quantity.php @@ -3,64 +3,60 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class SupportHidingQuantity extends Migration { +class SupportHidingQuantity extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->boolean('hide_quantity')->default(0); - $table->boolean('hide_paid_to_date')->default(0); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->boolean('hide_quantity')->default(0); + $table->boolean('hide_paid_to_date')->default(0); - $table->string('custom_invoice_label1')->nullable(); - $table->string('custom_invoice_label2')->nullable(); + $table->string('custom_invoice_label1')->nullable(); + $table->string('custom_invoice_label2')->nullable(); - $table->boolean('custom_invoice_taxes1')->nullable(); - $table->boolean('custom_invoice_taxes2')->nullable(); - }); + $table->boolean('custom_invoice_taxes1')->nullable(); + $table->boolean('custom_invoice_taxes2')->nullable(); + }); - Schema::table('invoices', function($table) - { - $table->decimal('custom_value1', 13, 2)->default(0); - $table->decimal('custom_value2', 13, 2)->default(0); + Schema::table('invoices', function ($table) { + $table->decimal('custom_value1', 13, 2)->default(0); + $table->decimal('custom_value2', 13, 2)->default(0); - $table->boolean('custom_taxes1')->default(0); - $table->boolean('custom_taxes2')->default(0); - }); - } + $table->boolean('custom_taxes1')->default(0); + $table->boolean('custom_taxes2')->default(0); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('hide_quantity'); - $table->dropColumn('hide_paid_to_date'); + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('hide_quantity'); + $table->dropColumn('hide_paid_to_date'); - $table->dropColumn('custom_invoice_label1'); - $table->dropColumn('custom_invoice_label2'); + $table->dropColumn('custom_invoice_label1'); + $table->dropColumn('custom_invoice_label2'); - $table->dropColumn('custom_invoice_taxes1'); - $table->dropColumn('custom_invoice_taxes2'); - }); - - Schema::table('invoices', function($table) - { - $table->dropColumn('custom_value1'); - $table->dropColumn('custom_value2'); - - $table->dropColumn('custom_taxes1'); - $table->dropColumn('custom_taxes2'); - }); - } + $table->dropColumn('custom_invoice_taxes1'); + $table->dropColumn('custom_invoice_taxes2'); + }); + + Schema::table('invoices', function ($table) { + $table->dropColumn('custom_value1'); + $table->dropColumn('custom_value2'); + $table->dropColumn('custom_taxes1'); + $table->dropColumn('custom_taxes2'); + }); + } } diff --git a/database/migrations/2014_07_24_171214_add_zapier_support.php b/database/migrations/2014_07_24_171214_add_zapier_support.php index 3c8fbe6982..093a502b5b 100644 --- a/database/migrations/2014_07_24_171214_add_zapier_support.php +++ b/database/migrations/2014_07_24_171214_add_zapier_support.php @@ -3,39 +3,37 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddZapierSupport extends Migration { +class AddZapierSupport extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('subscriptions', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $table->increments('id'); - $table->unsignedInteger('account_id')->nullable(); + Schema::create('subscriptions', function ($table) { + $table->increments('id'); + $table->unsignedInteger('account_id')->nullable(); - $table->timestamps(); - $table->softDeletes(); + $table->timestamps(); + $table->softDeletes(); - $table->unsignedInteger('event_id')->nullable(); - $table->string('target_url'); + $table->unsignedInteger('event_id')->nullable(); + $table->string('target_url'); - $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('subscriptions'); - } + $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('subscriptions'); + } } diff --git a/database/migrations/2014_10_01_141248_add_company_vat_number.php b/database/migrations/2014_10_01_141248_add_company_vat_number.php index 4222b2ee15..dca2053a2a 100644 --- a/database/migrations/2014_10_01_141248_add_company_vat_number.php +++ b/database/migrations/2014_10_01_141248_add_company_vat_number.php @@ -3,42 +3,38 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCompanyVatNumber extends Migration { +class AddCompanyVatNumber extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('vat_number')->nullable(); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('vat_number')->nullable(); + }); - Schema::table('clients', function($table) - { - $table->string('vat_number')->nullable(); - }); - } + Schema::table('clients', function ($table) { + $table->string('vat_number')->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('vat_number'); - }); - - Schema::table('clients', function($table) - { - $table->dropColumn('vat_number'); - }); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('vat_number'); + }); + Schema::table('clients', function ($table) { + $table->dropColumn('vat_number'); + }); + } } diff --git a/database/migrations/2014_10_05_141856_track_last_seen_message.php b/database/migrations/2014_10_05_141856_track_last_seen_message.php index 7446782a6a..b4b401a956 100644 --- a/database/migrations/2014_10_05_141856_track_last_seen_message.php +++ b/database/migrations/2014_10_05_141856_track_last_seen_message.php @@ -3,44 +3,42 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class TrackLastSeenMessage extends Migration { +class TrackLastSeenMessage extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('users', function($table) - { - $table->unsignedInteger('news_feed_id')->nullable(); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { + $table->unsignedInteger('news_feed_id')->nullable(); + }); - if (DB::table('payment_libraries')->count() > 0) { - DB::table('gateways')->update(['recommended' => 0]); - DB::table('gateways')->insert([ - 'name' => 'moolah', - 'provider' => 'AuthorizeNet_AIM', - 'sort_order' => 1, - 'recommended' => 1, - 'site_url' => 'https://invoiceninja.mymoolah.com/', - 'payment_library_id' => 1 - ]); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { - $table->dropColumn('news_feed_id'); - }); - } + if (DB::table('payment_libraries')->count() > 0) { + DB::table('gateways')->update(['recommended' => 0]); + DB::table('gateways')->insert([ + 'name' => 'moolah', + 'provider' => 'AuthorizeNet_AIM', + 'sort_order' => 1, + 'recommended' => 1, + 'site_url' => 'https://invoiceninja.mymoolah.com/', + 'payment_library_id' => 1 + ]); + } + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { + $table->dropColumn('news_feed_id'); + }); + } } diff --git a/database/migrations/2014_10_06_103529_add_timesheets.php b/database/migrations/2014_10_06_103529_add_timesheets.php index 61f8b842f3..d3dd854115 100644 --- a/database/migrations/2014_10_06_103529_add_timesheets.php +++ b/database/migrations/2014_10_06_103529_add_timesheets.php @@ -3,16 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddTimesheets extends Migration { +class AddTimesheets extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('projects', function($t) { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('projects', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); @@ -24,12 +25,12 @@ class AddTimesheets extends Migration { $t->string('description'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('account_id')->references('id')->on('accounts'); - $t->unique( array('account_id','name') ); + $t->unique(array('account_id','name')); }); - Schema::create('project_codes', function($t) { + Schema::create('project_codes', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); @@ -41,14 +42,14 @@ class AddTimesheets extends Migration { $t->string('description'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('account_id')->references('id')->on('accounts'); $t->foreign('project_id')->references('id')->on('projects')->onDelete('cascade'); - $t->unique( array('account_id','name') ); + $t->unique(array('account_id','name')); }); - Schema::create('timesheets', function($t) { + Schema::create('timesheets', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); @@ -65,10 +66,10 @@ class AddTimesheets extends Migration { $t->foreign('account_id')->references('id')->on('accounts'); $t->unsignedInteger('public_id'); - $t->unique( array('account_id','public_id') ); + $t->unique(array('account_id','public_id')); }); - Schema::create('timesheet_event_sources', function($t) { + Schema::create('timesheet_event_sources', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); @@ -83,18 +84,18 @@ class AddTimesheets extends Migration { $t->dateTime('from_date')->nullable(); $t->dateTime('to_date')->nullable(); - $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('account_id')->references('id')->on('accounts'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); }); - Schema::create('timesheet_events', function($t) { + Schema::create('timesheet_events', function ($t) { $t->increments('id'); $t->unsignedInteger('user_id'); $t->unsignedInteger('account_id')->index(); $t->unsignedInteger('timesheet_event_source_id'); $t->unsignedInteger('timesheet_id')->nullable()->index(); $t->unsignedInteger('project_id')->nullable()->index(); - $t->unsignedInteger('project_code_id')->nullable()->index(); + $t->unsignedInteger('project_code_id')->nullable()->index(); $t->timestamps(); $t->softDeletes(); @@ -127,26 +128,25 @@ class AddTimesheets extends Migration { $t->text('updated_data')->nullable(); $t->timeStamp('updated_data_at')->default('0000-00-00T00:00:00'); - $t->foreign('account_id')->references('id')->on('accounts'); + $t->foreign('account_id')->references('id')->on('accounts'); $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $t->foreign('timesheet_event_source_id')->references('id')->on('timesheet_event_sources')->onDelete('cascade'); - $t->unique( array('timesheet_event_source_id', 'uid') ); + $t->unique(array('timesheet_event_source_id', 'uid')); }); } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::dropIfExists('timesheet_events'); Schema::dropIfExists('timesheet_event_sources'); Schema::dropIfExists('timesheets'); Schema::dropIfExists('project_codes'); Schema::dropIfExists('projects'); - } - + } } diff --git a/database/migrations/2014_10_06_195330_add_invoice_design_table.php b/database/migrations/2014_10_06_195330_add_invoice_design_table.php index 582b59a09d..1c06fd4d76 100644 --- a/database/migrations/2014_10_06_195330_add_invoice_design_table.php +++ b/database/migrations/2014_10_06_195330_add_invoice_design_table.php @@ -3,27 +3,26 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddInvoiceDesignTable extends Migration { +class AddInvoiceDesignTable extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoice_designs', function($table) - { - $table->mediumText('javascript')->nullable(); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoice_designs', function ($table) { + $table->mediumText('javascript')->nullable(); + }); - Schema::table('accounts', function($table) - { - $table->text('invoice_design')->nullable(); - }); + Schema::table('accounts', function ($table) { + $table->text('invoice_design')->nullable(); + }); - DB::table('invoice_designs')->where('id', 1)->update([ - 'javascript' => "var GlobalY=0;//Y position of line at current page + DB::table('invoice_designs')->where('id', 1)->update([ + 'javascript' => "var GlobalY=0;//Y position of line at current page var client = invoice.client; var account = invoice.account; @@ -114,10 +113,10 @@ class AddInvoiceDesignTable extends Migration { headerLeft=layout.headerRight+400; var AmountX = layout.lineTotalRight - (doc.getStringUnitWidth(AmountText) * doc.internal.getFontSize()); doc.text(AmountX, y, AmountText);" - ]); + ]); - DB::table('invoice_designs')->where('id', 2)->update([ - 'javascript' => " var GlobalY=0;//Y position of line at current page + DB::table('invoice_designs')->where('id', 2)->update([ + 'javascript' => " var GlobalY=0;//Y position of line at current page var client = invoice.client; var account = invoice.account; @@ -264,10 +263,10 @@ class AddInvoiceDesignTable extends Migration { var AmountX = headerLeft - (doc.getStringUnitWidth(AmountText) * doc.internal.getFontSize()); SetPdfColor('SomeGreen', doc, 'secondary'); doc.text(AmountX, y, AmountText);" - ]); + ]); - DB::table('invoice_designs')->where('id', 3)->update([ - 'javascript' => " var client = invoice.client; + DB::table('invoice_designs')->where('id', 3)->update([ + 'javascript' => " var client = invoice.client; var account = invoice.account; var currencyId = client.currency_id; @@ -415,10 +414,10 @@ class AddInvoiceDesignTable extends Migration { headerLeft=layout.headerRight+400; var amountX = layout.lineTotalRight - (doc.getStringUnitWidth(amount) * doc.internal.getFontSize()); doc.text(amountX, y+2, amount);" - ]); + ]); - DB::table('invoice_designs')->where('id', 4)->update([ - 'javascript' => " var client = invoice.client; + DB::table('invoice_designs')->where('id', 4)->update([ + 'javascript' => " var client = invoice.client; var account = invoice.account; var currencyId = client.currency_id; @@ -492,28 +491,23 @@ class AddInvoiceDesignTable extends Migration { doc.setFontType('normal'); doc.text(layout.marginLeft, 790, 'Created by InvoiceNinja.com'); }" - - ]); + + ]); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoice_designs', function ($table) { + $table->dropColumn('javascript'); + }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoice_designs', function($table) - { - $table->dropColumn('javascript'); - }); - - Schema::table('accounts', function($table) - { - $table->dropColumn('invoice_design'); - }); - } - + Schema::table('accounts', function ($table) { + $table->dropColumn('invoice_design'); + }); + } } diff --git a/database/migrations/2014_10_13_054100_add_invoice_number_settings.php b/database/migrations/2014_10_13_054100_add_invoice_number_settings.php index 6d8d276858..0f3dce0ecd 100644 --- a/database/migrations/2014_10_13_054100_add_invoice_number_settings.php +++ b/database/migrations/2014_10_13_054100_add_invoice_number_settings.php @@ -3,61 +3,57 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddInvoiceNumberSettings extends Migration { +class AddInvoiceNumberSettings extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('invoice_number_prefix')->nullable(); - $table->integer('invoice_number_counter')->default(1)->nullable(); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('invoice_number_prefix')->nullable(); + $table->integer('invoice_number_counter')->default(1)->nullable(); - $table->string('quote_number_prefix')->nullable(); - $table->integer('quote_number_counter')->default(1)->nullable(); + $table->string('quote_number_prefix')->nullable(); + $table->integer('quote_number_counter')->default(1)->nullable(); - $table->boolean('share_counter')->default(true); - }); + $table->boolean('share_counter')->default(true); + }); - // set initial counter value for accounts with invoices + // set initial counter value for accounts with invoices $accounts = DB::table('accounts')->lists('id'); - foreach ($accounts as $accountId) { - - $invoiceNumbers = DB::table('invoices')->where('account_id', $accountId)->lists('invoice_number'); - $max = 0; + foreach ($accounts as $accountId) { + $invoiceNumbers = DB::table('invoices')->where('account_id', $accountId)->lists('invoice_number'); + $max = 0; - foreach ($invoiceNumbers as $invoiceNumber) { - $number = intval(preg_replace('/[^0-9]/', '', $invoiceNumber)); - $max = max($max, $number); - } + foreach ($invoiceNumbers as $invoiceNumber) { + $number = intval(preg_replace('/[^0-9]/', '', $invoiceNumber)); + $max = max($max, $number); + } - DB::table('accounts')->where('id', $accountId)->update(['invoice_number_counter' => ++$max]); - } - } + DB::table('accounts')->where('id', $accountId)->update(['invoice_number_counter' => ++$max]); + } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('invoice_number_prefix'); - $table->dropColumn('invoice_number_counter'); + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('invoice_number_prefix'); + $table->dropColumn('invoice_number_counter'); - $table->dropColumn('quote_number_prefix'); - $table->dropColumn('quote_number_counter'); - - $table->dropColumn('share_counter'); - }); - - } + $table->dropColumn('quote_number_prefix'); + $table->dropColumn('quote_number_counter'); + $table->dropColumn('share_counter'); + }); + } } diff --git a/database/migrations/2014_10_14_225227_add_danish_translation.php b/database/migrations/2014_10_14_225227_add_danish_translation.php index 6da361b2a3..044d46036a 100644 --- a/database/migrations/2014_10_14_225227_add_danish_translation.php +++ b/database/migrations/2014_10_14_225227_add_danish_translation.php @@ -3,27 +3,27 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddDanishTranslation extends Migration { +class AddDanishTranslation extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - //DB::table('languages')->insert(['name' => 'Danish', 'locale' => 'da']); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + //DB::table('languages')->insert(['name' => 'Danish', 'locale' => 'da']); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { //$language = \App\Models\Language::whereLocale('da')->first(); - //$language->delete(); - } - + //$language->delete(); + } } diff --git a/database/migrations/2014_10_22_174452_add_affiliate_price.php b/database/migrations/2014_10_22_174452_add_affiliate_price.php index 305ad1f421..035cd798dd 100644 --- a/database/migrations/2014_10_22_174452_add_affiliate_price.php +++ b/database/migrations/2014_10_22_174452_add_affiliate_price.php @@ -3,42 +3,38 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddAffiliatePrice extends Migration { +class AddAffiliatePrice extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('affiliates', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - $table->decimal('price', 7, 2)->nullable(); - }); + Schema::table('affiliates', function ($table) { + $table->decimal('price', 7, 2)->nullable(); + }); - Schema::table('licenses', function($table) - { - $table->unsignedInteger('product_id')->nullable(); - }); - } + Schema::table('licenses', function ($table) { + $table->unsignedInteger('product_id')->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('affiliates', function($table) + /** + * Reverse the migrations. + * + * @return void + */ + public function down() { - $table->dropColumn('price'); - }); + Schema::table('affiliates', function ($table) { + $table->dropColumn('price'); + }); - Schema::table('licenses', function($table) - { - $table->dropColumn('product_id'); - }); - } - + Schema::table('licenses', function ($table) { + $table->dropColumn('product_id'); + }); + } } diff --git a/database/migrations/2014_10_30_184126_add_company_id_number.php b/database/migrations/2014_10_30_184126_add_company_id_number.php index 9e0fcb75b4..420aaf5596 100644 --- a/database/migrations/2014_10_30_184126_add_company_id_number.php +++ b/database/migrations/2014_10_30_184126_add_company_id_number.php @@ -3,41 +3,37 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCompanyIdNumber extends Migration { +class AddCompanyIdNumber extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->string('id_number')->nullable(); - }); + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('id_number')->nullable(); + }); - Schema::table('clients', function($table) - { - $table->string('id_number')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('id_number'); - }); - Schema::table('clients', function($table) - { - $table->dropColumn('id_number'); - }); - } + Schema::table('clients', function ($table) { + $table->string('id_number')->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('id_number'); + }); + Schema::table('clients', function ($table) { + $table->dropColumn('id_number'); + }); + } } diff --git a/database/migrations/2014_11_04_200406_allow_null_client_currency.php b/database/migrations/2014_11_04_200406_allow_null_client_currency.php index 8007e8cb65..8700d85981 100644 --- a/database/migrations/2014_11_04_200406_allow_null_client_currency.php +++ b/database/migrations/2014_11_04_200406_allow_null_client_currency.php @@ -3,29 +3,27 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AllowNullClientCurrency extends Migration { +class AllowNullClientCurrency extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('clients', function($table) + /** + * Run the migrations. + * + * @return void + */ + public function up() { - //DB::statement('ALTER TABLE `clients` MODIFY `currency_id` INTEGER UNSIGNED NULL;'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - } + Schema::table('clients', function ($table) { + //DB::statement('ALTER TABLE `clients` MODIFY `currency_id` INTEGER UNSIGNED NULL;'); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } } diff --git a/database/migrations/2014_12_03_154119_add_discount_type.php b/database/migrations/2014_12_03_154119_add_discount_type.php index 50b9e07871..9fd64cf14d 100644 --- a/database/migrations/2014_12_03_154119_add_discount_type.php +++ b/database/migrations/2014_12_03_154119_add_discount_type.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddDiscountType extends Migration { +class AddDiscountType extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoices', function($table) - { - $table->boolean('is_amount_discount')->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) - { - $table->dropColumn('is_amount_discount'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoices', function ($table) { + $table->boolean('is_amount_discount')->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { + $table->dropColumn('is_amount_discount'); + }); + } } diff --git a/database/migrations/2015_02_12_102940_add_email_templates.php b/database/migrations/2015_02_12_102940_add_email_templates.php index 756466a791..cf595e8f66 100644 --- a/database/migrations/2015_02_12_102940_add_email_templates.php +++ b/database/migrations/2015_02_12_102940_add_email_templates.php @@ -3,36 +3,34 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddEmailTemplates extends Migration { +class AddEmailTemplates extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->text('email_template_invoice')->nullable(); $table->text('email_template_quote')->nullable(); $table->text('email_template_payment')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('email_template_invoice'); $table->dropColumn('email_template_quote'); $table->dropColumn('email_template_payment'); }); - } - + } } diff --git a/database/migrations/2015_02_17_131714_support_token_billing.php b/database/migrations/2015_02_17_131714_support_token_billing.php index f4c940c0f1..ac3baaea6f 100644 --- a/database/migrations/2015_02_17_131714_support_token_billing.php +++ b/database/migrations/2015_02_17_131714_support_token_billing.php @@ -3,22 +3,21 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class SupportTokenBilling extends Migration { +class SupportTokenBilling extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->smallInteger('token_billing_type_id')->default(TOKEN_BILLING_ALWAYS); }); - Schema::create('account_gateway_tokens', function($table) - { + Schema::create('account_gateway_tokens', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id'); $table->unsignedInteger('contact_id'); @@ -36,21 +35,19 @@ class SupportTokenBilling extends Migration { }); DB::table('accounts')->update(['token_billing_type_id' => TOKEN_BILLING_ALWAYS]); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('token_billing_type_id'); }); Schema::drop('account_gateway_tokens'); - } - -} \ No newline at end of file + } +} diff --git a/database/migrations/2015_02_27_081836_add_invoice_footer.php b/database/migrations/2015_02_27_081836_add_invoice_footer.php index 6d1cfb7a9e..19317aa4cd 100644 --- a/database/migrations/2015_02_27_081836_add_invoice_footer.php +++ b/database/migrations/2015_02_27_081836_add_invoice_footer.php @@ -3,42 +3,38 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddInvoiceFooter extends Migration { +class AddInvoiceFooter extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->text('invoice_footer')->nullable(); }); - Schema::table('invoices', function($table) - { + Schema::table('invoices', function ($table) { $table->text('invoice_footer')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('invoice_footer'); }); - Schema::table('invoices', function($table) - { + Schema::table('invoices', function ($table) { $table->dropColumn('invoice_footer'); }); - } - + } } diff --git a/database/migrations/2015_03_03_140259_add_tokens.php b/database/migrations/2015_03_03_140259_add_tokens.php index 45b54e3ca4..6d02786493 100644 --- a/database/migrations/2015_03_03_140259_add_tokens.php +++ b/database/migrations/2015_03_03_140259_add_tokens.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddTokens extends Migration { +class AddTokens extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('account_tokens', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('account_tokens', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id')->index(); $table->unsignedInteger('user_id'); @@ -30,25 +30,22 @@ class AddTokens extends Migration { $table->unique(['account_id', 'public_id']); }); - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->unsignedInteger('token_id')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::drop('account_tokens'); - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->dropColumn('token_id'); }); - } - + } } diff --git a/database/migrations/2015_03_09_151011_add_ip_to_activity.php b/database/migrations/2015_03_09_151011_add_ip_to_activity.php index 552f75dfa8..e180684b65 100644 --- a/database/migrations/2015_03_09_151011_add_ip_to_activity.php +++ b/database/migrations/2015_03_09_151011_add_ip_to_activity.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddIpToActivity extends Migration { +class AddIpToActivity extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('activities', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('activities', function ($table) { $table->string('ip')->nullable(); - }); - } + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('activities', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('activities', function ($table) { $table->dropColumn('ip'); - }); - } - + }); + } } diff --git a/database/migrations/2015_03_15_174122_add_pdf_email_attachment_option.php b/database/migrations/2015_03_15_174122_add_pdf_email_attachment_option.php index de89c6475a..16147c762e 100644 --- a/database/migrations/2015_03_15_174122_add_pdf_email_attachment_option.php +++ b/database/migrations/2015_03_15_174122_add_pdf_email_attachment_option.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddPdfEmailAttachmentOption extends Migration { +class AddPdfEmailAttachmentOption extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { - $table->smallInteger('pdf_email_attachment')->default(0); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { - $table->dropColumn('pdf_email_attachment'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->smallInteger('pdf_email_attachment')->default(0); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('pdf_email_attachment'); + }); + } } diff --git a/database/migrations/2015_03_30_100000_create_password_resets_table.php b/database/migrations/2015_03_30_100000_create_password_resets_table.php index 30be80c253..9889655e8e 100644 --- a/database/migrations/2015_03_30_100000_create_password_resets_table.php +++ b/database/migrations/2015_03_30_100000_create_password_resets_table.php @@ -3,26 +3,26 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreatePasswordResetsTable extends Migration { +class CreatePasswordResetsTable extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { Schema::rename('password_reminders', 'password_resets'); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::rename('password_resets', 'password_reminders'); - } - + } } diff --git a/database/migrations/2015_04_12_093447_add_sv_language.php b/database/migrations/2015_04_12_093447_add_sv_language.php index fc3342f727..589405fd9e 100644 --- a/database/migrations/2015_04_12_093447_add_sv_language.php +++ b/database/migrations/2015_04_12_093447_add_sv_language.php @@ -3,28 +3,29 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddSvLanguage extends Migration { +class AddSvLanguage extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { //DB::table('languages')->insert(['name' => 'Swedish', 'locale' => 'sv']); //DB::table('languages')->insert(['name' => 'Spanish - Spain', 'locale' => 'es_ES']); //DB::table('languages')->insert(['name' => 'French - Canada', 'locale' => 'fr_CA']); //DB::table('languages')->insert(['name' => 'Lithuanian', 'locale' => 'lt']); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { if ($language = \App\Models\Language::whereLocale('sv')->first()) { $language->delete(); } @@ -40,6 +41,5 @@ class AddSvLanguage extends Migration { if ($language = \App\Models\Language::whereLocale('lt')->first()) { $language->delete(); } - } - + } } diff --git a/database/migrations/2015_04_13_100333_add_notify_approved.php b/database/migrations/2015_04_13_100333_add_notify_approved.php index 8f0a4fd740..9fc01783a4 100644 --- a/database/migrations/2015_04_13_100333_add_notify_approved.php +++ b/database/migrations/2015_04_13_100333_add_notify_approved.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddNotifyApproved extends Migration { +class AddNotifyApproved extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('users', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { $table->boolean('notify_approved')->default(true); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { $table->dropColumn('notify_approved'); }); - } - + } } diff --git a/database/migrations/2015_04_16_122647_add_partial_amount_to_invoices.php b/database/migrations/2015_04_16_122647_add_partial_amount_to_invoices.php index cd1bada525..61e6f390bf 100644 --- a/database/migrations/2015_04_16_122647_add_partial_amount_to_invoices.php +++ b/database/migrations/2015_04_16_122647_add_partial_amount_to_invoices.php @@ -3,46 +3,42 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddPartialAmountToInvoices extends Migration { +class AddPartialAmountToInvoices extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoices', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoices', function ($table) { $table->decimal('partial', 13, 2)->nullable(); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->boolean('utf8_invoices')->default(true); $table->boolean('auto_wrap')->default(false); $table->string('subdomain')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { $table->dropColumn('partial'); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('utf8_invoices'); $table->dropColumn('auto_wrap'); $table->dropColumn('subdomain'); }); - } - + } } diff --git a/database/migrations/2015_05_21_184104_add_font_size.php b/database/migrations/2015_05_21_184104_add_font_size.php index b4a7c210d8..fa6094c771 100644 --- a/database/migrations/2015_05_21_184104_add_font_size.php +++ b/database/migrations/2015_05_21_184104_add_font_size.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddFontSize extends Migration { +class AddFontSize extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->smallInteger('font_size')->default(DEFAULT_FONT_SIZE); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('font_size'); }); - } - + } } diff --git a/database/migrations/2015_05_27_121828_add_tasks.php b/database/migrations/2015_05_27_121828_add_tasks.php index c8a0efa9cf..40406bf551 100644 --- a/database/migrations/2015_05_27_121828_add_tasks.php +++ b/database/migrations/2015_05_27_121828_add_tasks.php @@ -3,16 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddTasks extends Migration { +class AddTasks extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('tasks', function($table) { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('tasks', function ($table) { $table->increments('id'); $table->unsignedInteger('user_id'); $table->unsignedInteger('account_id')->index(); @@ -32,7 +33,7 @@ class AddTasks extends Migration { $table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); $table->unsignedInteger('public_id')->index(); - $table->unique( array('account_id','public_id') ); + $table->unique(array('account_id','public_id')); }); Schema::dropIfExists('timesheets'); @@ -40,16 +41,15 @@ class AddTasks extends Migration { Schema::dropIfExists('timesheet_event_sources'); Schema::dropIfExists('project_codes'); Schema::dropIfExists('projects'); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::drop('tasks'); - } - + } } diff --git a/database/migrations/2015_05_27_170808_add_custom_invoice_labels.php b/database/migrations/2015_05_27_170808_add_custom_invoice_labels.php index 24415d381b..593e4e8840 100644 --- a/database/migrations/2015_05_27_170808_add_custom_invoice_labels.php +++ b/database/migrations/2015_05_27_170808_add_custom_invoice_labels.php @@ -3,33 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCustomInvoiceLabels extends Migration { +class AddCustomInvoiceLabels extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->text('invoice_labels')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('invoice_labels'); }); - - } - + } } diff --git a/database/migrations/2015_06_09_134208_add_has_tasks_to_invoices.php b/database/migrations/2015_06_09_134208_add_has_tasks_to_invoices.php index 04a3ced69b..69a1070c0b 100644 --- a/database/migrations/2015_06_09_134208_add_has_tasks_to_invoices.php +++ b/database/migrations/2015_06_09_134208_add_has_tasks_to_invoices.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddHasTasksToInvoices extends Migration { +class AddHasTasksToInvoices extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoices', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoices', function ($table) { $table->boolean('has_tasks')->default(false); }); @@ -27,19 +27,17 @@ class AddHasTasksToInvoices extends Migration { ->where('id', $invoice->id) ->update(['has_tasks' => true]); } - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { $table->dropColumn('has_tasks'); }); - } - + } } diff --git a/database/migrations/2015_06_14_093410_enable_resuming_tasks.php b/database/migrations/2015_06_14_093410_enable_resuming_tasks.php index 6a685782f1..a712615740 100644 --- a/database/migrations/2015_06_14_093410_enable_resuming_tasks.php +++ b/database/migrations/2015_06_14_093410_enable_resuming_tasks.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class EnableResumingTasks extends Migration { +class EnableResumingTasks extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('tasks', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('tasks', function ($table) { $table->boolean('is_running')->default(false); $table->integer('break_duration')->nullable(); $table->timestamp('resume_time')->nullable(); @@ -36,23 +36,20 @@ class EnableResumingTasks extends Migration { ->where('id', $task->id) ->update($data); } - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - Schema::table('tasks', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tasks', function ($table) { $table->dropColumn('is_running'); $table->dropColumn('resume_time'); $table->dropColumn('break_duration'); $table->dropColumn('time_log'); }); - } - + } } diff --git a/database/migrations/2015_06_14_173025_multi_company_support.php b/database/migrations/2015_06_14_173025_multi_company_support.php index 08f8cf243f..2bc52b25f1 100644 --- a/database/migrations/2015_06_14_173025_multi_company_support.php +++ b/database/migrations/2015_06_14_173025_multi_company_support.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class MultiCompanySupport extends Migration { +class MultiCompanySupport extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('user_accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('user_accounts', function ($table) { $table->increments('id'); $table->unsignedInteger('user_id1')->nullable(); @@ -28,15 +28,15 @@ class MultiCompanySupport extends Migration { $table->foreign('user_id4')->references('id')->on('users'); $table->foreign('user_id5')->references('id')->on('users'); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::dropIfExists('user_accounts'); - } + } } diff --git a/database/migrations/2015_07_07_160257_support_locking_account.php b/database/migrations/2015_07_07_160257_support_locking_account.php index cb1ef96320..51a5dbc921 100644 --- a/database/migrations/2015_07_07_160257_support_locking_account.php +++ b/database/migrations/2015_07_07_160257_support_locking_account.php @@ -3,44 +3,40 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class SupportLockingAccount extends Migration { +class SupportLockingAccount extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('users', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('users', function ($table) { $table->smallInteger('failed_logins')->nullable(); }); - Schema::table('account_gateways', function($table) - { + Schema::table('account_gateways', function ($table) { $table->boolean('show_address')->default(true)->nullable(); $table->boolean('update_address')->default(true)->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('users', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function ($table) { $table->dropColumn('failed_logins'); }); - Schema::table('account_gateways', function($table) - { + Schema::table('account_gateways', function ($table) { $table->dropColumn('show_address'); $table->dropColumn('update_address'); }); - } - + } } diff --git a/database/migrations/2015_07_08_114333_simplify_tasks.php b/database/migrations/2015_07_08_114333_simplify_tasks.php index b0136a33ec..e1827d8a20 100644 --- a/database/migrations/2015_07_08_114333_simplify_tasks.php +++ b/database/migrations/2015_07_08_114333_simplify_tasks.php @@ -3,19 +3,20 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class SimplifyTasks extends Migration { +class SimplifyTasks extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { $tasks = \App\Models\Task::all(); foreach ($tasks as $task) { - $startTime = strtotime($task->start_time); + $startTime = strtotime($task->start_time); if (!$task->time_log || !count(json_decode($task->time_log))) { $task->time_log = json_encode([[$startTime, $startTime + $task->duration]]); $task->save(); @@ -25,49 +26,41 @@ class SimplifyTasks extends Migration { } } - Schema::table('tasks', function($table) - { + Schema::table('tasks', function ($table) { $table->dropColumn('start_time'); $table->dropColumn('duration'); $table->dropColumn('break_duration'); $table->dropColumn('resume_time'); }); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->boolean('dark_mode')->default(false)->nullable(); }); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->dropColumn('theme_id'); }); + } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('tasks', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tasks', function ($table) { $table->timestamp('start_time')->nullable(); $table->integer('duration')->nullable(); $table->timestamp('resume_time')->nullable(); $table->integer('break_duration')->nullable(); }); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->dropColumn('dark_mode'); }); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->integer('theme_id')->nullable(); }); - } - + } } diff --git a/database/migrations/2015_07_19_081332_add_custom_design.php b/database/migrations/2015_07_19_081332_add_custom_design.php index ea237594ac..adf4d6d6fc 100644 --- a/database/migrations/2015_07_19_081332_add_custom_design.php +++ b/database/migrations/2015_07_19_081332_add_custom_design.php @@ -3,34 +3,32 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddCustomDesign extends Migration { +class AddCustomDesign extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->mediumText('custom_design')->nullable(); }); DB::table('invoice_designs')->insert(['id' => CUSTOM_DESIGN, 'name' => 'Custom']); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('custom_design'); }); - } - + } } diff --git a/database/migrations/2015_07_27_183830_add_pdfmake_support.php b/database/migrations/2015_07_27_183830_add_pdfmake_support.php index b9294315a4..dc85f1f01f 100644 --- a/database/migrations/2015_07_27_183830_add_pdfmake_support.php +++ b/database/migrations/2015_07_27_183830_add_pdfmake_support.php @@ -3,32 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddPdfmakeSupport extends Migration { +class AddPdfmakeSupport extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('invoice_designs', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('invoice_designs', function ($table) { $table->mediumText('pdfmake')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoice_designs', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoice_designs', function ($table) { $table->dropColumn('pdfmake'); }); - } - + } } diff --git a/database/migrations/2015_09_10_185135_add_reminder_emails.php b/database/migrations/2015_09_10_185135_add_reminder_emails.php index 31a622e894..ab550eba33 100644 --- a/database/migrations/2015_09_10_185135_add_reminder_emails.php +++ b/database/migrations/2015_09_10_185135_add_reminder_emails.php @@ -3,15 +3,16 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddReminderEmails extends Migration { +class AddReminderEmails extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { Schema::table('accounts', function ($table) { $table->string('email_subject_invoice')->nullable(); $table->string('email_subject_quote')->nullable(); @@ -33,15 +34,15 @@ class AddReminderEmails extends Migration { $table->smallInteger('num_days_reminder2')->default(14); $table->smallInteger('num_days_reminder3')->default(30); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::table('accounts', function ($table) { $table->dropColumn('email_subject_invoice'); $table->dropColumn('email_subject_quote'); @@ -63,6 +64,5 @@ class AddReminderEmails extends Migration { $table->dropColumn('num_days_reminder2'); $table->dropColumn('num_days_reminder3'); }); - } - + } } diff --git a/database/migrations/2015_10_27_180214_add_is_system_to_activities.php b/database/migrations/2015_10_27_180214_add_is_system_to_activities.php index 615ea88b49..3ac3067d36 100644 --- a/database/migrations/2015_10_27_180214_add_is_system_to_activities.php +++ b/database/migrations/2015_10_27_180214_add_is_system_to_activities.php @@ -4,17 +4,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use App\Models\Activity; -class AddIsSystemToActivities extends Migration { +class AddIsSystemToActivities extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('activities', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('activities', function ($table) { $table->boolean('is_system')->default(0); }); @@ -24,28 +24,24 @@ class AddIsSystemToActivities extends Migration { $activity->save(); } - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->dropColumn('message'); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('activities', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('activities', function ($table) { $table->dropColumn('is_system'); }); - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->text('message')->nullable(); }); - } - + } } diff --git a/database/migrations/2015_10_29_133747_add_default_quote_terms.php b/database/migrations/2015_10_29_133747_add_default_quote_terms.php index a156dc3a77..6fccc3b120 100644 --- a/database/migrations/2015_10_29_133747_add_default_quote_terms.php +++ b/database/migrations/2015_10_29_133747_add_default_quote_terms.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddDefaultQuoteTerms extends Migration { +class AddDefaultQuoteTerms extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { $table->text('quote_terms')->nullable(); }); @@ -26,19 +26,17 @@ class AddDefaultQuoteTerms extends Migration { ->where('id', $account->id) ->update(['quote_terms' => $account->invoice_terms]); } - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('quote_terms'); }); - } - + } } diff --git a/database/migrations/2015_11_01_080417_encrypt_tokens.php b/database/migrations/2015_11_01_080417_encrypt_tokens.php index 0f2c35d4fc..cbd15aaff1 100644 --- a/database/migrations/2015_11_01_080417_encrypt_tokens.php +++ b/database/migrations/2015_11_01_080417_encrypt_tokens.php @@ -3,15 +3,16 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class EncryptTokens extends Migration { +class EncryptTokens extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { $gateways = DB::table('account_gateways') ->get(['id', 'config']); foreach ($gateways as $gateway) { @@ -19,15 +20,15 @@ class EncryptTokens extends Migration { ->where('id', $gateway->id) ->update(['config' => Crypt::encrypt($gateway->config)]); } - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { $gateways = DB::table('account_gateways') ->get(['id', 'config']); foreach ($gateways as $gateway) { @@ -35,7 +36,5 @@ class EncryptTokens extends Migration { ->where('id', $gateway->id) ->update(['config' => Crypt::decrypt($gateway->config)]); } - - } - + } } diff --git a/database/migrations/2015_11_03_181318_improve_currency_localization.php b/database/migrations/2015_11_03_181318_improve_currency_localization.php index dd0196ded7..5691f93219 100644 --- a/database/migrations/2015_11_03_181318_improve_currency_localization.php +++ b/database/migrations/2015_11_03_181318_improve_currency_localization.php @@ -3,34 +3,34 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class ImproveCurrencyLocalization extends Migration { +class ImproveCurrencyLocalization extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { Schema::table('countries', function ($table) { $table->boolean('swap_currency_symbol')->default(0); $table->string('thousand_separator')->nullable(); $table->string('decimal_separator')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::table('countries', function ($table) { $table->dropColumn('swap_currency_symbol'); $table->dropColumn('thousand_separator'); $table->dropColumn('decimal_separator'); }); - } - + } } diff --git a/database/migrations/2015_12_27_154513_add_reminder_settings.php b/database/migrations/2015_12_27_154513_add_reminder_settings.php index 0a94d49c78..a5b241fb17 100644 --- a/database/migrations/2015_12_27_154513_add_reminder_settings.php +++ b/database/migrations/2015_12_27_154513_add_reminder_settings.php @@ -3,15 +3,16 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddReminderSettings extends Migration { +class AddReminderSettings extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { Schema::table('accounts', function ($table) { $table->smallInteger('direction_reminder1')->default(1); $table->smallInteger('direction_reminder2')->default(1); @@ -21,15 +22,15 @@ class AddReminderSettings extends Migration { $table->smallInteger('field_reminder2')->default(1); $table->smallInteger('field_reminder3')->default(1); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::table('accounts', function ($table) { $table->dropColumn('direction_reminder1'); $table->dropColumn('direction_reminder2'); @@ -39,6 +40,5 @@ class AddReminderSettings extends Migration { $table->dropColumn('field_reminder2'); $table->dropColumn('field_reminder3'); }); - } - + } } diff --git a/database/migrations/2015_12_30_042035_add_client_view_css.php b/database/migrations/2015_12_30_042035_add_client_view_css.php index 8b654161d6..33a1fcdba5 100644 --- a/database/migrations/2015_12_30_042035_add_client_view_css.php +++ b/database/migrations/2015_12_30_042035_add_client_view_css.php @@ -3,30 +3,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddClientViewCss extends Migration { +class AddClientViewCss extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { Schema::table('accounts', function ($table) { $table->text('client_view_css')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::table('accounts', function ($table) { $table->dropColumn('client_view_css'); }); - } - + } } diff --git a/database/migrations/2016_01_18_195351_add_bank_accounts.php b/database/migrations/2016_01_18_195351_add_bank_accounts.php index 587672a496..37be55fe80 100644 --- a/database/migrations/2016_01_18_195351_add_bank_accounts.php +++ b/database/migrations/2016_01_18_195351_add_bank_accounts.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddBankAccounts extends Migration { +class AddBankAccounts extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('banks', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('banks', function ($table) { $table->increments('id'); $table->string('name'); $table->string('remote_id'); @@ -21,8 +21,7 @@ class AddBankAccounts extends Migration { $table->text('config'); }); - Schema::create('bank_accounts', function($table) - { + Schema::create('bank_accounts', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id'); $table->unsignedInteger('bank_id'); @@ -39,18 +38,16 @@ class AddBankAccounts extends Migration { $table->unsignedInteger('public_id')->index(); $table->unique(['account_id', 'public_id']); }); + } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::drop('bank_accounts'); Schema::drop('banks'); - } - + } } diff --git a/database/migrations/2016_01_24_112646_add_bank_subaccounts.php b/database/migrations/2016_01_24_112646_add_bank_subaccounts.php index 5c01fdd5de..ec43f6c70b 100644 --- a/database/migrations/2016_01_24_112646_add_bank_subaccounts.php +++ b/database/migrations/2016_01_24_112646_add_bank_subaccounts.php @@ -3,17 +3,17 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddBankSubaccounts extends Migration { +class AddBankSubaccounts extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('bank_subaccounts', function($table) - { + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('bank_subaccounts', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id'); $table->unsignedInteger('user_id'); @@ -33,37 +33,32 @@ class AddBankSubaccounts extends Migration { $table->unique(['account_id', 'public_id']); }); - Schema::table('expenses', function($table) - { + Schema::table('expenses', function ($table) { $table->string('transaction_id')->nullable(); $table->unsignedInteger('bank_id')->nullable(); }); - Schema::table('vendors', function($table) - { + Schema::table('vendors', function ($table) { $table->string('transaction_name')->nullable(); }); - } + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { Schema::drop('bank_subaccounts'); - Schema::table('expenses', function($table) - { + Schema::table('expenses', function ($table) { $table->dropColumn('transaction_id'); $table->dropColumn('bank_id'); }); - Schema::table('vendors', function($table) - { + Schema::table('vendors', function ($table) { $table->dropColumn('transaction_name'); }); - } - + } } diff --git a/database/migrations/2016_01_27_173015_add_header_footer_option.php b/database/migrations/2016_01_27_173015_add_header_footer_option.php index d840b31e8f..4922ebfbbd 100644 --- a/database/migrations/2016_01_27_173015_add_header_footer_option.php +++ b/database/migrations/2016_01_27_173015_add_header_footer_option.php @@ -3,66 +3,59 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddHeaderFooterOption extends Migration { +class AddHeaderFooterOption extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ + /** + * Run the migrations. + * + * @return void + */ public function up() - { - Schema::table('accounts', function($table) - { + { + Schema::table('accounts', function ($table) { $table->boolean('all_pages_footer'); $table->boolean('all_pages_header'); $table->boolean('show_currency_code'); $table->date('pro_plan_trial')->nullable(); }); - Schema::table('gateways', function($table) - { + Schema::table('gateways', function ($table) { $table->boolean('is_offsite'); $table->boolean('is_secure'); }); - Schema::table('expenses', function($table) - { - if (Schema::hasColumn('expenses', 'transaction_id')) { + Schema::table('expenses', function ($table) { + if (Schema::hasColumn('expenses', 'transaction_id')) { $table->string('transaction_id')->nullable()->change(); $table->unsignedInteger('bank_id')->nullable()->change(); - } + } }); - Schema::table('vendors', function($table) - { - if (Schema::hasColumn('vendors', 'transaction_name')) { - $table->string('transaction_name')->nullable()->change(); - } + Schema::table('vendors', function ($table) { + if (Schema::hasColumn('vendors', 'transaction_name')) { + $table->string('transaction_name')->nullable()->change(); + } }); - } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { $table->dropColumn('all_pages_footer'); $table->dropColumn('all_pages_header'); $table->dropColumn('show_currency_code'); $table->dropColumn('pro_plan_trial'); }); - Schema::table('gateways', function($table) - { + Schema::table('gateways', function ($table) { $table->dropColumn('is_offsite'); $table->dropColumn('is_secure'); }); - } - + } } diff --git a/database/migrations/2016_02_01_135956_add_source_currency_to_expenses.php b/database/migrations/2016_02_01_135956_add_source_currency_to_expenses.php index f40ed0fea4..8a1dd3e817 100644 --- a/database/migrations/2016_02_01_135956_add_source_currency_to_expenses.php +++ b/database/migrations/2016_02_01_135956_add_source_currency_to_expenses.php @@ -13,7 +13,6 @@ class AddSourceCurrencyToExpenses extends Migration public function up() { Schema::table('expenses', function (Blueprint $table) { - $table->dropColumn('foreign_amount'); if (Schema::hasColumn('expenses', 'currency_id')) { @@ -43,8 +42,7 @@ class AddSourceCurrencyToExpenses extends Migration */ public function down() { - Schema::table('expenses', function($table) { - + Schema::table('expenses', function ($table) { }); } } diff --git a/database/migrations/2016_02_25_152948_add_client_password.php b/database/migrations/2016_02_25_152948_add_client_password.php index 49fcae7fcb..86754ac81d 100644 --- a/database/migrations/2016_02_25_152948_add_client_password.php +++ b/database/migrations/2016_02_25_152948_add_client_password.php @@ -3,44 +3,44 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddClientPassword extends Migration { +class AddClientPassword extends Migration +{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function ($table) { - $table->boolean('enable_portal_password')->default(0); - $table->boolean('send_portal_password')->default(0); - }); - - Schema::table('contacts', function ($table) { - $table->string('password', 255)->nullable(); - $table->boolean('confirmation_code', 255)->nullable(); - $table->boolean('remember_token', 100)->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function ($table) { - $table->dropColumn('enable_portal_password'); - $table->dropColumn('send_portal_password'); - }); - - Schema::table('contacts', function ($table) { - $table->dropColumn('password'); - $table->dropColumn('confirmation_code'); - $table->dropColumn('remember_token'); - }); - } + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->boolean('enable_portal_password')->default(0); + $table->boolean('send_portal_password')->default(0); + }); + + Schema::table('contacts', function ($table) { + $table->string('password', 255)->nullable(); + $table->boolean('confirmation_code', 255)->nullable(); + $table->boolean('remember_token', 100)->nullable(); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('enable_portal_password'); + $table->dropColumn('send_portal_password'); + }); + + Schema::table('contacts', function ($table) { + $table->dropColumn('password'); + $table->dropColumn('confirmation_code'); + $table->dropColumn('remember_token'); + }); + } } diff --git a/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php b/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php index cda210fdf5..e88242e88d 100644 --- a/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php +++ b/database/migrations/2016_02_28_081424_add_custom_invoice_fields.php @@ -12,7 +12,7 @@ class AddCustomInvoiceFields extends Migration */ public function up() { - Schema::table('accounts', function($table) { + Schema::table('accounts', function ($table) { $table->string('custom_invoice_item_label1')->nullable(); $table->string('custom_invoice_item_label2')->nullable(); $table->string('recurring_invoice_number_prefix')->default('R'); @@ -21,7 +21,7 @@ class AddCustomInvoiceFields extends Migration $table->text('devices')->nullable(); }); - Schema::table('invoice_items', function($table) { + Schema::table('invoice_items', function ($table) { $table->string('custom_value1')->nullable(); $table->string('custom_value2')->nullable(); }); @@ -34,7 +34,7 @@ class AddCustomInvoiceFields extends Migration */ public function down() { - Schema::table('accounts', function($table) { + Schema::table('accounts', function ($table) { $table->dropColumn('custom_invoice_item_label1'); $table->dropColumn('custom_invoice_item_label2'); $table->dropColumn('recurring_invoice_number_prefix'); @@ -43,7 +43,7 @@ class AddCustomInvoiceFields extends Migration $table->dropColumn('devices'); }); - Schema::table('invoice_items', function($table) { + Schema::table('invoice_items', function ($table) { $table->dropColumn('custom_value1'); $table->dropColumn('custom_value2'); }); diff --git a/database/migrations/2016_03_14_066181_add_user_permissions.php b/database/migrations/2016_03_14_066181_add_user_permissions.php index 2cdd599482..0a26d487d1 100644 --- a/database/migrations/2016_03_14_066181_add_user_permissions.php +++ b/database/migrations/2016_03_14_066181_add_user_permissions.php @@ -12,7 +12,7 @@ class AddUserPermissions extends Migration */ public function up() { - Schema::table('users', function($table) { + Schema::table('users', function ($table) { $table->boolean('is_admin')->default(true); $table->unsignedInteger('permissions')->default(0); }); @@ -25,7 +25,7 @@ class AddUserPermissions extends Migration */ public function down() { - Schema::table('users', function($table) { + Schema::table('users', function ($table) { $table->dropColumn('is_admin'); $table->dropColumn('permissions'); }); diff --git a/database/migrations/2016_03_14_214710_add_support_three_decimal_taxes.php b/database/migrations/2016_03_14_214710_add_support_three_decimal_taxes.php index 339a29b521..f866b3abf0 100644 --- a/database/migrations/2016_03_14_214710_add_support_three_decimal_taxes.php +++ b/database/migrations/2016_03_14_214710_add_support_three_decimal_taxes.php @@ -2,29 +2,30 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddSupportThreeDecimalTaxes extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('tax_rates', function($table) { - if (Schema::hasColumn('tax_rates', 'rate')) { - $table->decimal('rate', 13, 3)->change(); - } - }); - } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('tax_rates', function($table) { - $table->decimal('rate', 13, 2)->change(); - }); - } +class AddSupportThreeDecimalTaxes extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('tax_rates', function ($table) { + if (Schema::hasColumn('tax_rates', 'rate')) { + $table->decimal('rate', 13, 3)->change(); + } + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tax_rates', function ($table) { + $table->decimal('rate', 13, 2)->change(); + }); + } } diff --git a/database/migrations/2016_03_22_168362_add_documents.php b/database/migrations/2016_03_22_168362_add_documents.php index d0f368b772..c5a430de41 100644 --- a/database/migrations/2016_03_22_168362_add_documents.php +++ b/database/migrations/2016_03_22_168362_add_documents.php @@ -2,69 +2,69 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddDocuments extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('accounts', function($table) { - $table->string('logo')->nullable()->default(null); - $table->unsignedInteger('logo_width'); - $table->unsignedInteger('logo_height'); - $table->unsignedInteger('logo_size'); - $table->boolean('invoice_embed_documents')->default(0); - $table->boolean('document_email_attachment')->default(0); - }); +class AddDocuments extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->string('logo')->nullable()->default(null); + $table->unsignedInteger('logo_width'); + $table->unsignedInteger('logo_height'); + $table->unsignedInteger('logo_size'); + $table->boolean('invoice_embed_documents')->default(0); + $table->boolean('document_email_attachment')->default(0); + }); - \DB::table('accounts')->update(array('logo' => '')); - Schema::dropIfExists('documents'); - Schema::create('documents', function($t) - { + \DB::table('accounts')->update(array('logo' => '')); + Schema::dropIfExists('documents'); + Schema::create('documents', function ($t) { $t->increments('id'); - $t->unsignedInteger('public_id')->nullable(); - $t->unsignedInteger('account_id'); - $t->unsignedInteger('user_id'); + $t->unsignedInteger('public_id')->nullable(); + $t->unsignedInteger('account_id'); + $t->unsignedInteger('user_id'); $t->unsignedInteger('invoice_id')->nullable(); $t->unsignedInteger('expense_id')->nullable(); $t->string('path'); - $t->string('preview'); - $t->string('name'); - $t->string('type'); - $t->string('disk'); - $t->string('hash', 40); + $t->string('preview'); + $t->string('name'); + $t->string('type'); + $t->string('disk'); + $t->string('hash', 40); $t->unsignedInteger('size'); - $t->unsignedInteger('width')->nullable(); - $t->unsignedInteger('height')->nullable(); + $t->unsignedInteger('width')->nullable(); + $t->unsignedInteger('height')->nullable(); $t->timestamps(); - }); - - Schema::table('documents', function($t) { - $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); - $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); - $t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade'); - $t->unique( array('account_id','public_id') ); }); - } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('accounts', function($table) { - $table->dropColumn('logo'); - $table->dropColumn('logo_width'); - $table->dropColumn('logo_height'); - $table->dropColumn('logo_size'); - $table->dropColumn('invoice_embed_documents'); - $table->dropColumn('document_email_attachment'); - }); - Schema::dropIfExists('documents'); - } + Schema::table('documents', function ($t) { + $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); + $t->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade'); + $t->foreign('expense_id')->references('id')->on('expenses')->onDelete('cascade'); + $t->unique(array('account_id','public_id')); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('logo'); + $table->dropColumn('logo_width'); + $table->dropColumn('logo_height'); + $table->dropColumn('logo_size'); + $table->dropColumn('invoice_embed_documents'); + $table->dropColumn('document_email_attachment'); + }); + + Schema::dropIfExists('documents'); + } } diff --git a/database/migrations/2016_03_23_215049_support_multiple_tax_rates.php b/database/migrations/2016_03_23_215049_support_multiple_tax_rates.php index cda2aef7b4..f992d461af 100644 --- a/database/migrations/2016_03_23_215049_support_multiple_tax_rates.php +++ b/database/migrations/2016_03_23_215049_support_multiple_tax_rates.php @@ -10,67 +10,67 @@ class SupportMultipleTaxRates extends Migration * * @return void */ - public function up() - { - Schema::table('invoices', function($table) { - if (Schema::hasColumn('invoices', 'tax_rate')) { - $table->decimal('tax_rate', 13, 3)->change(); - } - }); + public function up() + { + Schema::table('invoices', function ($table) { + if (Schema::hasColumn('invoices', 'tax_rate')) { + $table->decimal('tax_rate', 13, 3)->change(); + } + }); - Schema::table('invoice_items', function($table) { - if (Schema::hasColumn('invoice_items', 'tax_rate')) { - $table->decimal('tax_rate', 13, 3)->change(); - } - }); + Schema::table('invoice_items', function ($table) { + if (Schema::hasColumn('invoice_items', 'tax_rate')) { + $table->decimal('tax_rate', 13, 3)->change(); + } + }); - Schema::table('invoices', function($table) { - if (Schema::hasColumn('invoices', 'tax_rate')) { - $table->renameColumn('tax_rate', 'tax_rate1'); - $table->renameColumn('tax_name', 'tax_name1'); - } - $table->string('tax_name2')->nullable(); - $table->decimal('tax_rate2', 13, 3); - }); + Schema::table('invoices', function ($table) { + if (Schema::hasColumn('invoices', 'tax_rate')) { + $table->renameColumn('tax_rate', 'tax_rate1'); + $table->renameColumn('tax_name', 'tax_name1'); + } + $table->string('tax_name2')->nullable(); + $table->decimal('tax_rate2', 13, 3); + }); - Schema::table('invoice_items', function($table) { - if (Schema::hasColumn('invoice_items', 'tax_rate')) { - $table->renameColumn('tax_rate', 'tax_rate1'); - $table->renameColumn('tax_name', 'tax_name1'); - } - $table->string('tax_name2')->nullable(); - $table->decimal('tax_rate2', 13, 3); - }); + Schema::table('invoice_items', function ($table) { + if (Schema::hasColumn('invoice_items', 'tax_rate')) { + $table->renameColumn('tax_rate', 'tax_rate1'); + $table->renameColumn('tax_name', 'tax_name1'); + } + $table->string('tax_name2')->nullable(); + $table->decimal('tax_rate2', 13, 3); + }); - Schema::table('accounts', function($table) { - $table->boolean('enable_client_portal_dashboard')->default(true); - }); - } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('invoices', function($table) { - $table->decimal('tax_rate1', 13, 2)->change(); - $table->renameColumn('tax_rate1', 'tax_rate'); - $table->renameColumn('tax_name1', 'tax_name'); - $table->dropColumn('tax_name2'); - $table->dropColumn('tax_rate2'); - }); - - Schema::table('invoice_items', function($table) { + Schema::table('accounts', function ($table) { + $table->boolean('enable_client_portal_dashboard')->default(true); + }); + } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('invoices', function ($table) { $table->decimal('tax_rate1', 13, 2)->change(); $table->renameColumn('tax_rate1', 'tax_rate'); $table->renameColumn('tax_name1', 'tax_name'); $table->dropColumn('tax_name2'); $table->dropColumn('tax_rate2'); - }); + }); - Schema::table('accounts', function($table) { + Schema::table('invoice_items', function ($table) { + $table->decimal('tax_rate1', 13, 2)->change(); + $table->renameColumn('tax_rate1', 'tax_rate'); + $table->renameColumn('tax_name1', 'tax_name'); + $table->dropColumn('tax_name2'); + $table->dropColumn('tax_rate2'); + }); + + Schema::table('accounts', function ($table) { $table->dropColumn('enable_client_portal_dashboard'); }); - } + } } diff --git a/database/migrations/2016_04_16_103943_enterprise_plan.php b/database/migrations/2016_04_16_103943_enterprise_plan.php index 7b3bca5575..dc6b5d52df 100644 --- a/database/migrations/2016_04_16_103943_enterprise_plan.php +++ b/database/migrations/2016_04_16_103943_enterprise_plan.php @@ -12,7 +12,8 @@ class EnterprisePlan extends Migration * * @return void */ - public function up() { + public function up() + { $timeout = ini_get('max_execution_time'); if ($timeout == 0) { $timeout = 600; @@ -21,8 +22,7 @@ class EnterprisePlan extends Migration $startTime = time(); if (!Schema::hasTable('companies')) { - Schema::create('companies', function($table) - { + Schema::create('companies', function ($table) { $table->increments('id'); $table->enum('plan', array('pro', 'enterprise', 'white_label'))->nullable(); @@ -44,19 +44,16 @@ class EnterprisePlan extends Migration $table->softDeletes(); }); - Schema::table('companies', function($table) - { + Schema::table('companies', function ($table) { $table->foreign('payment_id')->references('id')->on('payments'); }); } if (!Schema::hasColumn('accounts', 'company_id')) { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->unsignedInteger('company_id')->nullable(); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade'); }); } @@ -111,16 +108,16 @@ class EnterprisePlan extends Migration } if (Schema::hasColumn('accounts', 'pro_plan_paid')) { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('pro_plan_paid'); $table->dropColumn('pro_plan_trial'); }); } - } + } - private function upAccounts($primaryAccount, $otherAccounts = array()) { - if(!$primaryAccount) { + private function upAccounts($primaryAccount, $otherAccounts = array()) + { + if (!$primaryAccount) { $primaryAccount = $otherAccounts->first(); } @@ -167,28 +164,29 @@ class EnterprisePlan extends Migration $primaryAccount->save(); if (!empty($otherAccounts)) { - foreach ($otherAccounts as $account) { - if ($account && $account->id != $primaryAccount->id) { + foreach ($otherAccounts as $account) { + if ($account && $account->id != $primaryAccount->id) { $account->company_id = $company->id; $account->save(); - } - } + } + } } } - protected function checkTimeout($timeout, $startTime) { + protected function checkTimeout($timeout, $startTime) + { if (time() - $startTime >= $timeout) { exit('Migration reached time limit; please run again to continue'); } } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { $timeout = ini_get('max_execution_time'); if ($timeout == 0) { $timeout = 600; @@ -197,8 +195,7 @@ class EnterprisePlan extends Migration $startTime = time(); if (!Schema::hasColumn('accounts', 'pro_plan_paid')) { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->date('pro_plan_paid')->nullable(); $table->date('pro_plan_trial')->nullable(); }); @@ -228,13 +225,12 @@ class EnterprisePlan extends Migration } if (Schema::hasColumn('accounts', 'company_id')) { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropForeign('accounts_company_id_foreign'); $table->dropColumn('company_id'); }); } Schema::dropIfExists('companies'); - } + } } diff --git a/database/migrations/2016_04_18_174135_add_page_size.php b/database/migrations/2016_04_18_174135_add_page_size.php index 8184e954c1..70fab93247 100644 --- a/database/migrations/2016_04_18_174135_add_page_size.php +++ b/database/migrations/2016_04_18_174135_add_page_size.php @@ -22,8 +22,7 @@ class AddPageSize extends Migration $table->dropColumn('is_early_access'); }); - Schema::create('expense_categories', function($table) - { + Schema::create('expense_categories', function ($table) { $table->increments('id'); $table->unsignedInteger('user_id'); $table->unsignedInteger('account_id')->index(); @@ -36,7 +35,7 @@ class AddPageSize extends Migration Schema::table('expense_categories', function ($table) { $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $table->unique( array('account_id','public_id') ); + $table->unique(array('account_id','public_id')); }); diff --git a/database/migrations/2016_04_23_182223_payments_changes.php b/database/migrations/2016_04_23_182223_payments_changes.php index 61d0d16eef..852e17870a 100644 --- a/database/migrations/2016_04_23_182223_payments_changes.php +++ b/database/migrations/2016_04_23_182223_payments_changes.php @@ -15,8 +15,7 @@ class PaymentsChanges extends Migration { Schema::dropIfExists('payment_statuses'); - Schema::create('payment_statuses', function($table) - { + Schema::create('payment_statuses', function ($table) { $table->increments('id'); $table->string('name'); }); @@ -44,8 +43,7 @@ class PaymentsChanges extends Migration Schema::dropIfExists('payment_methods'); - Schema::create('payment_methods', function($table) - { + Schema::create('payment_methods', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id'); $table->unsignedInteger('user_id'); @@ -67,8 +65,7 @@ class PaymentsChanges extends Migration $table->unsignedInteger('public_id')->index(); }); - Schema::table('payment_methods', function($table) - { + Schema::table('payment_methods', function ($table) { $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); @@ -76,11 +73,10 @@ class PaymentsChanges extends Migration $table->foreign('payment_type_id')->references('id')->on('payment_types'); $table->foreign('currency_id')->references('id')->on('currencies'); - $table->unique( array('account_id','public_id') ); + $table->unique(array('account_id','public_id')); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->decimal('refunded', 13, 2); $table->unsignedInteger('payment_status_id')->default(PAYMENT_STATUS_COMPLETED); @@ -92,15 +88,13 @@ class PaymentsChanges extends Migration $table->unsignedInteger('payment_method_id')->nullable(); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->foreign('payment_status_id')->references('id')->on('payment_statuses'); $table->foreign('payment_method_id')->references('id')->on('payment_methods'); }); - Schema::table('invoices', function($table) - { + Schema::table('invoices', function ($table) { $table->boolean('client_enable_auto_bill')->default(false); }); @@ -114,16 +108,13 @@ class PaymentsChanges extends Migration ->update(array('auto_bill' => AUTO_BILL_OFF)); - Schema::table('account_gateway_tokens', function($table) - { + Schema::table('account_gateway_tokens', function ($table) { $table->unsignedInteger('default_payment_method_id')->nullable(); }); - Schema::table('account_gateway_tokens', function($table) - { + Schema::table('account_gateway_tokens', function ($table) { $table->foreign('default_payment_method_id')->references('id')->on('payment_methods'); }); - } /** @@ -133,8 +124,7 @@ class PaymentsChanges extends Migration */ public function down() { - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->dropColumn('refunded'); $table->dropForeign('payments_payment_status_id_foreign'); $table->dropColumn('payment_status_id'); @@ -154,9 +144,9 @@ class PaymentsChanges extends Migration ->update(array('auto_bill' => 0)); \DB::table('invoices') - ->where(function($query){ + ->where(function ($query) { $query->where('auto_bill', '=', AUTO_BILL_ALWAYS); - $query->orwhere(function($query){ + $query->orwhere(function ($query) { $query->where('auto_bill', '!=', 0); $query->where('client_enable_auto_bill', '=', 1); }); @@ -173,8 +163,7 @@ class PaymentsChanges extends Migration Schema::dropIfExists('payment_statuses'); - Schema::table('account_gateway_tokens', function($table) - { + Schema::table('account_gateway_tokens', function ($table) { $table->dropForeign('account_gateway_tokens_default_payment_method_id_foreign'); $table->dropColumn('default_payment_method_id'); }); diff --git a/database/migrations/2016_05_16_102925_add_swap_currency_symbol_to_currency.php b/database/migrations/2016_05_16_102925_add_swap_currency_symbol_to_currency.php index d331b54cf7..756cfa8e01 100644 --- a/database/migrations/2016_05_16_102925_add_swap_currency_symbol_to_currency.php +++ b/database/migrations/2016_05_16_102925_add_swap_currency_symbol_to_currency.php @@ -12,18 +12,18 @@ class AddSwapCurrencySymbolToCurrency extends Migration */ public function up() { - Schema::table('currencies', function(Blueprint $table) { + Schema::table('currencies', function (Blueprint $table) { $table->boolean('swap_currency_symbol')->default(false); }); - Schema::table('expenses', function(Blueprint $table) { + Schema::table('expenses', function (Blueprint $table) { $table->string('tax_name1')->nullable(); $table->decimal('tax_rate1', 13, 3); $table->string('tax_name2')->nullable(); $table->decimal('tax_rate2', 13, 3); }); - Schema::table('account_gateways', function(Blueprint $table) { + Schema::table('account_gateways', function (Blueprint $table) { $table->boolean('require_cvv')->default(true)->nullable(); }); } @@ -35,18 +35,18 @@ class AddSwapCurrencySymbolToCurrency extends Migration */ public function down() { - Schema::table('currencies', function(Blueprint $table) { + Schema::table('currencies', function (Blueprint $table) { $table->dropColumn('swap_currency_symbol'); }); - Schema::table('expenses', function(Blueprint $table) { + Schema::table('expenses', function (Blueprint $table) { $table->dropColumn('tax_name1'); $table->dropColumn('tax_rate1'); $table->dropColumn('tax_name2'); $table->dropColumn('tax_rate2'); }); - Schema::table('account_gateways', function(Blueprint $table) { + Schema::table('account_gateways', function (Blueprint $table) { $table->dropColumn('require_cvv'); }); } diff --git a/database/migrations/2016_05_18_085739_add_invoice_type_support.php b/database/migrations/2016_05_18_085739_add_invoice_type_support.php index bc4834df96..2dc97fbdfd 100644 --- a/database/migrations/2016_05_18_085739_add_invoice_type_support.php +++ b/database/migrations/2016_05_18_085739_add_invoice_type_support.php @@ -20,12 +20,9 @@ class AddInvoiceTypeSupport extends Migration }); } - Schema::table('accounts', function($table) - { - $table->boolean('enable_second_tax_rate')->default(false); - }); - - + Schema::table('accounts', function ($table) { + $table->boolean('enable_second_tax_rate')->default(false); + }); } /** @@ -39,9 +36,8 @@ class AddInvoiceTypeSupport extends Migration DB::update('update invoices set invoice_type_id = invoice_type_id - 1'); } - Schema::table('accounts', function($table) - { - $table->dropColumn('enable_second_tax_rate'); - }); + Schema::table('accounts', function ($table) { + $table->dropColumn('enable_second_tax_rate'); + }); } } diff --git a/database/migrations/2016_05_24_164847_wepay_ach.php b/database/migrations/2016_05_24_164847_wepay_ach.php index 088e9225d0..4a5803d718 100644 --- a/database/migrations/2016_05_24_164847_wepay_ach.php +++ b/database/migrations/2016_05_24_164847_wepay_ach.php @@ -12,24 +12,21 @@ class WepayAch extends Migration */ public function up() { - Schema::table('contacts', function(Blueprint $table) { + Schema::table('contacts', function (Blueprint $table) { $table->string('contact_key')->nullable()->default(null)->index()->unique(); }); - Schema::table('payment_methods', function($table) - { + Schema::table('payment_methods', function ($table) { $table->string('bank_name')->nullable(); $table->string('ip')->nullable(); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->string('bank_name')->nullable(); $table->string('ip')->nullable(); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->boolean('auto_bill_on_due_date')->default(false); }); } @@ -41,21 +38,21 @@ class WepayAch extends Migration */ public function down() { - Schema::table('contacts', function(Blueprint $table) { - $table->dropColumn('contact_key'); + Schema::table('contacts', function (Blueprint $table) { + $table->dropColumn('contact_key'); }); - Schema::table('payments', function($table) { + Schema::table('payments', function ($table) { $table->dropColumn('bank_name'); $table->dropColumn('ip'); }); - Schema::table('payment_methods', function($table) { + Schema::table('payment_methods', function ($table) { $table->dropColumn('bank_name'); $table->dropColumn('ip'); }); - Schema::table('accounts', function($table) { + Schema::table('accounts', function ($table) { $table->dropColumn('auto_bill_on_due_date'); }); } diff --git a/database/migrations/2016_07_08_083802_support_new_pricing.php b/database/migrations/2016_07_08_083802_support_new_pricing.php index b6bacffc67..dc2498f6cb 100644 --- a/database/migrations/2016_07_08_083802_support_new_pricing.php +++ b/database/migrations/2016_07_08_083802_support_new_pricing.php @@ -12,8 +12,7 @@ class SupportNewPricing extends Migration */ public function up() { - Schema::table('companies', function (Blueprint $table) - { + Schema::table('companies', function (Blueprint $table) { $table->decimal('plan_price', 7, 2)->nullable(); $table->decimal('pending_plan_price', 7, 2)->nullable(); $table->smallInteger('num_users')->default(1); @@ -78,8 +77,7 @@ class SupportNewPricing extends Migration */ public function down() { - Schema::table('companies', function (Blueprint $table) - { + Schema::table('companies', function (Blueprint $table) { $table->dropColumn('plan_price'); $table->dropColumn('pending_plan_price'); $table->dropColumn('num_users'); diff --git a/database/migrations/2016_07_13_083821_add_buy_now_buttons.php b/database/migrations/2016_07_13_083821_add_buy_now_buttons.php index a27c0b09c5..4f2bf4cc68 100644 --- a/database/migrations/2016_07_13_083821_add_buy_now_buttons.php +++ b/database/migrations/2016_07_13_083821_add_buy_now_buttons.php @@ -12,19 +12,16 @@ class AddBuyNowButtons extends Migration */ public function up() { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->boolean('enable_buy_now_buttons')->default(false); $table->dropColumn('invoice_design'); }); - Schema::table('datetime_formats', function($table) - { + Schema::table('datetime_formats', function ($table) { $table->dropColumn('label'); }); - Schema::table('date_formats', function($table) - { + Schema::table('date_formats', function ($table) { $table->dropColumn('label'); }); } @@ -36,19 +33,16 @@ class AddBuyNowButtons extends Migration */ public function down() { - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('enable_buy_now_buttons'); $table->text('invoice_design')->nullable(); }); - Schema::table('datetime_formats', function($table) - { + Schema::table('datetime_formats', function ($table) { $table->string('label'); }); - Schema::table('date_formats', function($table) - { + Schema::table('date_formats', function ($table) { $table->string('label'); }); } diff --git a/database/migrations/2016_08_10_184027_add_support_for_bots.php b/database/migrations/2016_08_10_184027_add_support_for_bots.php index 3a28f29a13..a7865dde03 100644 --- a/database/migrations/2016_08_10_184027_add_support_for_bots.php +++ b/database/migrations/2016_08_10_184027_add_support_for_bots.php @@ -12,8 +12,7 @@ class AddSupportForBots extends Migration */ public function up() { - Schema::create('security_codes', function($table) - { + Schema::create('security_codes', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id')->index(); $table->unsignedInteger('user_id')->nullable(); @@ -24,28 +23,23 @@ class AddSupportForBots extends Migration $table->timestamp('created_at')->useCurrent(); }); - Schema::table('security_codes', function($table) - { + Schema::table('security_codes', function ($table) { $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); }); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->string('bot_user_id')->nullable(); }); - Schema::table('contacts', function($table) - { + Schema::table('contacts', function ($table) { $table->string('bot_user_id')->nullable(); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->boolean('include_item_taxes_inline')->default(false); }); - } /** @@ -57,18 +51,15 @@ class AddSupportForBots extends Migration { Schema::dropIfExists('security_codes'); - Schema::table('users', function($table) - { + Schema::table('users', function ($table) { $table->dropColumn('bot_user_id'); }); - Schema::table('contacts', function($table) - { + Schema::table('contacts', function ($table) { $table->dropColumn('bot_user_id'); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('include_item_taxes_inline'); }); } diff --git a/database/migrations/2016_09_05_150625_create_gateway_types.php b/database/migrations/2016_09_05_150625_create_gateway_types.php index 544211eb53..2243c58c72 100644 --- a/database/migrations/2016_09_05_150625_create_gateway_types.php +++ b/database/migrations/2016_09_05_150625_create_gateway_types.php @@ -13,16 +13,14 @@ class CreateGatewayTypes extends Migration public function up() { Schema::dropIfExists('gateway_types'); - Schema::create('gateway_types', function($table) - { + Schema::create('gateway_types', function ($table) { $table->increments('id'); $table->string('alias'); $table->string('name'); }); Schema::dropIfExists('account_gateway_settings'); - Schema::create('account_gateway_settings', function($table) - { + Schema::create('account_gateway_settings', function ($table) { $table->increments('id'); $table->unsignedInteger('account_id'); @@ -36,22 +34,19 @@ class CreateGatewayTypes extends Migration $table->unsignedInteger('max_limit')->nullable(); }); - Schema::table('account_gateway_settings', function($table) - { + Schema::table('account_gateway_settings', function ($table) { $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade'); }); - Schema::table('payment_types', function($table) - { + Schema::table('payment_types', function ($table) { $table->unsignedInteger('gateway_type_id')->nullable(); }); // http://laravel.io/forum/09-18-2014-foreign-key-not-saving-in-migration DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - Schema::table('payment_types', function($table) - { + Schema::table('payment_types', function ($table) { $table->foreign('gateway_type_id')->references('id')->on('gateway_types')->onDelete('cascade'); }); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); @@ -64,8 +59,7 @@ class CreateGatewayTypes extends Migration */ public function down() { - Schema::table('payment_types', function($table) - { + Schema::table('payment_types', function ($table) { $table->dropForeign('payment_types_gateway_type_id_foreign'); $table->dropColumn('gateway_type_id'); }); diff --git a/database/migrations/2016_10_20_191150_add_expense_to_activities.php b/database/migrations/2016_10_20_191150_add_expense_to_activities.php index 6b95da88e5..4e83b941d9 100644 --- a/database/migrations/2016_10_20_191150_add_expense_to_activities.php +++ b/database/migrations/2016_10_20_191150_add_expense_to_activities.php @@ -12,13 +12,11 @@ class AddExpenseToActivities extends Migration */ public function up() { - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->unsignedInteger('expense_id')->nullable(); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->date('financial_year_start')->nullable(); $table->smallInteger('enabled_modules')->default(63); $table->smallInteger('enabled_dashboard_sections')->default(7); @@ -28,8 +26,7 @@ class AddExpenseToActivities extends Migration $table->boolean('require_quote_signature')->default(false); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->text('credit_ids')->nullable(); }); } @@ -41,13 +38,11 @@ class AddExpenseToActivities extends Migration */ public function down() { - Schema::table('activities', function($table) - { + Schema::table('activities', function ($table) { $table->dropColumn('expense_id'); }); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('financial_year_start'); $table->dropColumn('enabled_modules'); $table->dropColumn('enabled_dashboard_sections'); @@ -57,8 +52,7 @@ class AddExpenseToActivities extends Migration $table->dropColumn('require_quote_signature'); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->dropColumn('credit_ids'); }); } diff --git a/database/migrations/2016_11_03_113316_add_invoice_signature.php b/database/migrations/2016_11_03_113316_add_invoice_signature.php index 2f5a71549b..3591372f68 100644 --- a/database/migrations/2016_11_03_113316_add_invoice_signature.php +++ b/database/migrations/2016_11_03_113316_add_invoice_signature.php @@ -12,16 +12,13 @@ class AddInvoiceSignature extends Migration */ public function up() { - if ( ! Schema::hasColumn('invitations', 'signature_base64')) - { - Schema::table('invitations', function($table) - { + if (! Schema::hasColumn('invitations', 'signature_base64')) { + Schema::table('invitations', function ($table) { $table->text('signature_base64')->nullable(); $table->timestamp('signature_date')->nullable(); }); - Schema::table('companies', function($table) - { + Schema::table('companies', function ($table) { $table->string('utm_source')->nullable(); $table->string('utm_medium')->nullable(); $table->string('utm_campaign')->nullable(); @@ -30,25 +27,22 @@ class AddInvoiceSignature extends Migration }); if (Utils::isNinja()) { - Schema::table('payment_methods', function($table) - { + Schema::table('payment_methods', function ($table) { $table->unsignedInteger('account_gateway_token_id')->nullable()->change(); $table->dropForeign('payment_methods_account_gateway_token_id_foreign'); }); - Schema::table('payment_methods', function($table) - { + Schema::table('payment_methods', function ($table) { $table->foreign('account_gateway_token_id')->references('id')->on('account_gateway_tokens')->onDelete('cascade'); }); - Schema::table('payments', function($table) - { + Schema::table('payments', function ($table) { $table->dropForeign('payments_payment_method_id_foreign'); }); - Schema::table('payments', function($table) - { - $table->foreign('payment_method_id')->references('id')->on('payment_methods')->onDelete('cascade');; + Schema::table('payments', function ($table) { + $table->foreign('payment_method_id')->references('id')->on('payment_methods')->onDelete('cascade'); + ; }); } } @@ -61,14 +55,12 @@ class AddInvoiceSignature extends Migration */ public function down() { - Schema::table('invitations', function($table) - { + Schema::table('invitations', function ($table) { $table->dropColumn('signature_base64'); $table->dropColumn('signature_date'); }); - Schema::table('companies', function($table) - { + Schema::table('companies', function ($table) { $table->dropColumn('utm_source'); $table->dropColumn('utm_medium'); $table->dropColumn('utm_campaign'); diff --git a/database/migrations/2016_11_03_161149_add_bluevine_fields.php b/database/migrations/2016_11_03_161149_add_bluevine_fields.php index bc7e57ff5d..0bee1d0b2a 100644 --- a/database/migrations/2016_11_03_161149_add_bluevine_fields.php +++ b/database/migrations/2016_11_03_161149_add_bluevine_fields.php @@ -3,26 +3,29 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class AddBluevineFields extends Migration { - /** - * Run the migrations. - * - * @return void - */ - public function up() { - Schema::table( 'accounts', function ( $table ) { - $table->enum( 'bluevine_status', array( 'ignored', 'signed_up' ) )->nullable(); - } ); - } +class AddBluevineFields extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::table('accounts', function ($table) { + $table->enum('bluevine_status', array( 'ignored', 'signed_up' ))->nullable(); + }); + } - /** - * Reverse the migrations. - * - * @return void - */ - public function down() { - Schema::table( 'accounts', function ( $table ) { - $table->dropColumn( 'bluevine_status' ); - } ); - } + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('accounts', function ($table) { + $table->dropColumn('bluevine_status'); + }); + } } diff --git a/database/migrations/2016_11_28_092904_add_task_projects.php b/database/migrations/2016_11_28_092904_add_task_projects.php index 696b7121b3..1359b1272a 100644 --- a/database/migrations/2016_11_28_092904_add_task_projects.php +++ b/database/migrations/2016_11_28_092904_add_task_projects.php @@ -12,8 +12,7 @@ class AddTaskProjects extends Migration */ public function up() { - Schema::create('projects', function($table) - { + Schema::create('projects', function ($table) { $table->increments('id'); $table->unsignedInteger('user_id'); $table->unsignedInteger('account_id')->index(); @@ -29,11 +28,10 @@ class AddTaskProjects extends Migration $table->foreign('client_id')->references('id')->on('clients')->onDelete('cascade'); $table->unsignedInteger('public_id')->index(); - $table->unique( array('account_id','public_id') ); + $table->unique(array('account_id','public_id')); }); - Schema::table('tasks', function ($table) - { + Schema::table('tasks', function ($table) { $table->unsignedInteger('project_id')->nullable()->index(); if (Schema::hasColumn('tasks', 'description')) { @@ -42,36 +40,30 @@ class AddTaskProjects extends Migration }); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); - Schema::table('tasks', function ($table) - { + Schema::table('tasks', function ($table) { $table->foreign('project_id')->references('id')->on('projects')->onDelete('cascade'); }); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); // is_deleted to standardize tables - Schema::table('expense_categories', function ($table) - { + Schema::table('expense_categories', function ($table) { $table->boolean('is_deleted')->default(false); }); - Schema::table('products', function ($table) - { + Schema::table('products', function ($table) { $table->boolean('is_deleted')->default(false); }); // add 'delete cascase' to resolve error when deleting an account - Schema::table('account_gateway_tokens', function($table) - { + Schema::table('account_gateway_tokens', function ($table) { $table->dropForeign('account_gateway_tokens_default_payment_method_id_foreign'); }); - Schema::table('account_gateway_tokens', function($table) - { + Schema::table('account_gateway_tokens', function ($table) { $table->foreign('default_payment_method_id')->references('id')->on('payment_methods')->onDelete('cascade'); }); - Schema::table('invoices', function ($table) - { + Schema::table('invoices', function ($table) { $table->boolean('is_public')->default(false); }); DB::table('invoices')->update(['is_public' => true]); @@ -84,26 +76,22 @@ class AddTaskProjects extends Migration */ public function down() { - Schema::table('tasks', function ($table) - { + Schema::table('tasks', function ($table) { $table->dropForeign('tasks_project_id_foreign'); $table->dropColumn('project_id'); }); Schema::dropIfExists('projects'); - Schema::table('expense_categories', function ($table) - { + Schema::table('expense_categories', function ($table) { $table->dropColumn('is_deleted'); }); - Schema::table('products', function ($table) - { + Schema::table('products', function ($table) { $table->dropColumn('is_deleted'); }); - Schema::table('invoices', function ($table) - { + Schema::table('invoices', function ($table) { $table->dropColumn('is_public'); }); } diff --git a/database/migrations/2016_12_13_113955_add_pro_plan_discount.php b/database/migrations/2016_12_13_113955_add_pro_plan_discount.php index c04b810e2b..3dd64497f6 100644 --- a/database/migrations/2016_12_13_113955_add_pro_plan_discount.php +++ b/database/migrations/2016_12_13_113955_add_pro_plan_discount.php @@ -12,8 +12,7 @@ class AddProPlanDiscount extends Migration */ public function up() { - Schema::table('companies', function ($table) - { + Schema::table('companies', function ($table) { $table->float('discount'); $table->date('discount_expires')->nullable(); $table->date('promo_expires')->nullable(); @@ -27,8 +26,7 @@ class AddProPlanDiscount extends Migration */ public function down() { - Schema::table('companies', function ($table) - { + Schema::table('companies', function ($table) { $table->dropColumn('discount'); $table->dropColumn('discount_expires'); $table->dropColumn('promo_expires'); diff --git a/database/migrations/2017_01_01_214241_add_inclusive_taxes.php b/database/migrations/2017_01_01_214241_add_inclusive_taxes.php index 4eebbe95e3..b0711c021c 100644 --- a/database/migrations/2017_01_01_214241_add_inclusive_taxes.php +++ b/database/migrations/2017_01_01_214241_add_inclusive_taxes.php @@ -12,22 +12,19 @@ class AddInclusiveTaxes extends Migration */ public function up() { - Schema::table('tax_rates', function($table) - { + Schema::table('tax_rates', function ($table) { $table->boolean('is_inclusive')->default(false); }); - Schema::table('companies', function ($table) - { - $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable(); - }); + Schema::table('companies', function ($table) { + $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable(); + }); DB::statement('UPDATE companies LEFT JOIN accounts ON accounts.company_id = companies.id AND accounts.bluevine_status IS NOT NULL SET companies.bluevine_status = accounts.bluevine_status'); - Schema::table('accounts', function($table) - { + Schema::table('accounts', function ($table) { $table->dropColumn('bluevine_status'); $table->text('bcc_email')->nullable(); $table->text('client_number_prefix')->nullable(); @@ -37,15 +34,13 @@ class AddInclusiveTaxes extends Migration $table->tinyInteger('payment_terms')->nullable(); }); - Schema::table('activities', function ($table) - { - $table->text('notes')->nullable(); - }); + Schema::table('activities', function ($table) { + $table->text('notes')->nullable(); + }); - Schema::table('date_formats', function ($table) - { - $table->string('format_moment')->nullable(); - }); + Schema::table('date_formats', function ($table) { + $table->string('format_moment')->nullable(); + }); } /** @@ -55,35 +50,30 @@ class AddInclusiveTaxes extends Migration */ public function down() { - Schema::table('tax_rates', function($table) - { + Schema::table('tax_rates', function ($table) { $table->dropColumn('is_inclusive'); }); - Schema::table('companies', function($table) - { + Schema::table('companies', function ($table) { $table->dropColumn('bluevine_status'); }); - Schema::table('accounts', function ($table) - { - $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable(); + Schema::table('accounts', function ($table) { + $table->enum('bluevine_status', ['ignored', 'signed_up'])->nullable(); $table->dropColumn('bcc_email'); $table->dropColumn('client_number_prefix'); $table->dropColumn('client_number_counter'); $table->dropColumn('client_number_pattern'); $table->dropColumn('domain_id'); $table->dropColumn('payment_terms'); - }); + }); - Schema::table('activities', function ($table) - { - $table->dropColumn('notes'); - }); + Schema::table('activities', function ($table) { + $table->dropColumn('notes'); + }); - Schema::table('date_formats', function ($table) - { - $table->dropColumn('format_moment'); - }); + Schema::table('date_formats', function ($table) { + $table->dropColumn('format_moment'); + }); } } diff --git a/database/seeds/BanksSeeder.php b/database/seeds/BanksSeeder.php index 3f2a0cf4ce..5e0e9808bb 100644 --- a/database/seeds/BanksSeeder.php +++ b/database/seeds/BanksSeeder.php @@ -22,7 +22,7 @@ class BanksSeeder extends Seeder foreach ($banks as $bank) { if (!DB::table('banks')->where('remote_id', '=', $bank->id)->get()) { - if ( ! isset($bank->fid) || ! isset($bank->org)) { + if (! isset($bank->fid) || ! isset($bank->org)) { continue; } diff --git a/database/seeds/ConstantsSeeder.php b/database/seeds/ConstantsSeeder.php index 299cc2a669..f627b341d4 100644 --- a/database/seeds/ConstantsSeeder.php +++ b/database/seeds/ConstantsSeeder.php @@ -1,4 +1,4 @@ - 'amelia')); + Theme::create(array('name' => 'cerulean')); + Theme::create(array('name' => 'cosmo')); + Theme::create(array('name' => 'cyborg')); + Theme::create(array('name' => 'flatly')); + Theme::create(array('name' => 'journal')); + Theme::create(array('name' => 'readable')); + Theme::create(array('name' => 'simplex')); + Theme::create(array('name' => 'slate')); + Theme::create(array('name' => 'spacelab')); + Theme::create(array('name' => 'united')); + Theme::create(array('name' => 'yeti')); - public function run() - { - Theme::create(array('name' => 'amelia')); - Theme::create(array('name' => 'cerulean')); - Theme::create(array('name' => 'cosmo')); - Theme::create(array('name' => 'cyborg')); - Theme::create(array('name' => 'flatly')); - Theme::create(array('name' => 'journal')); - Theme::create(array('name' => 'readable')); - Theme::create(array('name' => 'simplex')); - Theme::create(array('name' => 'slate')); - Theme::create(array('name' => 'spacelab')); - Theme::create(array('name' => 'united')); - Theme::create(array('name' => 'yeti')); + Frequency::create(array('name' => 'Weekly')); + Frequency::create(array('name' => 'Two weeks')); + Frequency::create(array('name' => 'Four weeks')); + Frequency::create(array('name' => 'Monthly')); + Frequency::create(array('name' => 'Three months')); + Frequency::create(array('name' => 'Six months')); + Frequency::create(array('name' => 'Annually')); - Frequency::create(array('name' => 'Weekly')); - Frequency::create(array('name' => 'Two weeks')); - Frequency::create(array('name' => 'Four weeks')); - Frequency::create(array('name' => 'Monthly')); - Frequency::create(array('name' => 'Three months')); - Frequency::create(array('name' => 'Six months')); - Frequency::create(array('name' => 'Annually')); + Size::create(array('name' => '1 - 3')); + Size::create(array('name' => '4 - 10')); + Size::create(array('name' => '11 - 50')); + Size::create(array('name' => '51 - 100')); + Size::create(array('name' => '101 - 500')); + Size::create(array('name' => '500+')); - Size::create(array('name' => '1 - 3')); - Size::create(array('name' => '4 - 10')); - Size::create(array('name' => '11 - 50')); - Size::create(array('name' => '51 - 100')); - Size::create(array('name' => '101 - 500')); - Size::create(array('name' => '500+')); + PaymentTerm::create(array('num_days' => 7, 'name' => 'Net 7', 'public_id' => 1)); + PaymentTerm::create(array('num_days' => 10, 'name' => 'Net 10', 'public_id' => 2)); + PaymentTerm::create(array('num_days' => 14, 'name' => 'Net 14', 'public_id' => 3)); + PaymentTerm::create(array('num_days' => 15, 'name' => 'Net 15', 'public_id' => 4)); + PaymentTerm::create(array('num_days' => 30, 'name' => 'Net 30', 'public_id' => 5)); + PaymentTerm::create(array('num_days' => 60, 'name' => 'Net 60', 'public_id' => 6)); + PaymentTerm::create(array('num_days' => 90, 'name' => 'Net 90', 'public_id' => 7)); - PaymentTerm::create(array('num_days' => 7, 'name' => 'Net 7', 'public_id' => 1)); - PaymentTerm::create(array('num_days' => 10, 'name' => 'Net 10', 'public_id' => 2)); - PaymentTerm::create(array('num_days' => 14, 'name' => 'Net 14', 'public_id' => 3)); - PaymentTerm::create(array('num_days' => 15, 'name' => 'Net 15', 'public_id' => 4)); - PaymentTerm::create(array('num_days' => 30, 'name' => 'Net 30', 'public_id' => 5)); - PaymentTerm::create(array('num_days' => 60, 'name' => 'Net 60', 'public_id' => 6)); - PaymentTerm::create(array('num_days' => 90, 'name' => 'Net 90', 'public_id' => 7)); + PaymentLibrary::create(['name' => 'Omnipay']); + PaymentLibrary::create(['name' => 'PHP-Payments [Deprecated]']); - PaymentLibrary::create(['name' => 'Omnipay']); - PaymentLibrary::create(['name' => 'PHP-Payments [Deprecated]']); + /* + d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05. + D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday. + m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07. + M, MM: Abbreviated and full month names, respectively. Eg, Jan, January + yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.) + */ - /* - d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05. - D, DD: Abbreviated and full weekday names, respectively. Eg, Mon, Monday. - m, mm: Numeric month, no leading zero and leading zero, respectively. Eg, 7, 07. - M, MM: Abbreviated and full month names, respectively. Eg, Jan, January - yy, yyyy: 2- and 4-digit years, respectively. Eg, 12, 2012.) - */ + $timezones = array( + 'Pacific/Midway' => "(GMT-11:00) Midway Island", + 'US/Samoa' => "(GMT-11:00) Samoa", + 'US/Hawaii' => "(GMT-10:00) Hawaii", + 'US/Alaska' => "(GMT-09:00) Alaska", + 'US/Pacific' => "(GMT-08:00) Pacific Time (US & Canada)", + 'America/Tijuana' => "(GMT-08:00) Tijuana", + 'US/Arizona' => "(GMT-07:00) Arizona", + 'US/Mountain' => "(GMT-07:00) Mountain Time (US & Canada)", + 'America/Chihuahua' => "(GMT-07:00) Chihuahua", + 'America/Mazatlan' => "(GMT-07:00) Mazatlan", + 'America/Mexico_City' => "(GMT-06:00) Mexico City", + 'America/Monterrey' => "(GMT-06:00) Monterrey", + 'Canada/Saskatchewan' => "(GMT-06:00) Saskatchewan", + 'US/Central' => "(GMT-06:00) Central Time (US & Canada)", + 'US/Eastern' => "(GMT-05:00) Eastern Time (US & Canada)", + 'US/East-Indiana' => "(GMT-05:00) Indiana (East)", + 'America/Bogota' => "(GMT-05:00) Bogota", + 'America/Lima' => "(GMT-05:00) Lima", + 'America/Caracas' => "(GMT-04:30) Caracas", + 'Canada/Atlantic' => "(GMT-04:00) Atlantic Time (Canada)", + 'America/La_Paz' => "(GMT-04:00) La Paz", + 'America/Santiago' => "(GMT-04:00) Santiago", + 'Canada/Newfoundland' => "(GMT-03:30) Newfoundland", + 'America/Buenos_Aires' => "(GMT-03:00) Buenos Aires", + 'America/Godthab' => "(GMT-03:00) Greenland", + 'Atlantic/Stanley' => "(GMT-02:00) Stanley", + 'Atlantic/Azores' => "(GMT-01:00) Azores", + 'Atlantic/Cape_Verde' => "(GMT-01:00) Cape Verde Is.", + 'Africa/Casablanca' => "(GMT) Casablanca", + 'Europe/Dublin' => "(GMT) Dublin", + 'Europe/Lisbon' => "(GMT) Lisbon", + 'Europe/London' => "(GMT) London", + 'Africa/Monrovia' => "(GMT) Monrovia", + 'Europe/Amsterdam' => "(GMT+01:00) Amsterdam", + 'Europe/Belgrade' => "(GMT+01:00) Belgrade", + 'Europe/Berlin' => "(GMT+01:00) Berlin", + 'Europe/Bratislava' => "(GMT+01:00) Bratislava", + 'Europe/Brussels' => "(GMT+01:00) Brussels", + 'Europe/Budapest' => "(GMT+01:00) Budapest", + 'Europe/Copenhagen' => "(GMT+01:00) Copenhagen", + 'Europe/Ljubljana' => "(GMT+01:00) Ljubljana", + 'Europe/Madrid' => "(GMT+01:00) Madrid", + 'Europe/Paris' => "(GMT+01:00) Paris", + 'Europe/Prague' => "(GMT+01:00) Prague", + 'Europe/Rome' => "(GMT+01:00) Rome", + 'Europe/Sarajevo' => "(GMT+01:00) Sarajevo", + 'Europe/Skopje' => "(GMT+01:00) Skopje", + 'Europe/Stockholm' => "(GMT+01:00) Stockholm", + 'Europe/Vienna' => "(GMT+01:00) Vienna", + 'Europe/Warsaw' => "(GMT+01:00) Warsaw", + 'Europe/Zagreb' => "(GMT+01:00) Zagreb", + 'Europe/Athens' => "(GMT+02:00) Athens", + 'Europe/Bucharest' => "(GMT+02:00) Bucharest", + 'Africa/Cairo' => "(GMT+02:00) Cairo", + 'Africa/Harare' => "(GMT+02:00) Harare", + 'Europe/Helsinki' => "(GMT+02:00) Helsinki", + 'Europe/Istanbul' => "(GMT+02:00) Istanbul", + 'Asia/Jerusalem' => "(GMT+02:00) Jerusalem", + 'Europe/Kiev' => "(GMT+02:00) Kyiv", + 'Europe/Minsk' => "(GMT+02:00) Minsk", + 'Europe/Riga' => "(GMT+02:00) Riga", + 'Europe/Sofia' => "(GMT+02:00) Sofia", + 'Europe/Tallinn' => "(GMT+02:00) Tallinn", + 'Europe/Vilnius' => "(GMT+02:00) Vilnius", + 'Asia/Baghdad' => "(GMT+03:00) Baghdad", + 'Asia/Kuwait' => "(GMT+03:00) Kuwait", + 'Africa/Nairobi' => "(GMT+03:00) Nairobi", + 'Asia/Riyadh' => "(GMT+03:00) Riyadh", + 'Asia/Tehran' => "(GMT+03:30) Tehran", + 'Europe/Moscow' => "(GMT+04:00) Moscow", + 'Asia/Baku' => "(GMT+04:00) Baku", + 'Europe/Volgograd' => "(GMT+04:00) Volgograd", + 'Asia/Muscat' => "(GMT+04:00) Muscat", + 'Asia/Tbilisi' => "(GMT+04:00) Tbilisi", + 'Asia/Yerevan' => "(GMT+04:00) Yerevan", + 'Asia/Kabul' => "(GMT+04:30) Kabul", + 'Asia/Karachi' => "(GMT+05:00) Karachi", + 'Asia/Tashkent' => "(GMT+05:00) Tashkent", + 'Asia/Kolkata' => "(GMT+05:30) Kolkata", + 'Asia/Kathmandu' => "(GMT+05:45) Kathmandu", + 'Asia/Yekaterinburg' => "(GMT+06:00) Ekaterinburg", + 'Asia/Almaty' => "(GMT+06:00) Almaty", + 'Asia/Dhaka' => "(GMT+06:00) Dhaka", + 'Asia/Novosibirsk' => "(GMT+07:00) Novosibirsk", + 'Asia/Bangkok' => "(GMT+07:00) Bangkok", + 'Asia/Ho_Chi_Minh' => "(GMT+07.00) Ho Chi Minh", + 'Asia/Jakarta' => "(GMT+07:00) Jakarta", + 'Asia/Krasnoyarsk' => "(GMT+08:00) Krasnoyarsk", + 'Asia/Chongqing' => "(GMT+08:00) Chongqing", + 'Asia/Hong_Kong' => "(GMT+08:00) Hong Kong", + 'Asia/Kuala_Lumpur' => "(GMT+08:00) Kuala Lumpur", + 'Australia/Perth' => "(GMT+08:00) Perth", + 'Asia/Singapore' => "(GMT+08:00) Singapore", + 'Asia/Taipei' => "(GMT+08:00) Taipei", + 'Asia/Ulaanbaatar' => "(GMT+08:00) Ulaan Bataar", + 'Asia/Urumqi' => "(GMT+08:00) Urumqi", + 'Asia/Irkutsk' => "(GMT+09:00) Irkutsk", + 'Asia/Seoul' => "(GMT+09:00) Seoul", + 'Asia/Tokyo' => "(GMT+09:00) Tokyo", + 'Australia/Adelaide' => "(GMT+09:30) Adelaide", + 'Australia/Darwin' => "(GMT+09:30) Darwin", + 'Asia/Yakutsk' => "(GMT+10:00) Yakutsk", + 'Australia/Brisbane' => "(GMT+10:00) Brisbane", + 'Australia/Canberra' => "(GMT+10:00) Canberra", + 'Pacific/Guam' => "(GMT+10:00) Guam", + 'Australia/Hobart' => "(GMT+10:00) Hobart", + 'Australia/Melbourne' => "(GMT+10:00) Melbourne", + 'Pacific/Port_Moresby' => "(GMT+10:00) Port Moresby", + 'Australia/Sydney' => "(GMT+10:00) Sydney", + 'Asia/Vladivostok' => "(GMT+11:00) Vladivostok", + 'Asia/Magadan' => "(GMT+12:00) Magadan", + 'Pacific/Auckland' => "(GMT+12:00) Auckland", + 'Pacific/Fiji' => "(GMT+12:00) Fiji", + ); - $timezones = array( - 'Pacific/Midway' => "(GMT-11:00) Midway Island", - 'US/Samoa' => "(GMT-11:00) Samoa", - 'US/Hawaii' => "(GMT-10:00) Hawaii", - 'US/Alaska' => "(GMT-09:00) Alaska", - 'US/Pacific' => "(GMT-08:00) Pacific Time (US & Canada)", - 'America/Tijuana' => "(GMT-08:00) Tijuana", - 'US/Arizona' => "(GMT-07:00) Arizona", - 'US/Mountain' => "(GMT-07:00) Mountain Time (US & Canada)", - 'America/Chihuahua' => "(GMT-07:00) Chihuahua", - 'America/Mazatlan' => "(GMT-07:00) Mazatlan", - 'America/Mexico_City' => "(GMT-06:00) Mexico City", - 'America/Monterrey' => "(GMT-06:00) Monterrey", - 'Canada/Saskatchewan' => "(GMT-06:00) Saskatchewan", - 'US/Central' => "(GMT-06:00) Central Time (US & Canada)", - 'US/Eastern' => "(GMT-05:00) Eastern Time (US & Canada)", - 'US/East-Indiana' => "(GMT-05:00) Indiana (East)", - 'America/Bogota' => "(GMT-05:00) Bogota", - 'America/Lima' => "(GMT-05:00) Lima", - 'America/Caracas' => "(GMT-04:30) Caracas", - 'Canada/Atlantic' => "(GMT-04:00) Atlantic Time (Canada)", - 'America/La_Paz' => "(GMT-04:00) La Paz", - 'America/Santiago' => "(GMT-04:00) Santiago", - 'Canada/Newfoundland' => "(GMT-03:30) Newfoundland", - 'America/Buenos_Aires' => "(GMT-03:00) Buenos Aires", - 'America/Godthab' => "(GMT-03:00) Greenland", - 'Atlantic/Stanley' => "(GMT-02:00) Stanley", - 'Atlantic/Azores' => "(GMT-01:00) Azores", - 'Atlantic/Cape_Verde' => "(GMT-01:00) Cape Verde Is.", - 'Africa/Casablanca' => "(GMT) Casablanca", - 'Europe/Dublin' => "(GMT) Dublin", - 'Europe/Lisbon' => "(GMT) Lisbon", - 'Europe/London' => "(GMT) London", - 'Africa/Monrovia' => "(GMT) Monrovia", - 'Europe/Amsterdam' => "(GMT+01:00) Amsterdam", - 'Europe/Belgrade' => "(GMT+01:00) Belgrade", - 'Europe/Berlin' => "(GMT+01:00) Berlin", - 'Europe/Bratislava' => "(GMT+01:00) Bratislava", - 'Europe/Brussels' => "(GMT+01:00) Brussels", - 'Europe/Budapest' => "(GMT+01:00) Budapest", - 'Europe/Copenhagen' => "(GMT+01:00) Copenhagen", - 'Europe/Ljubljana' => "(GMT+01:00) Ljubljana", - 'Europe/Madrid' => "(GMT+01:00) Madrid", - 'Europe/Paris' => "(GMT+01:00) Paris", - 'Europe/Prague' => "(GMT+01:00) Prague", - 'Europe/Rome' => "(GMT+01:00) Rome", - 'Europe/Sarajevo' => "(GMT+01:00) Sarajevo", - 'Europe/Skopje' => "(GMT+01:00) Skopje", - 'Europe/Stockholm' => "(GMT+01:00) Stockholm", - 'Europe/Vienna' => "(GMT+01:00) Vienna", - 'Europe/Warsaw' => "(GMT+01:00) Warsaw", - 'Europe/Zagreb' => "(GMT+01:00) Zagreb", - 'Europe/Athens' => "(GMT+02:00) Athens", - 'Europe/Bucharest' => "(GMT+02:00) Bucharest", - 'Africa/Cairo' => "(GMT+02:00) Cairo", - 'Africa/Harare' => "(GMT+02:00) Harare", - 'Europe/Helsinki' => "(GMT+02:00) Helsinki", - 'Europe/Istanbul' => "(GMT+02:00) Istanbul", - 'Asia/Jerusalem' => "(GMT+02:00) Jerusalem", - 'Europe/Kiev' => "(GMT+02:00) Kyiv", - 'Europe/Minsk' => "(GMT+02:00) Minsk", - 'Europe/Riga' => "(GMT+02:00) Riga", - 'Europe/Sofia' => "(GMT+02:00) Sofia", - 'Europe/Tallinn' => "(GMT+02:00) Tallinn", - 'Europe/Vilnius' => "(GMT+02:00) Vilnius", - 'Asia/Baghdad' => "(GMT+03:00) Baghdad", - 'Asia/Kuwait' => "(GMT+03:00) Kuwait", - 'Africa/Nairobi' => "(GMT+03:00) Nairobi", - 'Asia/Riyadh' => "(GMT+03:00) Riyadh", - 'Asia/Tehran' => "(GMT+03:30) Tehran", - 'Europe/Moscow' => "(GMT+04:00) Moscow", - 'Asia/Baku' => "(GMT+04:00) Baku", - 'Europe/Volgograd' => "(GMT+04:00) Volgograd", - 'Asia/Muscat' => "(GMT+04:00) Muscat", - 'Asia/Tbilisi' => "(GMT+04:00) Tbilisi", - 'Asia/Yerevan' => "(GMT+04:00) Yerevan", - 'Asia/Kabul' => "(GMT+04:30) Kabul", - 'Asia/Karachi' => "(GMT+05:00) Karachi", - 'Asia/Tashkent' => "(GMT+05:00) Tashkent", - 'Asia/Kolkata' => "(GMT+05:30) Kolkata", - 'Asia/Kathmandu' => "(GMT+05:45) Kathmandu", - 'Asia/Yekaterinburg' => "(GMT+06:00) Ekaterinburg", - 'Asia/Almaty' => "(GMT+06:00) Almaty", - 'Asia/Dhaka' => "(GMT+06:00) Dhaka", - 'Asia/Novosibirsk' => "(GMT+07:00) Novosibirsk", - 'Asia/Bangkok' => "(GMT+07:00) Bangkok", - 'Asia/Ho_Chi_Minh' => "(GMT+07.00) Ho Chi Minh", - 'Asia/Jakarta' => "(GMT+07:00) Jakarta", - 'Asia/Krasnoyarsk' => "(GMT+08:00) Krasnoyarsk", - 'Asia/Chongqing' => "(GMT+08:00) Chongqing", - 'Asia/Hong_Kong' => "(GMT+08:00) Hong Kong", - 'Asia/Kuala_Lumpur' => "(GMT+08:00) Kuala Lumpur", - 'Australia/Perth' => "(GMT+08:00) Perth", - 'Asia/Singapore' => "(GMT+08:00) Singapore", - 'Asia/Taipei' => "(GMT+08:00) Taipei", - 'Asia/Ulaanbaatar' => "(GMT+08:00) Ulaan Bataar", - 'Asia/Urumqi' => "(GMT+08:00) Urumqi", - 'Asia/Irkutsk' => "(GMT+09:00) Irkutsk", - 'Asia/Seoul' => "(GMT+09:00) Seoul", - 'Asia/Tokyo' => "(GMT+09:00) Tokyo", - 'Australia/Adelaide' => "(GMT+09:30) Adelaide", - 'Australia/Darwin' => "(GMT+09:30) Darwin", - 'Asia/Yakutsk' => "(GMT+10:00) Yakutsk", - 'Australia/Brisbane' => "(GMT+10:00) Brisbane", - 'Australia/Canberra' => "(GMT+10:00) Canberra", - 'Pacific/Guam' => "(GMT+10:00) Guam", - 'Australia/Hobart' => "(GMT+10:00) Hobart", - 'Australia/Melbourne' => "(GMT+10:00) Melbourne", - 'Pacific/Port_Moresby' => "(GMT+10:00) Port Moresby", - 'Australia/Sydney' => "(GMT+10:00) Sydney", - 'Asia/Vladivostok' => "(GMT+11:00) Vladivostok", - 'Asia/Magadan' => "(GMT+12:00) Magadan", - 'Pacific/Auckland' => "(GMT+12:00) Auckland", - 'Pacific/Fiji' => "(GMT+12:00) Fiji", - ); - - foreach ($timezones as $name => $location) { - Timezone::create(array('name'=>$name, 'location'=>$location)); - } - } + foreach ($timezones as $name => $location) { + Timezone::create(array('name'=>$name, 'location'=>$location)); + } + } } diff --git a/database/seeds/CountriesSeeder.php b/database/seeds/CountriesSeeder.php index 570cb51e6c..efbbcfb9bf 100644 --- a/database/seeds/CountriesSeeder.php +++ b/database/seeds/CountriesSeeder.php @@ -2,7 +2,8 @@ use Illuminate\Database\Eloquent\Model as Eloquent; use App\Models\Country; -class CountriesSeeder extends Seeder { +class CountriesSeeder extends Seeder +{ /** * Run the database seeds. @@ -17,7 +18,7 @@ class CountriesSeeder extends Seeder { if (DB::table('countries')->count() == 0) { //Get all of the countries $countries = Countries::getList(); - foreach ($countries as $countryId => $country){ + foreach ($countries as $countryId => $country) { DB::table('countries')->insert(array( 'id' => $countryId, 'capital' => ((isset($country['capital'])) ? $country['capital'] : null), @@ -170,4 +171,4 @@ class CountriesSeeder extends Seeder { $country->save(); } } -} \ No newline at end of file +} diff --git a/database/seeds/CurrenciesSeeder.php b/database/seeds/CurrenciesSeeder.php index f3e320f9d8..2fabdd4c57 100644 --- a/database/seeds/CurrenciesSeeder.php +++ b/database/seeds/CurrenciesSeeder.php @@ -72,7 +72,7 @@ class CurrenciesSeeder extends Seeder $record->symbol = $currency['symbol']; $record->thousand_separator = $currency['thousand_separator']; $record->decimal_separator = $currency['decimal_separator']; - if(isset($currency['swap_currency_symbol'])){ + if (isset($currency['swap_currency_symbol'])) { $record->swap_currency_symbol = $currency['swap_currency_symbol']; } $record->save(); diff --git a/database/seeds/GatewayTypesSeeder.php b/database/seeds/GatewayTypesSeeder.php index dc556e89fd..a8ecf474b2 100644 --- a/database/seeds/GatewayTypesSeeder.php +++ b/database/seeds/GatewayTypesSeeder.php @@ -24,6 +24,5 @@ class GatewayTypesSeeder extends Seeder GatewayType::create($gateway_type); } } - } } diff --git a/database/seeds/IndustrySeeder.php b/database/seeds/IndustrySeeder.php index f6461b950a..910d90cf0a 100644 --- a/database/seeds/IndustrySeeder.php +++ b/database/seeds/IndustrySeeder.php @@ -10,42 +10,42 @@ class IndustrySeeder extends Seeder $industries = [ ['name' => 'Accounting & Legal'], - ['name' => 'Advertising'], - ['name' => 'Aerospace'], - ['name' => 'Agriculture'], - ['name' => 'Automotive'], - ['name' => 'Banking & Finance'], - ['name' => 'Biotechnology'], - ['name' => 'Broadcasting'], - ['name' => 'Business Services'], - ['name' => 'Commodities & Chemicals'], - ['name' => 'Communications'], - ['name' => 'Computers & Hightech'], - ['name' => 'Defense'], - ['name' => 'Energy'], - ['name' => 'Entertainment'], - ['name' => 'Government'], - ['name' => 'Healthcare & Life Sciences'], - ['name' => 'Insurance'], - ['name' => 'Manufacturing'], - ['name' => 'Marketing'], - ['name' => 'Media'], - ['name' => 'Nonprofit & Higher Ed'], - ['name' => 'Pharmaceuticals'], - ['name' => 'Professional Services & Consulting'], - ['name' => 'Real Estate'], - ['name' => 'Retail & Wholesale'], - ['name' => 'Sports'], - ['name' => 'Transportation'], - ['name' => 'Travel & Luxury'], - ['name' => 'Other'], - ['name' => 'Photography'], + ['name' => 'Advertising'], + ['name' => 'Aerospace'], + ['name' => 'Agriculture'], + ['name' => 'Automotive'], + ['name' => 'Banking & Finance'], + ['name' => 'Biotechnology'], + ['name' => 'Broadcasting'], + ['name' => 'Business Services'], + ['name' => 'Commodities & Chemicals'], + ['name' => 'Communications'], + ['name' => 'Computers & Hightech'], + ['name' => 'Defense'], + ['name' => 'Energy'], + ['name' => 'Entertainment'], + ['name' => 'Government'], + ['name' => 'Healthcare & Life Sciences'], + ['name' => 'Insurance'], + ['name' => 'Manufacturing'], + ['name' => 'Marketing'], + ['name' => 'Media'], + ['name' => 'Nonprofit & Higher Ed'], + ['name' => 'Pharmaceuticals'], + ['name' => 'Professional Services & Consulting'], + ['name' => 'Real Estate'], + ['name' => 'Retail & Wholesale'], + ['name' => 'Sports'], + ['name' => 'Transportation'], + ['name' => 'Travel & Luxury'], + ['name' => 'Other'], + ['name' => 'Photography'], ['name' => 'Construction'], ]; foreach ($industries as $industry) { $record = Industry::whereName($industry['name'])->first(); - if ( ! $record) { + if (! $record) { Industry::create($industry); } } diff --git a/database/seeds/InvoiceDesignsSeeder.php b/database/seeds/InvoiceDesignsSeeder.php index 0e07067e1e..94fd0d5574 100644 --- a/database/seeds/InvoiceDesignsSeeder.php +++ b/database/seeds/InvoiceDesignsSeeder.php @@ -39,5 +39,4 @@ class InvoiceDesignsSeeder extends Seeder } } } - } diff --git a/database/seeds/InvoiceStatusSeeder.php b/database/seeds/InvoiceStatusSeeder.php index 2b551ae7ea..06b63c1a07 100644 --- a/database/seeds/InvoiceStatusSeeder.php +++ b/database/seeds/InvoiceStatusSeeder.php @@ -33,6 +33,5 @@ class InvoiceStatusSeeder extends Seeder InvoiceStatus::create($status); } } - } + } } - diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index 73a67020e9..ddfd639fd5 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -88,6 +88,5 @@ class PaymentLibrariesSeeder extends Seeder Gateway::create($gateway); } } - } } diff --git a/database/seeds/PaymentTermsSeeder.php b/database/seeds/PaymentTermsSeeder.php index 3dd8c48533..3ef8c8258c 100644 --- a/database/seeds/PaymentTermsSeeder.php +++ b/database/seeds/PaymentTermsSeeder.php @@ -18,5 +18,4 @@ class PaymentTermsSeeder extends Seeder } } } - } diff --git a/database/seeds/PaymentTypesSeeder.php b/database/seeds/PaymentTypesSeeder.php index b1c8bbeaba..59d2c18f4d 100644 --- a/database/seeds/PaymentTypesSeeder.php +++ b/database/seeds/PaymentTypesSeeder.php @@ -39,7 +39,7 @@ class PaymentTypesSeeder extends Seeder foreach ($paymentTypes as $paymentType) { $record = PaymentType::where('name', '=', $paymentType['name'])->first(); - if ( $record) { + if ($record) { $record->name = $paymentType['name']; $record->gateway_type_id = ! empty($paymentType['gateway_type_id']) ? $paymentType['gateway_type_id'] : null; @@ -49,5 +49,4 @@ class PaymentTypesSeeder extends Seeder } } } - } diff --git a/database/seeds/UserTableSeeder.php b/database/seeds/UserTableSeeder.php index 7d68e5ad9c..49b636c4d1 100644 --- a/database/seeds/UserTableSeeder.php +++ b/database/seeds/UserTableSeeder.php @@ -15,9 +15,8 @@ use Faker\Factory; class UserTableSeeder extends Seeder { - - public function run() - { + public function run() + { $this->command->info('Running UserTableSeeder'); Eloquent::unguard(); @@ -81,7 +80,7 @@ class UserTableSeeder extends Seeder 'public_id' => 1, 'email' => env('TEST_EMAIL', TEST_USERNAME), 'is_primary' => true, - 'send_invoice' => true, + 'send_invoice' => true, ]); Product::create([ @@ -96,7 +95,5 @@ class UserTableSeeder extends Seeder Affiliate::create([ 'affiliate_key' => SELF_HOST_AFFILIATE_KEY ]); - - } - + } }