From eb049d8ee6fd9f52580d47d664533bb492f62770 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Holger=20Lo=CC=88sken?=
Date: Sun, 3 Jul 2016 18:11:58 +0200
Subject: [PATCH] Code Refactoring
- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
---
.../Commands/ChargeRenewalInvoices.php | 45 +-
app/Console/Commands/CheckData.php | 32 +-
app/Console/Commands/CreateTestData.php | 58 ++-
app/Console/Commands/GenerateResources.php | 41 +-
app/Console/Commands/Inspire.php | 3 +
app/Console/Commands/PruneData.php | 24 +-
.../Commands/RemoveOrphanedDocuments.php | 25 +-
app/Console/Commands/ResetData.php | 39 +-
.../Commands/SendRecurringInvoices.php | 53 +-
app/Console/Commands/SendReminders.php | 59 ++-
app/Console/Commands/SendRenewalInvoices.php | 46 +-
app/Console/Commands/TestOFX.php | 30 +-
app/Events/ClientWasArchived.php | 12 +-
app/Events/ClientWasCreated.php | 12 +-
app/Events/ClientWasDeleted.php | 12 +-
app/Events/ClientWasRestored.php | 12 +-
app/Events/ClientWasUpdated.php | 12 +-
app/Events/CreditWasArchived.php | 31 +-
app/Events/CreditWasCreated.php | 25 +-
app/Events/CreditWasDeleted.php | 23 +-
app/Events/CreditWasRestored.php | 22 +-
app/Events/Event.php | 6 +-
app/Events/ExpenseWasArchived.php | 28 +-
app/Events/ExpenseWasCreated.php | 24 +-
app/Events/ExpenseWasDeleted.php | 29 +-
app/Events/ExpenseWasRestored.php | 28 +-
app/Events/ExpenseWasUpdated.php | 12 +-
app/Events/InvoiceInvitationWasEmailed.php | 27 +-
app/Events/InvoiceInvitationWasViewed.php | 30 +-
app/Events/InvoiceWasArchived.php | 26 +-
app/Events/InvoiceWasCreated.php | 28 +-
app/Events/InvoiceWasDeleted.php | 27 +-
app/Events/InvoiceWasEmailed.php | 29 +-
app/Events/InvoiceWasRestored.php | 28 +-
app/Events/InvoiceWasUpdated.php | 33 +-
app/Events/PaymentCompleted.php | 17 +-
app/Events/PaymentFailed.php | 18 +-
app/Events/PaymentWasArchived.php | 32 +-
app/Events/PaymentWasCreated.php | 29 +-
app/Events/PaymentWasDeleted.php | 31 +-
app/Events/PaymentWasRefunded.php | 30 +-
app/Events/PaymentWasRestored.php | 29 +-
app/Events/PaymentWasVoided.php | 19 +-
app/Events/QuoteInvitationWasApproved.php | 34 +-
app/Events/QuoteInvitationWasEmailed.php | 29 +-
app/Events/QuoteInvitationWasViewed.php | 28 +-
app/Events/QuoteWasArchived.php | 26 +-
app/Events/QuoteWasCreated.php | 24 +-
app/Events/QuoteWasDeleted.php | 24 +-
app/Events/QuoteWasEmailed.php | 24 +-
app/Events/QuoteWasRestored.php | 24 +-
app/Events/QuoteWasUpdated.php | 29 +-
app/Events/UserLoggedIn.php | 27 +-
app/Events/UserSettingsChanged.php | 29 +-
app/Events/UserSignedUp.php | 27 +-
app/Events/VendorWasArchived.php | 12 +-
app/Events/VendorWasCreated.php | 13 +-
app/Events/VendorWasDeleted.php | 13 +-
app/Events/VendorWasRestored.php | 13 +-
app/Events/VendorWasUpdated.php | 14 +-
app/Exceptions/Handler.php | 26 +-
app/Http/Controllers/AccountApiController.php | 12 -
app/Http/Controllers/AccountController.php | 246 +++++++--
.../Controllers/AccountGatewayController.php | 30 +-
app/Http/Controllers/ActivityController.php | 7 -
app/Http/Controllers/AppController.php | 26 +-
app/Http/Controllers/Auth/AuthController.php | 91 ++--
.../Controllers/Auth/PasswordController.php | 51 +-
.../Controllers/BankAccountController.php | 7 -
app/Http/Controllers/BaseAPIController.php | 4 -
app/Http/Controllers/BaseController.php | 4 -
app/Http/Controllers/ClientApiController.php | 5 -
.../Controllers/ClientAuth/AuthController.php | 57 ++-
.../ClientAuth/PasswordController.php | 115 ++---
app/Http/Controllers/ClientController.php | 22 +-
.../Controllers/ClientPortalController.php | 29 +-
app/Http/Controllers/Controller.php | 10 +-
app/Http/Controllers/CreditController.php | 10 +-
.../Controllers/DashboardApiController.php | 2 -
app/Http/Controllers/DashboardController.php | 6 +
.../Controllers/DocumentAPIController.php | 38 +-
app/Http/Controllers/DocumentController.php | 11 +-
app/Http/Controllers/ExpenseApiController.php | 6 -
app/Http/Controllers/ExpenseController.php | 21 +-
app/Http/Controllers/ExportController.php | 38 +-
app/Http/Controllers/HomeController.php | 40 +-
app/Http/Controllers/ImportController.php | 1 -
.../Controllers/IntegrationController.php | 6 +
app/Http/Controllers/InvoiceApiController.php | 4 -
app/Http/Controllers/InvoiceController.php | 52 +-
app/Http/Controllers/NinjaController.php | 39 +-
.../Controllers/OnlinePaymentController.php | 52 +-
app/Http/Controllers/PaymentApiController.php | 6 -
app/Http/Controllers/PaymentController.php | 75 ++-
.../Controllers/PaymentTermController.php | 41 +-
app/Http/Controllers/ProductApiController.php | 35 +-
app/Http/Controllers/ProductController.php | 43 +-
app/Http/Controllers/QuoteApiController.php | 5 -
app/Http/Controllers/QuoteController.php | 15 +-
.../RecurringInvoiceController.php | 13 +
app/Http/Controllers/ReportController.php | 67 +++
app/Http/Controllers/TaskApiController.php | 2 -
app/Http/Controllers/TaskController.php | 88 +++-
app/Http/Controllers/TaxRateApiController.php | 22 +-
app/Http/Controllers/TaxRateController.php | 6 -
app/Http/Controllers/TokenController.php | 43 +-
app/Http/Controllers/UserApiController.php | 1 -
app/Http/Controllers/UserController.php | 5 -
app/Http/Controllers/VendorApiController.php | 3 -
app/Http/Controllers/VendorController.php | 21 +-
app/Http/Middleware/ApiCheck.php | 4 +-
app/Http/Middleware/Authenticate.php | 186 +++----
.../Middleware/DuplicateSubmissionCheck.php | 18 +-
app/Http/Middleware/PermissionsRequired.php | 80 +--
app/Http/Middleware/QueryLogging.php | 11 +-
.../Middleware/RedirectIfAuthenticated.php | 67 +--
app/Http/Middleware/StartupCheck.php | 11 +-
app/Http/Middleware/VerifyCsrfToken.php | 47 +-
.../Requests/CreateBankAccountRequest.php | 3 +-
app/Http/Requests/CreatePaymentAPIRequest.php | 4 +-
app/Http/Requests/CreatePaymentRequest.php | 4 +-
app/Http/Requests/CreateTaxRateRequest.php | 3 +-
app/Http/Requests/EntityRequest.php | 1 -
app/Http/Requests/RegisterRequest.php | 4 -
app/Http/Requests/Request.php | 2 +-
app/Http/Requests/UpdateAccountRequest.php | 3 +-
app/Http/Requests/UpdateTaxRateRequest.php | 3 +-
app/Http/Requests/UpdateUserRequest.php | 2 -
app/Http/routes.php | 82 +--
app/Includes/parsecsv.lib.php | 48 +-
app/Libraries/OFX.php | 38 +-
app/Libraries/Utils.php | 25 +-
app/Libraries/lib_autolink.php | 10 +-
app/Listeners/ActivityListener.php | 105 +++-
app/Listeners/AnalyticsListener.php | 15 +-
app/Listeners/CreditListener.php | 17 +-
app/Listeners/ExpenseListener.php | 15 +-
app/Listeners/HandleUserLoggedIn.php | 21 +-
app/Listeners/HandleUserSettingsChanged.php | 12 +-
app/Listeners/HandleUserSignedUp.php | 17 +-
app/Listeners/InvoiceListener.php | 31 +-
app/Listeners/NotificationListener.php | 45 +-
app/Listeners/QuoteListener.php | 9 +-
app/Listeners/SubscriptionListener.php | 35 +-
app/Listeners/TaskListener.php | 6 +
app/Models/Account.php | 466 ++++++++++++++++--
app/Models/AccountGateway.php | 73 ++-
app/Models/AccountGatewayToken.php | 36 ++
app/Models/AccountToken.php | 15 +
app/Models/Activity.php | 38 +-
app/Models/Affiliate.php | 9 +
app/Models/BalanceAffecting.php | 3 +
app/Models/Bank.php | 10 +
app/Models/BankAccount.php | 17 +-
app/Models/BankSubaccount.php | 15 +-
app/Models/Client.php | 143 +++++-
app/Models/Company.php | 16 +-
app/Models/Contact.php | 55 ++-
app/Models/Country.php | 15 +
app/Models/Credit.php | 31 ++
app/Models/Currency.php | 12 +
app/Models/DateFormat.php | 9 +
app/Models/DatetimeFormat.php | 9 +
app/Models/Document.php | 157 ++++--
app/Models/EntityModel.php | 54 ++
app/Models/Expense.php | 57 +++
app/Models/ExpenseCategory.php | 10 +-
app/Models/Font.php | 6 +
app/Models/Frequency.php | 6 +
app/Models/Gateway.php | 50 ++
app/Models/Industry.php | 9 +
app/Models/Invitation.php | 32 ++
app/Models/Invoice.php | 250 +++++++++-
app/Models/InvoiceDesign.php | 10 +-
app/Models/InvoiceItem.php | 21 +
app/Models/InvoiceStatus.php | 6 +
app/Models/Language.php | 9 +
app/Models/License.php | 9 +
app/Models/OwnedByClientTrait.php | 6 +
app/Models/Payment.php | 92 +++-
app/Models/PaymentLibrary.php | 12 +
app/Models/PaymentMethod.php | 64 ++-
app/Models/PaymentStatus.php | 6 +
app/Models/PaymentTerm.php | 14 +-
app/Models/PaymentType.php | 6 +
app/Models/Product.php | 29 +-
app/Models/Size.php | 9 +
app/Models/Subscription.php | 10 +-
app/Models/Task.php | 42 +-
app/Models/TaxRate.php | 16 +-
app/Models/Theme.php | 6 +
app/Models/Timezone.php | 6 +
app/Models/User.php | 99 +++-
app/Models/UserAccount.php | 16 +
app/Models/Vendor.php | 108 +++-
app/Models/VendorContact.php | 46 +-
.../Datatables/AccountGatewayDatatable.php | 10 +-
app/Ninja/Datatables/ActivityDatatable.php | 2 -
app/Ninja/Datatables/BankAccountDatatable.php | 2 -
app/Ninja/Datatables/InvoiceDatatable.php | 16 +-
app/Ninja/Datatables/PaymentDatatable.php | 9 +-
app/Ninja/Datatables/TaskDatatable.php | 1 -
app/Ninja/Datatables/TaxRateDatatable.php | 2 -
app/Ninja/Datatables/TokenDatatable.php | 2 -
app/Ninja/Datatables/UserDatatable.php | 2 -
app/Ninja/Import/BaseTransformer.php | 77 +++
app/Ninja/Import/CSV/ClientTransformer.php | 7 +
app/Ninja/Import/CSV/InvoiceTransformer.php | 7 +
app/Ninja/Import/CSV/PaymentTransformer.php | 7 +
app/Ninja/Import/CSV/ProductTransformer.php | 7 +
app/Ninja/Import/CSV/VendorTransformer.php | 8 +
.../Import/FreshBooks/ClientTransformer.php | 7 +
.../Import/FreshBooks/InvoiceTransformer.php | 7 +
.../Import/FreshBooks/PaymentTransformer.php | 7 +
.../Import/FreshBooks/TaskTransformer.php | 1 -
.../Import/FreshBooks/VendorTransformer.php | 8 +
.../Import/Harvest/ClientTransformer.php | 7 +
.../Import/Harvest/ContactTransformer.php | 7 +
.../Import/Harvest/InvoiceTransformer.php | 7 +
.../Import/Harvest/PaymentTransformer.php | 7 +
.../Harvest/VendorContactTransformer.php | 8 +
.../Import/Harvest/VendorTransformer.php | 8 +
.../Import/Hiveage/ClientTransformer.php | 7 +
.../Import/Hiveage/InvoiceTransformer.php | 7 +
.../Import/Hiveage/PaymentTransformer.php | 7 +
.../Import/Hiveage/VendorTransformer.php | 8 +
.../Import/Invoiceable/ClientTransformer.php | 7 +
.../Import/Invoiceable/InvoiceTransformer.php | 7 +
.../Import/Invoiceable/PaymentTransformer.php | 7 +
.../Import/Invoiceable/VendorTransformer.php | 8 +
.../Import/Nutcache/ClientTransformer.php | 7 +
.../Import/Nutcache/InvoiceTransformer.php | 7 +
.../Import/Nutcache/PaymentTransformer.php | 7 +
app/Ninja/Import/Nutcache/TaskTransformer.php | 1 -
.../Import/Nutcache/VendorTransformer.php | 8 +
app/Ninja/Import/Ronin/ClientTransformer.php | 7 +
app/Ninja/Import/Ronin/InvoiceTransformer.php | 7 +
app/Ninja/Import/Ronin/PaymentTransformer.php | 7 +
app/Ninja/Import/Ronin/VendorTransformer.php | 8 +
app/Ninja/Import/Wave/ClientTransformer.php | 7 +
app/Ninja/Import/Wave/InvoiceTransformer.php | 7 +
app/Ninja/Import/Wave/PaymentTransformer.php | 7 +
app/Ninja/Import/Wave/VendorTransformer.php | 8 +
app/Ninja/Import/Zoho/ClientTransformer.php | 7 +
app/Ninja/Import/Zoho/InvoiceTransformer.php | 7 +
app/Ninja/Import/Zoho/PaymentTransformer.php | 7 +
app/Ninja/Import/Zoho/VendorTransformer.php | 8 +
app/Ninja/Mailers/ContactMailer.php | 65 ++-
app/Ninja/Mailers/Mailer.php | 24 +-
app/Ninja/Mailers/UserMailer.php | 21 +-
app/Ninja/Notifications/PushFactory.php | 11 -
.../PaymentDrivers/BasePaymentDriver.php | 8 +-
.../PayPalExpressPaymentDriver.php | 1 -
.../PaymentDrivers/StripePaymentDriver.php | 10 +-
.../PaymentDrivers/WePayPaymentDriver.php | 30 +-
app/Ninja/Presenters/AccountPresenter.php | 15 +-
app/Ninja/Presenters/ClientPresenter.php | 2 -
app/Ninja/Presenters/CreditPresenter.php | 13 +-
app/Ninja/Presenters/EntityPresenter.php | 10 +-
app/Ninja/Presenters/ExpensePresenter.php | 16 +-
app/Ninja/Presenters/InvoicePresenter.php | 1 -
app/Ninja/Presenters/PaymentPresenter.php | 1 -
app/Ninja/Presenters/TaskPresenter.php | 21 +-
app/Ninja/Presenters/VendorPresenter.php | 8 +-
.../Repositories/AccountGatewayRepository.php | 4 -
app/Ninja/Repositories/AccountRepository.php | 3 +-
.../Repositories/BankAccountRepository.php | 3 -
app/Ninja/Repositories/BaseRepository.php | 31 ++
app/Ninja/Repositories/ClientRepository.php | 2 -
app/Ninja/Repositories/ContactRepository.php | 1 -
app/Ninja/Repositories/CreditRepository.php | 1 -
app/Ninja/Repositories/DocumentRepository.php | 19 +-
app/Ninja/Repositories/ExpenseRepository.php | 4 +-
app/Ninja/Repositories/InvoiceRepository.php | 46 +-
app/Ninja/Repositories/PaymentRepository.php | 2 -
.../Repositories/PaymentTermRepository.php | 3 -
app/Ninja/Repositories/ProductRepository.php | 1 -
app/Ninja/Repositories/ReferralRepository.php | 1 -
app/Ninja/Repositories/TaskRepository.php | 3 -
app/Ninja/Repositories/TaxRateRepository.php | 1 -
app/Ninja/Repositories/TokenRepository.php | 2 -
app/Ninja/Repositories/UserRepository.php | 2 -
.../Repositories/VendorContactRepository.php | 1 +
app/Ninja/Repositories/VendorRepository.php | 4 +-
app/Ninja/Serializers/ArraySerializer.php | 15 +-
.../Transformers/AccountTokenTransformer.php | 8 +-
app/Ninja/Transformers/AccountTransformer.php | 49 +-
app/Ninja/Transformers/ClientTransformer.php | 29 +-
app/Ninja/Transformers/ContactTransformer.php | 9 +-
app/Ninja/Transformers/CreditTransformer.php | 9 +-
.../Transformers/DocumentTransformer.php | 9 +-
app/Ninja/Transformers/EntityTransformer.php | 1 -
.../ExpenseCategoryTransformer.php | 1 -
app/Ninja/Transformers/ExpenseTransformer.php | 2 -
.../Transformers/InvitationTransformer.php | 3 -
.../Transformers/InvoiceItemTransformer.php | 2 -
app/Ninja/Transformers/InvoiceTransformer.php | 1 -
app/Ninja/Transformers/PaymentTransformer.php | 2 -
app/Ninja/Transformers/ProductTransformer.php | 1 -
app/Ninja/Transformers/QuoteTransformer.php | 1 -
app/Ninja/Transformers/TaskTransformer.php | 1 -
app/Ninja/Transformers/TaxRateTransformer.php | 2 -
.../Transformers/UserAccountTransformer.php | 3 -
app/Ninja/Transformers/UserTransformer.php | 1 -
.../Transformers/VendorContactTransformer.php | 3 +-
app/Ninja/Transformers/VendorTransformer.php | 2 -
app/Policies/AccountGatewayPolicy.php | 22 +-
app/Policies/BankAccountPolicy.php | 21 +-
app/Policies/DocumentPolicy.php | 48 +-
app/Policies/EntityPolicy.php | 52 +-
app/Policies/GenericEntityPolicy.php | 40 +-
app/Policies/PaymentTermPolicy.php | 22 +-
app/Policies/ProductPolicy.php | 22 +-
app/Policies/TaxRatePolicy.php | 18 +-
app/Providers/AppServiceProvider.php | 29 +-
app/Providers/BusServiceProvider.php | 52 +-
app/Providers/RouteServiceProvider.php | 73 ++-
app/Services/AccountGatewayService.php | 26 +-
app/Services/ActivityService.php | 23 +-
app/Services/AuthService.php | 35 +-
app/Services/BankAccountService.php | 68 ++-
app/Services/BaseService.php | 13 +-
app/Services/ClientService.php | 39 +-
app/Services/CreditService.php | 32 +-
app/Services/DatatableService.php | 36 +-
app/Services/EmailService.php | 29 +-
app/Services/ExpenseService.php | 75 ++-
app/Services/ImportService.php | 214 ++++++--
app/Services/InvoiceService.php | 53 +-
app/Services/PaymentService.php | 67 ++-
app/Services/PaymentTermService.php | 15 +-
app/Services/ProductService.php | 33 +-
app/Services/PushService.php | 82 ++-
app/Services/RecurringInvoiceService.php | 2 -
app/Services/TaskService.php | 30 +-
app/Services/TaxRateService.php | 27 +-
app/Services/TemplateService.php | 13 +-
app/Services/TokenService.php | 26 +-
app/Services/UserService.php | 26 +-
app/Services/VendorService.php | 45 +-
340 files changed, 6586 insertions(+), 2129 deletions(-)
diff --git a/app/Console/Commands/ChargeRenewalInvoices.php b/app/Console/Commands/ChargeRenewalInvoices.php
index 39d63ee44c06..4773f53c43d0 100644
--- a/app/Console/Commands/ChargeRenewalInvoices.php
+++ b/app/Console/Commands/ChargeRenewalInvoices.php
@@ -1,22 +1,47 @@
info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php
index 795e241e6249..567c6972489c 100644
--- a/app/Console/Commands/CheckData.php
+++ b/app/Console/Commands/CheckData.php
@@ -1,11 +1,9 @@
where("{$table}.account_id", '!=', DB::raw("{$entityType}s.account_id"))
- ->get(["{$table}.id", "clients.account_id", "clients.user_id"]);
+ ->get(["{$table}.id", 'clients.account_id', 'clients.user_id']);
if (count($records)) {
$this->info(count($records) . " {$table} records with incorrect {$entityType} account id");
@@ -327,19 +335,23 @@ class CheckData extends Command {
}
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- array('fix', null, InputOption::VALUE_OPTIONAL, 'Fix data', null),
- array('client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null),
- );
+ return [
+ ['fix', null, InputOption::VALUE_OPTIONAL, 'Fix data', null],
+ ['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null],
+ ];
}
}
\ No newline at end of file
diff --git a/app/Console/Commands/CreateTestData.php b/app/Console/Commands/CreateTestData.php
index 6a0643e46c5a..a75922635f75 100644
--- a/app/Console/Commands/CreateTestData.php
+++ b/app/Console/Commands/CreateTestData.php
@@ -1,28 +1,43 @@
expenseRepo = $expenseRepo;
}
+ /**
+ * @return bool
+ */
public function fire()
{
if (Utils::isNinjaProd()) {
@@ -83,6 +101,9 @@ class CreateTestData extends Command
}
}
+ /**
+ * @param $client
+ */
private function createInvoices($client)
{
for ($i=0; $i<$this->count; $i++) {
@@ -102,7 +123,11 @@ class CreateTestData extends Command
$this->createPayment($client, $invoice);
}
}
-
+
+ /**
+ * @param $client
+ * @param $invoice
+ */
private function createPayment($client, $invoice)
{
$data = [
@@ -115,7 +140,7 @@ class CreateTestData extends Command
$this->info('Payment: ' . $payment->amount);
}
-
+
private function createVendors()
{
for ($i=0; $i<$this->count; $i++) {
@@ -140,7 +165,10 @@ class CreateTestData extends Command
$this->createExpense($vendor);
}
}
-
+
+ /**
+ * @param $vendor
+ */
private function createExpense($vendor)
{
for ($i=0; $i<$this->count; $i++) {
@@ -156,17 +184,19 @@ class CreateTestData extends Command
}
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/GenerateResources.php b/app/Console/Commands/GenerateResources.php
index e7139c85be63..9826f3c70b07 100644
--- a/app/Console/Commands/GenerateResources.php
+++ b/app/Console/Commands/GenerateResources.php
@@ -3,15 +3,22 @@
use File;
use Illuminate\Console\Command;
+/**
+ * Class GenerateResources
+ */
class GenerateResources extends Command
{
+ /**
+ * @var string
+ */
protected $name = 'ninja:generate-resources';
+ /**
+ * @var string
+ */
protected $description = 'Generate Resouces';
/**
* Create a new command instance.
- *
- * @return void
*/
public function __construct()
{
@@ -25,22 +32,6 @@ class GenerateResources extends Command
*/
public function fire()
{
- $langs = [
- 'da',
- 'de',
- 'en',
- 'es',
- 'es_ES',
- 'fr',
- 'fr_CA',
- 'it',
- 'lt',
- 'nb_NO',
- 'nl',
- 'pt_BR',
- 'sv'
- ];
-
$texts = File::getRequire(base_path() . '/resources/lang/en/texts.php');
foreach ($texts as $key => $value) {
@@ -52,17 +43,19 @@ class GenerateResources extends Command
}
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/Inspire.php b/app/Console/Commands/Inspire.php
index 65c265a2583c..8909799ec792 100644
--- a/app/Console/Commands/Inspire.php
+++ b/app/Console/Commands/Inspire.php
@@ -3,6 +3,9 @@
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
+/**
+ * Class Inspire
+ */
class Inspire extends Command {
/**
diff --git a/app/Console/Commands/PruneData.php b/app/Console/Commands/PruneData.php
index 89703764243e..1c04e1ab5fcf 100644
--- a/app/Console/Commands/PruneData.php
+++ b/app/Console/Commands/PruneData.php
@@ -3,9 +3,19 @@
use DB;
use Illuminate\Console\Command;
+/**
+ * Class PruneData
+ */
class PruneData extends Command
{
+ /**
+ * @var string
+ */
protected $name = 'ninja:prune-data';
+
+ /**
+ * @var string
+ */
protected $description = 'Delete inactive accounts';
public function fire()
@@ -41,17 +51,19 @@ class PruneData extends Command
$this->info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/RemoveOrphanedDocuments.php b/app/Console/Commands/RemoveOrphanedDocuments.php
index 3c7fe1bb537f..edcb864564bc 100644
--- a/app/Console/Commands/RemoveOrphanedDocuments.php
+++ b/app/Console/Commands/RemoveOrphanedDocuments.php
@@ -4,16 +4,25 @@ use DateTime;
use App\Models\Document;
use Illuminate\Console\Command;
+/**
+ * Class RemoveOrphanedDocuments
+ */
class RemoveOrphanedDocuments extends Command
{
+ /**
+ * @var string
+ */
protected $name = 'ninja:remove-orphaned-documents';
+ /**
+ * @var string
+ */
protected $description = 'Removes old documents not associated with an expense or invoice';
public function fire()
{
$this->info(date('Y-m-d').' Running RemoveOrphanedDocuments...');
- $documents = Document::whereRaw('invoice_id IS NULL AND expense_id IS NULL AND updated_at <= ?', array(new DateTime('-1 hour')))
+ $documents = Document::whereRaw('invoice_id IS NULL AND expense_id IS NULL AND updated_at <= ?', [new DateTime('-1 hour')])
->get();
$this->info(count($documents).' orphaned document(s) found');
@@ -25,17 +34,19 @@ class RemoveOrphanedDocuments extends Command
$this->info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/ResetData.php b/app/Console/Commands/ResetData.php
index 6400b5fafbdc..2ab706fa1d10 100644
--- a/app/Console/Commands/ResetData.php
+++ b/app/Console/Commands/ResetData.php
@@ -3,24 +3,33 @@
use Utils;
use Illuminate\Console\Command;
-use Symfony\Component\Console\Input\InputOption;
-use Symfony\Component\Console\Input\InputArgument;
-class ResetData extends Command {
+/**
+ * Class ResetData
+ */
+class ResetData extends Command
+{
- protected $name = 'ninja:reset-data';
- protected $description = 'Reset data';
+ /**
+ * @var string
+ */
+ protected $name = 'ninja:reset-data';
+
+ /**
+ * @var string
+ */
+ protected $description = 'Reset data';
- public function fire()
- {
- $this->info(date('Y-m-d') . ' Running ResetData...');
+ public function fire()
+ {
+ $this->info(date('Y-m-d') . ' Running ResetData...');
- if (!Utils::isNinjaDev()) {
- return;
+ if (!Utils::isNinjaDev()) {
+ return;
+ }
+
+ Artisan::call('migrate:reset');
+ Artisan::call('migrate');
+ Artisan::call('db:seed');
}
-
- Artisan::call('migrate:reset');
- Artisan::call('migrate');
- Artisan::call('db:seed');
- }
}
\ No newline at end of file
diff --git a/app/Console/Commands/SendRecurringInvoices.php b/app/Console/Commands/SendRecurringInvoices.php
index 4934ca417e34..51f8cda33e4e 100644
--- a/app/Console/Commands/SendRecurringInvoices.php
+++ b/app/Console/Commands/SendRecurringInvoices.php
@@ -1,26 +1,48 @@
whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND frequency_id > 0 AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))
+ ->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND frequency_id > 0 AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', [$today, $today])
->orderBy('id', 'asc')
->get();
$this->info(count($invoices).' recurring invoice(s) found');
@@ -59,11 +81,12 @@ class SendRecurringInvoices extends Command
$delayedAutoBillInvoices = Invoice::with('account.timezone', 'recurring_invoice', 'invoice_items', 'client', 'user')
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS FALSE
AND balance > 0 AND due_date = ? AND recurring_invoice_id IS NOT NULL',
- array($today->format('Y-m-d')))
+ [$today->format('Y-m-d')])
->orderBy('invoices.id', 'asc')
->get();
$this->info(count($delayedAutoBillInvoices).' due recurring invoice instance(s) found');
+ /** @var Invoice $invoice */
foreach ($delayedAutoBillInvoices as $invoice) {
if ($invoice->isPaid()) {
continue;
@@ -78,17 +101,19 @@ class SendRecurringInvoices extends Command
$this->info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/SendReminders.php b/app/Console/Commands/SendReminders.php
index 58c38a7d8163..bdb239deff70 100644
--- a/app/Console/Commands/SendReminders.php
+++ b/app/Console/Commands/SendReminders.php
@@ -1,23 +1,47 @@
info(date('Y-m-d').' Running SendReminders...');
- $today = new DateTime();
+ $this->info(date('Y-m-d') . ' Running SendReminders...');
$accounts = $this->accountRepo->findWithReminders();
- $this->info(count($accounts).' accounts found');
+ $this->info(count($accounts) . ' accounts found');
+ /** @var \App\Models\Account $account */
foreach ($accounts as $account) {
if (!$account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
continue;
}
$invoices = $this->invoiceRepo->findNeedingReminding($account);
- $this->info($account->name . ': ' . count($invoices).' invoices found');
+ $this->info($account->name . ': ' . count($invoices) . ' invoices found');
+ /** @var Invoice $invoice */
foreach ($invoices as $invoice) {
if ($reminder = $account->getInvoiceReminder($invoice)) {
$this->info('Send to ' . $invoice->id);
@@ -54,17 +79,19 @@ class SendReminders extends Command
$this->info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/SendRenewalInvoices.php b/app/Console/Commands/SendRenewalInvoices.php
index 87a840aed2c0..bb34849e7cdf 100644
--- a/app/Console/Commands/SendRenewalInvoices.php
+++ b/app/Console/Commands/SendRenewalInvoices.php
@@ -1,21 +1,41 @@
mailer = $mailer;
$this->accountRepo = $repo;
}
-
+
public function fire()
{
$this->info(date('Y-m-d').' Running SendRenewalInvoices...');
- $today = new DateTime();
- $sentTo = [];
// get all accounts with plans expiring in 10 days
$companies = Company::whereRaw('datediff(plan_expires, curdate()) = 10')
@@ -73,17 +91,19 @@ class SendRenewalInvoices extends Command
$this->info('Done');
}
+ /**
+ * @return array
+ */
protected function getArguments()
{
- return array(
- //array('example', InputArgument::REQUIRED, 'An example argument.'),
- );
+ return [];
}
+ /**
+ * @return array
+ */
protected function getOptions()
{
- return array(
- //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
- );
+ return [];
}
}
diff --git a/app/Console/Commands/TestOFX.php b/app/Console/Commands/TestOFX.php
index f7eb2b748b03..d21518cba7ef 100644
--- a/app/Console/Commands/TestOFX.php
+++ b/app/Console/Commands/TestOFX.php
@@ -3,11 +3,31 @@
use Illuminate\Console\Command;
use App\Services\BankAccountService;
+/**
+ * Class TestOFX
+ */
class TestOFX extends Command
{
+ /**
+ * @var string
+ */
protected $name = 'ninja:test-ofx';
+
+ /**
+ * @var string
+ */
protected $description = 'Test OFX';
+ /**
+ * @var BankAccountService
+ */
+ protected $bankAccountService;
+
+ /**
+ * TestOFX constructor.
+ *
+ * @param BankAccountService $bankAccountService
+ */
public function __construct(BankAccountService $bankAccountService)
{
parent::__construct();
@@ -18,15 +38,5 @@ class TestOFX extends Command
public function fire()
{
$this->info(date('Y-m-d').' Running TestOFX...');
-
- /*
- $bankId = env('TEST_BANK_ID');
- $username = env('TEST_BANK_USERNAME');
- $password = env('TEST_BANK_PASSWORD');
-
- $data = $this->bankAccountService->loadBankAccounts($bankId, $username, $password, false);
-
- echo json_encode($data);
- */
}
}
\ No newline at end of file
diff --git a/app/Events/ClientWasArchived.php b/app/Events/ClientWasArchived.php
index 03ebdc09cd18..176376d2b6f1 100644
--- a/app/Events/ClientWasArchived.php
+++ b/app/Events/ClientWasArchived.php
@@ -1,20 +1,26 @@
client = $client;
}
diff --git a/app/Events/ClientWasCreated.php b/app/Events/ClientWasCreated.php
index 5c2d3700172b..eed24343fb56 100644
--- a/app/Events/ClientWasCreated.php
+++ b/app/Events/ClientWasCreated.php
@@ -1,20 +1,26 @@
client = $client;
}
diff --git a/app/Events/ClientWasDeleted.php b/app/Events/ClientWasDeleted.php
index b87063c4979d..f6d27b92d95a 100644
--- a/app/Events/ClientWasDeleted.php
+++ b/app/Events/ClientWasDeleted.php
@@ -1,20 +1,26 @@
client = $client;
}
diff --git a/app/Events/ClientWasRestored.php b/app/Events/ClientWasRestored.php
index 385a0472ab4c..16fb6b9616c0 100644
--- a/app/Events/ClientWasRestored.php
+++ b/app/Events/ClientWasRestored.php
@@ -1,20 +1,26 @@
client = $client;
}
diff --git a/app/Events/ClientWasUpdated.php b/app/Events/ClientWasUpdated.php
index 7e4790da6885..1f863d6c0160 100644
--- a/app/Events/ClientWasUpdated.php
+++ b/app/Events/ClientWasUpdated.php
@@ -1,20 +1,26 @@
client = $client;
}
diff --git a/app/Events/CreditWasArchived.php b/app/Events/CreditWasArchived.php
index 2c680905b33a..b9dd495dddb8 100644
--- a/app/Events/CreditWasArchived.php
+++ b/app/Events/CreditWasArchived.php
@@ -1,23 +1,30 @@
credit = $credit;
- }
+ /**
+ * Create a new event instance.
+ *
+ * @param Client $credit
+ */
+ public function __construct(Client $credit)
+ {
+ $this->credit = $credit;
+ }
}
diff --git a/app/Events/CreditWasCreated.php b/app/Events/CreditWasCreated.php
index bc20b312dc5f..81ba63c450ca 100644
--- a/app/Events/CreditWasCreated.php
+++ b/app/Events/CreditWasCreated.php
@@ -1,21 +1,24 @@
credit = $credit;
}
diff --git a/app/Events/CreditWasDeleted.php b/app/Events/CreditWasDeleted.php
index e26a5d3ab053..c5f585fcf338 100644
--- a/app/Events/CreditWasDeleted.php
+++ b/app/Events/CreditWasDeleted.php
@@ -1,21 +1,26 @@
credit = $credit;
}
diff --git a/app/Events/CreditWasRestored.php b/app/Events/CreditWasRestored.php
index 8d17d961e7ff..a80c9e729b5f 100644
--- a/app/Events/CreditWasRestored.php
+++ b/app/Events/CreditWasRestored.php
@@ -1,21 +1,27 @@
credit = $credit;
}
diff --git a/app/Events/Event.php b/app/Events/Event.php
index d59f7690f83c..76e730a4b8e8 100644
--- a/app/Events/Event.php
+++ b/app/Events/Event.php
@@ -1,7 +1,5 @@
expense = $expense;
- }
+ /**
+ * Create a new event instance.
+ *
+ * @param Expense $expense
+ */
+ public function __construct(Expense $expense)
+ {
+ $this->expense = $expense;
+ }
}
diff --git a/app/Events/ExpenseWasCreated.php b/app/Events/ExpenseWasCreated.php
index ab462fe60253..edaca9c00a82 100644
--- a/app/Events/ExpenseWasCreated.php
+++ b/app/Events/ExpenseWasCreated.php
@@ -1,20 +1,26 @@
expense = $expense;
}
diff --git a/app/Events/ExpenseWasDeleted.php b/app/Events/ExpenseWasDeleted.php
index 1549b483b497..bb2b6e4dbdd5 100644
--- a/app/Events/ExpenseWasDeleted.php
+++ b/app/Events/ExpenseWasDeleted.php
@@ -1,21 +1,26 @@
expense = $expense;
}
diff --git a/app/Events/ExpenseWasRestored.php b/app/Events/ExpenseWasRestored.php
index b52a2d119a2d..142f41d7e9ec 100644
--- a/app/Events/ExpenseWasRestored.php
+++ b/app/Events/ExpenseWasRestored.php
@@ -1,21 +1,27 @@
expense = $expense;
}
diff --git a/app/Events/ExpenseWasUpdated.php b/app/Events/ExpenseWasUpdated.php
index 1066d90de4f7..469a258ba1aa 100644
--- a/app/Events/ExpenseWasUpdated.php
+++ b/app/Events/ExpenseWasUpdated.php
@@ -1,20 +1,26 @@
expense = $expense;
}
diff --git a/app/Events/InvoiceInvitationWasEmailed.php b/app/Events/InvoiceInvitationWasEmailed.php
index da0031249217..b51e8af0c10d 100644
--- a/app/Events/InvoiceInvitationWasEmailed.php
+++ b/app/Events/InvoiceInvitationWasEmailed.php
@@ -1,21 +1,28 @@
invitation = $invitation;
}
diff --git a/app/Events/InvoiceInvitationWasViewed.php b/app/Events/InvoiceInvitationWasViewed.php
index bbf7e23c3353..0897895a7a82 100644
--- a/app/Events/InvoiceInvitationWasViewed.php
+++ b/app/Events/InvoiceInvitationWasViewed.php
@@ -1,25 +1,35 @@
invoice = $invoice;
$this->invitation = $invitation;
}
-
}
diff --git a/app/Events/InvoiceWasArchived.php b/app/Events/InvoiceWasArchived.php
index 7587c071a66e..0de212661acb 100644
--- a/app/Events/InvoiceWasArchived.php
+++ b/app/Events/InvoiceWasArchived.php
@@ -1,20 +1,26 @@
invoice = $invoice;
}
diff --git a/app/Events/InvoiceWasCreated.php b/app/Events/InvoiceWasCreated.php
index cfd943bcffbf..b78d7f769f3f 100644
--- a/app/Events/InvoiceWasCreated.php
+++ b/app/Events/InvoiceWasCreated.php
@@ -1,20 +1,26 @@
invoice = $invoice;
}
diff --git a/app/Events/InvoiceWasDeleted.php b/app/Events/InvoiceWasDeleted.php
index 316b1b5c5001..792e693eb4eb 100644
--- a/app/Events/InvoiceWasDeleted.php
+++ b/app/Events/InvoiceWasDeleted.php
@@ -1,22 +1,27 @@
invoice = $invoice;
}
-
}
diff --git a/app/Events/InvoiceWasEmailed.php b/app/Events/InvoiceWasEmailed.php
index dc30f6a55869..a83035818c81 100644
--- a/app/Events/InvoiceWasEmailed.php
+++ b/app/Events/InvoiceWasEmailed.php
@@ -1,22 +1,27 @@
invoice = $invoice;
}
-
}
diff --git a/app/Events/InvoiceWasRestored.php b/app/Events/InvoiceWasRestored.php
index 5d75b4b246b4..e935f5b9e890 100644
--- a/app/Events/InvoiceWasRestored.php
+++ b/app/Events/InvoiceWasRestored.php
@@ -1,22 +1,30 @@
invoice = $invoice;
$this->fromDeleted = $fromDeleted;
diff --git a/app/Events/InvoiceWasUpdated.php b/app/Events/InvoiceWasUpdated.php
index 87a0f8f20136..f929b3d5bef8 100644
--- a/app/Events/InvoiceWasUpdated.php
+++ b/app/Events/InvoiceWasUpdated.php
@@ -1,22 +1,27 @@
invoice = $invoice;
- }
-
+ /**
+ * Create a new event instance.
+ *
+ * @param Invoice $invoice
+ */
+ public function __construct(Invoice $invoice)
+ {
+ $this->invoice = $invoice;
+ }
}
diff --git a/app/Events/PaymentCompleted.php b/app/Events/PaymentCompleted.php
index 281dddfae0df..4d78fb923e68 100644
--- a/app/Events/PaymentCompleted.php
+++ b/app/Events/PaymentCompleted.php
@@ -1,21 +1,26 @@
payment = $payment;
}
diff --git a/app/Events/PaymentFailed.php b/app/Events/PaymentFailed.php
index 5ff1a1874534..445b8ba5beaf 100644
--- a/app/Events/PaymentFailed.php
+++ b/app/Events/PaymentFailed.php
@@ -1,23 +1,27 @@
payment = $payment;
}
-
}
diff --git a/app/Events/PaymentWasArchived.php b/app/Events/PaymentWasArchived.php
index b8bb693dfc78..4bf7eb8ff7bd 100644
--- a/app/Events/PaymentWasArchived.php
+++ b/app/Events/PaymentWasArchived.php
@@ -1,22 +1,28 @@
payment = $payment;
- }
+ /**
+ * Create a new event instance.
+ *
+ * @param Payment $payment
+ */
+ public function __construct(Payment $payment)
+ {
+ $this->payment = $payment;
+ }
}
diff --git a/app/Events/PaymentWasCreated.php b/app/Events/PaymentWasCreated.php
index 619d33e95890..98e95ae43a70 100644
--- a/app/Events/PaymentWasCreated.php
+++ b/app/Events/PaymentWasCreated.php
@@ -1,22 +1,27 @@
payment = $payment;
}
-
}
diff --git a/app/Events/PaymentWasDeleted.php b/app/Events/PaymentWasDeleted.php
index e12647c86011..e7b62fe74cc7 100644
--- a/app/Events/PaymentWasDeleted.php
+++ b/app/Events/PaymentWasDeleted.php
@@ -1,22 +1,29 @@
-payment = $payment;
}
-
}
diff --git a/app/Events/PaymentWasRefunded.php b/app/Events/PaymentWasRefunded.php
index 54eeeabc3259..55ca280ba85e 100644
--- a/app/Events/PaymentWasRefunded.php
+++ b/app/Events/PaymentWasRefunded.php
@@ -1,25 +1,31 @@
payment = $payment;
$this->refundAmount = $refundAmount;
}
-
}
diff --git a/app/Events/PaymentWasRestored.php b/app/Events/PaymentWasRestored.php
index 711bdbb67fa5..1179d1896ece 100644
--- a/app/Events/PaymentWasRestored.php
+++ b/app/Events/PaymentWasRestored.php
@@ -1,25 +1,30 @@
payment = $payment;
$this->fromDeleted = $fromDeleted;
}
-
}
diff --git a/app/Events/PaymentWasVoided.php b/app/Events/PaymentWasVoided.php
index 962b8eee8262..e2d4f5013303 100644
--- a/app/Events/PaymentWasVoided.php
+++ b/app/Events/PaymentWasVoided.php
@@ -1,22 +1,27 @@
payment = $payment;
}
-
}
diff --git a/app/Events/QuoteInvitationWasApproved.php b/app/Events/QuoteInvitationWasApproved.php
index 5e69fe9c7895..e5532352e16d 100644
--- a/app/Events/QuoteInvitationWasApproved.php
+++ b/app/Events/QuoteInvitationWasApproved.php
@@ -1,27 +1,37 @@
quote = $quote;
$this->invoice = $invoice;
$this->invitation = $invitation;
}
-
}
diff --git a/app/Events/QuoteInvitationWasEmailed.php b/app/Events/QuoteInvitationWasEmailed.php
index 5ce1c68602fb..54481ab9e763 100644
--- a/app/Events/QuoteInvitationWasEmailed.php
+++ b/app/Events/QuoteInvitationWasEmailed.php
@@ -1,21 +1,26 @@
invitation = $invitation;
}
diff --git a/app/Events/QuoteInvitationWasViewed.php b/app/Events/QuoteInvitationWasViewed.php
index 3cd84b0e1189..87f5da2a0bb0 100644
--- a/app/Events/QuoteInvitationWasViewed.php
+++ b/app/Events/QuoteInvitationWasViewed.php
@@ -1,25 +1,31 @@
quote = $quote;
$this->invitation = $invitation;
}
-
}
diff --git a/app/Events/QuoteWasArchived.php b/app/Events/QuoteWasArchived.php
index 285a61250c04..4e78026b24af 100644
--- a/app/Events/QuoteWasArchived.php
+++ b/app/Events/QuoteWasArchived.php
@@ -1,22 +1,20 @@
quote = $quote;
- }
+ /**
+ * Create a new event instance.
+ *
+ * @param $quote
+ */
+ public function __construct($quote)
+ {
+ $this->quote = $quote;
+ }
}
diff --git a/app/Events/QuoteWasCreated.php b/app/Events/QuoteWasCreated.php
index d17ef9c1318c..8077ea671634 100644
--- a/app/Events/QuoteWasCreated.php
+++ b/app/Events/QuoteWasCreated.php
@@ -1,22 +1,22 @@
quote = $quote;
}
-
}
diff --git a/app/Events/QuoteWasDeleted.php b/app/Events/QuoteWasDeleted.php
index ce3685d7a212..c338042e8dce 100644
--- a/app/Events/QuoteWasDeleted.php
+++ b/app/Events/QuoteWasDeleted.php
@@ -1,22 +1,22 @@
quote = $quote;
}
-
}
diff --git a/app/Events/QuoteWasEmailed.php b/app/Events/QuoteWasEmailed.php
index 19b1ec12d6a5..e41cfebb2c20 100644
--- a/app/Events/QuoteWasEmailed.php
+++ b/app/Events/QuoteWasEmailed.php
@@ -1,22 +1,22 @@
quote = $quote;
}
-
}
diff --git a/app/Events/QuoteWasRestored.php b/app/Events/QuoteWasRestored.php
index 0f13a65b437e..4733991f69f1 100644
--- a/app/Events/QuoteWasRestored.php
+++ b/app/Events/QuoteWasRestored.php
@@ -1,22 +1,22 @@
quote = $quote;
}
-
}
diff --git a/app/Events/QuoteWasUpdated.php b/app/Events/QuoteWasUpdated.php
index f01b9822601f..b3559a85b1f2 100644
--- a/app/Events/QuoteWasUpdated.php
+++ b/app/Events/QuoteWasUpdated.php
@@ -1,22 +1,23 @@
quote = $quote;
- }
+ /**
+ * Create a new event instance.
+ *
+ * @param $quote
+ */
+ public function __construct($quote)
+ {
+ $this->quote = $quote;
+ }
}
diff --git a/app/Events/UserLoggedIn.php b/app/Events/UserLoggedIn.php
index 1f4af5e86a9a..3127d3824767 100644
--- a/app/Events/UserLoggedIn.php
+++ b/app/Events/UserLoggedIn.php
@@ -1,21 +1,18 @@
user = $user;
- }
-
+ }
}
diff --git a/app/Events/UserSignedUp.php b/app/Events/UserSignedUp.php
index 99e8b22456c2..fcef6296cdc6 100644
--- a/app/Events/UserSignedUp.php
+++ b/app/Events/UserSignedUp.php
@@ -1,21 +1,18 @@
vendor = $vendor;
}
diff --git a/app/Events/VendorWasCreated.php b/app/Events/VendorWasCreated.php
index b2d7e81c9394..dcd86a1548a6 100644
--- a/app/Events/VendorWasCreated.php
+++ b/app/Events/VendorWasCreated.php
@@ -1,21 +1,26 @@
vendor = $vendor;
}
diff --git a/app/Events/VendorWasDeleted.php b/app/Events/VendorWasDeleted.php
index 553bece3ccdc..c53a8c2123bc 100644
--- a/app/Events/VendorWasDeleted.php
+++ b/app/Events/VendorWasDeleted.php
@@ -1,21 +1,26 @@
vendor = $vendor;
}
diff --git a/app/Events/VendorWasRestored.php b/app/Events/VendorWasRestored.php
index 88c24693e611..0b62f5a27e46 100644
--- a/app/Events/VendorWasRestored.php
+++ b/app/Events/VendorWasRestored.php
@@ -1,21 +1,26 @@
vendor = $vendor;
}
diff --git a/app/Events/VendorWasUpdated.php b/app/Events/VendorWasUpdated.php
index eb90a68f46c0..17f4a56c7f6c 100644
--- a/app/Events/VendorWasUpdated.php
+++ b/app/Events/VendorWasUpdated.php
@@ -1,20 +1,26 @@
vendor = $vendor;
}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 2a8b0d305277..0eecaba698cb 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -4,13 +4,17 @@ use Redirect;
use Utils;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
-use Illuminate\Http\Exception\HttpResponseException;
+use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
-use Illuminate\Foundation\Validation\ValidationException;
+use Illuminate\Validation\ValidationException;
-class Handler extends ExceptionHandler {
+/**
+ * Class Handler
+ */
+class Handler extends ExceptionHandler
+{
/**
* A list of the exception types that should not be reported.
@@ -24,14 +28,14 @@ class Handler extends ExceptionHandler {
ValidationException::class,
];
- /**
- * Report or log an exception.
- *
- * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
- *
- * @param \Exception $e
- * @return void
- */
+ /**
+ * Report or log an exception.
+ *
+ * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
+ *
+ * @param \Exception $e
+ * @return bool|void
+ */
public function report(Exception $e)
{
// don't show these errors in the logs
diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php
index 65175cdd5ba1..1034bdf25432 100644
--- a/app/Http/Controllers/AccountApiController.php
+++ b/app/Http/Controllers/AccountApiController.php
@@ -3,22 +3,12 @@
use Auth;
use Utils;
use Response;
-use Input;
-use Validator;
use Cache;
-use App\Models\Client;
use App\Models\Account;
-use App\Models\AccountToken;
use App\Ninja\Repositories\AccountRepository;
use Illuminate\Http\Request;
-use League\Fractal;
-use League\Fractal\Manager;
-use App\Ninja\Serializers\ArraySerializer;
use App\Ninja\Transformers\AccountTransformer;
use App\Ninja\Transformers\UserAccountTransformer;
-use App\Http\Controllers\BaseAPIController;
-use Swagger\Annotations as SWG;
-
use App\Events\UserSignedUp;
use App\Http\Requests\RegisterRequest;
use App\Http\Requests\UpdateAccountRequest;
@@ -183,8 +173,6 @@ class AccountApiController extends BaseAPIController
'notify_paid' => $request->notify_paid,
];
- //unset($devices[$x]);
-
$devices[$x] = $newDevice;
$account->devices = json_encode($devices);
$account->save();
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index abb88ef002fd..4e7ead7fed53 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -1,6 +1,7 @@
accountRepo = $accountRepo;
$this->userMailer = $userMailer;
$this->contactMailer = $contactMailer;
@@ -55,6 +90,9 @@ class AccountController extends BaseController
$this->paymentService = $paymentService;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function demo()
{
$demoAccountId = Utils::getDemoAccountId();
@@ -71,6 +109,9 @@ class AccountController extends BaseController
return Redirect::to('invoices/create');
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function getStarted()
{
$user = false;
@@ -113,6 +154,9 @@ class AccountController extends BaseController
return Redirect::to($redirectTo)->with('sign_up', Input::get('sign_up'));
}
+ /**
+ * @return bool|mixed
+ */
public function enableProPlan()
{
if (Auth::user()->isPro() && ! Auth::user()->isTrial()) {
@@ -124,6 +168,9 @@ class AccountController extends BaseController
return $invitation->invitation_key;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function changePlan() {
$user = Auth::user();
$account = $user->account;
@@ -143,22 +190,22 @@ class AccountController extends BaseController
$term = PLAN_TERM_YEARLY;
}
- $new_plan = array(
+ $new_plan = [
'plan' => PLAN_ENTERPRISE,
'term' => $term,
- );
+ ];
} elseif ($planDetails['plan'] == $plan) {
// Term switch
if ($planDetails['term'] == PLAN_TERM_YEARLY && $term == PLAN_TERM_MONTHLY) {
- $pending_change = array(
+ $pending_change = [
'plan' => $plan,
'term' => $term
- );
+ ];
} elseif ($planDetails['term'] == PLAN_TERM_MONTHLY && $term == PLAN_TERM_YEARLY) {
- $new_plan = array(
+ $new_plan = [
'plan' => $plan,
'term' => $term,
- );
+ ];
} else {
// Cancel the pending change
$account->company->pending_plan = null;
@@ -194,10 +241,10 @@ class AccountController extends BaseController
$account->company->save();
} else {
- $pending_change = array(
+ $pending_change = [
'plan' => $plan,
'term' => $plan == PLAN_FREE ? null : $term,
- );
+ ];
}
}
@@ -217,10 +264,10 @@ class AccountController extends BaseController
$credit = $old_plan_price * (1 - $percent_used);
}
} else {
- $new_plan = array(
+ $new_plan = [
'plan' => $plan,
'term' => $term,
- );
+ ];
}
if (!empty($pending_change) && empty($new_plan)) {
@@ -239,6 +286,11 @@ class AccountController extends BaseController
return Redirect::to('/settings/'.ACCOUNT_MANAGEMENT, 301);
}
+ /**
+ * @param $entityType
+ * @param $visible
+ * @return mixed
+ */
public function setTrashVisible($entityType, $visible)
{
Session::put("show_trash:{$entityType}", $visible == 'true');
@@ -246,6 +298,9 @@ class AccountController extends BaseController
return RESULT_SUCCESS;
}
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getSearchData()
{
$data = $this->accountRepo->getSearchData(Auth::user());
@@ -253,6 +308,10 @@ class AccountController extends BaseController
return Response::json($data);
}
+ /**
+ * @param bool $section
+ * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
+ */
public function showSection($section = false)
{
if (!$section) {
@@ -298,6 +357,9 @@ class AccountController extends BaseController
}
}
+ /**
+ * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
+ */
private function showSystemSettings()
{
if (Utils::isNinjaProd()) {
@@ -306,13 +368,16 @@ class AccountController extends BaseController
$data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
- 'title' => trans("texts.system_settings"),
+ 'title' => trans('texts.system_settings'),
'section' => ACCOUNT_SYSTEM_SETTINGS,
];
- return View::make("accounts.system_settings", $data);
+ return View::make('accounts.system_settings', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showInvoiceSettings()
{
$account = Auth::user()->account;
@@ -329,14 +394,17 @@ class AccountController extends BaseController
$data = [
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
- 'title' => trans("texts.invoice_settings"),
+ 'title' => trans('texts.invoice_settings'),
'section' => ACCOUNT_INVOICE_SETTINGS,
'recurringHours' => $recurringHours,
];
- return View::make("accounts.invoice_settings", $data);
+ return View::make('accounts.invoice_settings', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showCompanyDetails()
{
// check that logo is less than the max file size
@@ -356,6 +424,9 @@ class AccountController extends BaseController
return View::make('accounts.details', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showAccountManagement()
{
$account = Auth::user()->account;
@@ -368,6 +439,9 @@ class AccountController extends BaseController
return View::make('accounts.management', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function showUserDetails()
{
$oauthLoginUrls = [];
@@ -387,6 +461,9 @@ class AccountController extends BaseController
return View::make('accounts.user_details', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showLocalization()
{
$data = [
@@ -402,6 +479,9 @@ class AccountController extends BaseController
return View::make('accounts.localization', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showBankAccounts()
{
return View::make('accounts.banks', [
@@ -409,6 +489,9 @@ class AccountController extends BaseController
]);
}
+ /**
+ * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
+ */
private function showOnlinePayments()
{
$account = Auth::user()->account;
@@ -439,6 +522,9 @@ class AccountController extends BaseController
}
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showProducts()
{
$columns = ['product', 'description', 'unit_cost'];
@@ -456,6 +542,9 @@ class AccountController extends BaseController
return View::make('accounts.products', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showTaxRates()
{
$data = [
@@ -467,6 +556,9 @@ class AccountController extends BaseController
return View::make('accounts.tax_rates', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showPaymentTerms()
{
$data = [
@@ -478,6 +570,10 @@ class AccountController extends BaseController
return View::make('accounts.payment_terms', $data);
}
+ /**
+ * @param $section
+ * @return \Illuminate\Contracts\View\View
+ */
private function showInvoiceDesign($section)
{
$account = Auth::user()->account->load('country');
@@ -608,6 +704,9 @@ class AccountController extends BaseController
return View::make("accounts.{$section}", $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showClientPortal()
{
$account = Auth::user()->account->load('country');
@@ -616,8 +715,8 @@ class AccountController extends BaseController
if (Utils::isNinja() && $css) {
// Unescape the CSS for display purposes
$css = str_replace(
- array('\3C ', '\3E ', '\26 '),
- array('<', '>', '&'),
+ ['\3C ', '\3E ', '\26 '],
+ ['<', '>', '&'],
$css
);
}
@@ -626,14 +725,17 @@ class AccountController extends BaseController
'client_view_css' => $css,
'enable_portal_password' => $account->enable_portal_password,
'send_portal_password' => $account->send_portal_password,
- 'title' => trans("texts.client_portal"),
+ 'title' => trans('texts.client_portal'),
'section' => ACCOUNT_CLIENT_PORTAL,
'account' => $account,
];
- return View::make("accounts.client_portal", $data);
+ return View::make('accounts.client_portal', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
private function showTemplates()
{
$account = Auth::user()->account->load('country');
@@ -656,6 +758,10 @@ class AccountController extends BaseController
return View::make('accounts.templates_and_reminders', $data);
}
+ /**
+ * @param $section
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function doSection($section = ACCOUNT_COMPANY_DETAILS)
{
if ($section === ACCOUNT_COMPANY_DETAILS) {
@@ -689,6 +795,9 @@ class AccountController extends BaseController
}
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveCustomizeDesign()
{
if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) {
@@ -703,6 +812,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_CUSTOMIZE_DESIGN);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveClientPortal()
{
$account = Auth::user()->account;
@@ -756,6 +868,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_CLIENT_PORTAL);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveEmailTemplates()
{
if (Auth::user()->account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
@@ -790,6 +905,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_TEMPLATES_AND_REMINDERS);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveTaxRates()
{
$account = Auth::user()->account;
@@ -801,6 +919,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_TAX_RATES);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveProducts()
{
$account = Auth::user()->account;
@@ -814,13 +935,16 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_PRODUCTS);
}
+ /**
+ * @return $this|\Illuminate\Http\RedirectResponse
+ */
private function saveEmailSettings()
{
if (Auth::user()->account->hasFeature(FEATURE_CUSTOM_EMAILS)) {
$rules = [];
$user = Auth::user();
$iframeURL = preg_replace('/[^a-zA-Z0-9_\-\:\/\.]/', '', substr(strtolower(Input::get('iframe_url')), 0, MAX_IFRAME_URL_LENGTH));
- $iframeURL = rtrim($iframeURL, "/");
+ $iframeURL = rtrim($iframeURL, '/');
$subdomain = preg_replace('/[^a-zA-Z0-9_\-\.]/', '', substr(strtolower(Input::get('subdomain')), 0, MAX_SUBDOMAIN_LENGTH));
if ($iframeURL) {
@@ -857,6 +981,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_EMAIL_SETTINGS);
}
+ /**
+ * @return $this|\Illuminate\Http\RedirectResponse
+ */
private function saveInvoiceSettings()
{
if (Auth::user()->account->hasFeature(FEATURE_INVOICE_SETTINGS)) {
@@ -938,6 +1065,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_INVOICE_SETTINGS);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveInvoiceDesign()
{
if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) {
@@ -982,6 +1112,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_INVOICE_DESIGN);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveNotifications()
{
$user = Auth::user();
@@ -996,6 +1129,10 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_NOTIFICATIONS);
}
+ /**
+ * @param UpdateAccountRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function updateDetails(UpdateAccountRequest $request)
{
$account = Auth::user()->account;
@@ -1018,7 +1155,7 @@ class AccountController extends BaseController
$documentType = $extension;
}
- if(!in_array($documentType, array('jpeg', 'png', 'gif'))){
+ if(!in_array($documentType, ['jpeg', 'png', 'gif'])){
Session::flash('warning', 'Unsupported file type');
} else {
$documentTypeData = Document::$types[$documentType];
@@ -1082,8 +1219,12 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_COMPANY_DETAILS);
}
+ /**
+ * @return $this|\Illuminate\Http\RedirectResponse
+ */
public function saveUserDetails()
{
+ /** @var \App\Models\User $user */
$user = Auth::user();
$rules = ['email' => 'email|required|unique:users,email,'.$user->id.',id'];
$validator = Validator::make(Input::all(), $rules);
@@ -1117,9 +1258,14 @@ class AccountController extends BaseController
}
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveLocalization()
{
+ /** @var \App\Models\Account $account */
$account = Auth::user()->account;
+
$account->timezone_id = Input::get('timezone_id') ? Input::get('timezone_id') : null;
$account->date_format_id = Input::get('date_format_id') ? Input::get('date_format_id') : null;
$account->datetime_format_id = Input::get('datetime_format_id') ? Input::get('datetime_format_id') : null;
@@ -1136,6 +1282,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_LOCALIZATION);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function saveOnlinePayments()
{
$account = Auth::user()->account;
@@ -1150,6 +1299,9 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_PAYMENTS);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function removeLogo()
{
$account = Auth::user()->account;
@@ -1168,25 +1320,33 @@ class AccountController extends BaseController
return Redirect::to('settings/'.ACCOUNT_COMPANY_DETAILS);
}
+ /**
+ * @return string
+ */
public function checkEmail()
{
- $email = User::withTrashed()->where('email', '=', Input::get('email'))->where('id', '<>', Auth::user()->id)->first();
+ $email = User::withTrashed()->where('email', '=', Input::get('email'))
+ ->where('id', '<>', Auth::user()->id)
+ ->first();
if ($email) {
- return "taken";
+ return 'taken';
} else {
- return "available";
+ return 'available';
}
}
+ /**
+ * @return string
+ */
public function submitSignup()
{
- $rules = array(
+ $rules = [
'new_first_name' => 'required',
'new_last_name' => 'required',
'new_password' => 'required|min:6',
'new_email' => 'email|required|unique:users,email,'.Auth::user()->id.',id',
- );
+ ];
$validator = Validator::make(Input::all(), $rules);
@@ -1194,6 +1354,7 @@ class AccountController extends BaseController
return '';
}
+ /** @var \App\Models\User $user */
$user = Auth::user();
$user->first_name = trim(Input::get('new_first_name'));
$user->last_name = trim(Input::get('new_last_name'));
@@ -1212,6 +1373,9 @@ class AccountController extends BaseController
return "{$user->first_name} {$user->last_name}";
}
+ /**
+ * @return mixed
+ */
public function doRegister()
{
$affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first();
@@ -1235,6 +1399,9 @@ class AccountController extends BaseController
return RESULT_SUCCESS;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function cancelAccount()
{
if ($reason = trim(Input::get('reason'))) {
@@ -1275,16 +1442,25 @@ class AccountController extends BaseController
return Redirect::to('/')->with('clearGuestKey', true);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function resendConfirmation()
{
+ /** @var \App\Models\User $user */
$user = Auth::user();
$this->userMailer->sendConfirmation($user);
return Redirect::to('/settings/'.ACCOUNT_USER_DETAILS)->with('message', trans('texts.confirmation_resent'));
}
+ /**
+ * @param $plan
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function startTrial($plan)
{
+ /** @var \App\Models\User $user */
$user = Auth::user();
if ($user->isEligibleForTrial($plan)) {
@@ -1294,6 +1470,11 @@ class AccountController extends BaseController
return Redirect::back()->with('message', trans('texts.trial_success'));
}
+ /**
+ * @param $section
+ * @param bool $subSection
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function redirectLegacy($section, $subSection = false)
{
if ($section === 'details') {
@@ -1314,7 +1495,11 @@ class AccountController extends BaseController
return Redirect::to("/settings/$section/", 301);
}
- public function previewEmail(\App\Services\TemplateService $templateService)
+ /**
+ * @param TemplateService $templateService
+ * @return \Illuminate\Http\Response
+ */
+ public function previewEmail(TemplateService $templateService)
{
$template = Input::get('template');
$invoice = Invoice::scope()
@@ -1326,6 +1511,7 @@ class AccountController extends BaseController
return trans('texts.create_invoice_for_sample');
}
+ /** @var \App\Models\Account $account */
$account = Auth::user()->account;
$invitation = $invoice->invitations->first();
diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php
index aec0212b098c..fc6af8a66ed0 100644
--- a/app/Http/Controllers/AccountGatewayController.php
+++ b/app/Http/Controllers/AccountGatewayController.php
@@ -1,8 +1,6 @@
getFields();
$optional = array_merge(Gateway::$hiddenFields, Gateway::$optionalFields);
@@ -334,11 +330,11 @@ class AccountGatewayController extends BaseController
$wepay = Utils::setupWePay($accountGateway);
- $update_uri_data = $wepay->request('account/get_update_uri', array(
+ $update_uri_data = $wepay->request('account/get_update_uri', [
'account_id' => $accountGateway->getConfig()->accountId,
'mode' => 'iframe',
'redirect_uri' => URL::to('/gateways'),
- ));
+ ]);
return $update_uri_data->uri;
}
@@ -348,14 +344,14 @@ class AccountGatewayController extends BaseController
$user = Auth::user();
$account = $user->account;
- $rules = array(
+ $rules = [
'company_name' => 'required',
'description' => 'required',
'tos_agree' => 'required',
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
- );
+ ];
if (WEPAY_ENABLE_CANADA) {
$rules['country'] = 'required|in:US,CA';
@@ -372,7 +368,7 @@ class AccountGatewayController extends BaseController
try{
$wepay = Utils::setupWePay();
- $userDetails = array(
+ $userDetails = [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'email' => Input::get('email'),
@@ -383,7 +379,7 @@ class AccountGatewayController extends BaseController
'tos_acceptance_time' => time(),
'redirect_uri' => URL::to('gateways'),
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
- );
+ ];
$wepayUser = $wepay->request('user/register/', $userDetails);
@@ -392,12 +388,12 @@ class AccountGatewayController extends BaseController
$wepay = new WePay($accessToken);
- $accountDetails = array(
+ $accountDetails = [
'name' => Input::get('company_name'),
'description' => Input::get('description'),
'theme_object' => json_decode(WEPAY_THEME),
'callback_uri' => $accountGateway->getWebhookUrl(),
- );
+ ];
if (WEPAY_ENABLE_CANADA) {
$accountDetails['country'] = Input::get('country');
@@ -422,7 +418,7 @@ class AccountGatewayController extends BaseController
}
$accountGateway->gateway_id = GATEWAY_WEPAY;
- $accountGateway->setConfig(array(
+ $accountGateway->setConfig([
'userId' => $wepayUser->user_id,
'accessToken' => $accessToken,
'tokenType' => $wepayUser->token_type,
@@ -431,15 +427,15 @@ class AccountGatewayController extends BaseController
'state' => $wepayAccount->state,
'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE,
'country' => WEPAY_ENABLE_CANADA ? Input::get('country') : 'US',
- ));
+ ]);
if ($confirmationRequired) {
Session::flash('message', trans('texts.created_wepay_confirmation_required'));
} else {
- $updateUri = $wepay->request('/account/get_update_uri', array(
+ $updateUri = $wepay->request('/account/get_update_uri', [
'account_id' => $wepayAccount->account_id,
'redirect_uri' => URL::to('gateways'),
- ));
+ ]);
$response = Redirect::to($updateUri->uri);
return true;
diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php
index 897e1d2a978b..bd84d3ff9a1f 100644
--- a/app/Http/Controllers/ActivityController.php
+++ b/app/Http/Controllers/ActivityController.php
@@ -1,12 +1,5 @@
true)); // Debug Purposes
- Artisan::call('migrate', array('--force' => true));
+ Artisan::call('migrate', ['--force' => true]);
if (Industry::count() == 0) {
- Artisan::call('db:seed', array('--force' => true));
+ Artisan::call('db:seed', ['--force' => true]);
}
Cache::flush();
- Artisan::call('optimize', array('--force' => true));
+ Artisan::call('optimize', ['--force' => true]);
$firstName = trim(Input::get('first_name'));
$lastName = trim(Input::get('last_name'));
@@ -147,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');
}
@@ -187,7 +185,7 @@ class AppController extends BaseController
$config .= "{$key}={$val}\n";
}
- $fp = fopen(base_path()."/.env", 'w');
+ $fp = fopen(base_path().'/.env', 'w');
fwrite($fp, $config);
fclose($fp);
@@ -243,11 +241,11 @@ class AppController extends BaseController
if (!Utils::isNinjaProd() && !Utils::isDatabaseSetup()) {
try {
set_time_limit(60 * 5); // shouldn't take this long but just in case
- Artisan::call('migrate', array('--force' => true));
+ Artisan::call('migrate', ['--force' => true]);
if (Industry::count() == 0) {
- Artisan::call('db:seed', array('--force' => true));
+ Artisan::call('db:seed', ['--force' => true]);
}
- Artisan::call('optimize', array('--force' => true));
+ Artisan::call('optimize', ['--force' => true]);
} catch (Exception $e) {
Utils::logError($e);
return Response::make($e->getMessage(), 500);
@@ -268,11 +266,11 @@ class AppController extends BaseController
Artisan::call('route:clear');
Artisan::call('view:clear');
Artisan::call('config:clear');
- Artisan::call('optimize', array('--force' => true));
+ Artisan::call('optimize', ['--force' => true]);
Cache::flush();
Session::flush();
- Artisan::call('migrate', array('--force' => true));
- Artisan::call('db:seed', array('--force' => true, '--class' => "UpdateSeeder"));
+ Artisan::call('migrate', ['--force' => true]);
+ Artisan::call('db:seed', ['--force' => true, '--class' => 'UpdateSeeder']);
Event::fire(new UserSettingsChanged());
// show message with link to Trello board
diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
index e599890c6a90..0824f4d44e4d 100644
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -12,40 +12,55 @@ use App\Ninja\Repositories\AccountRepository;
use App\Services\AuthService;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
-class AuthController extends Controller {
+class AuthController extends Controller
+{
- /*
- |--------------------------------------------------------------------------
- | Registration & Login Controller
- |--------------------------------------------------------------------------
- |
- | This controller handles the registration of new users, as well as the
- | authentication of existing users. By default, this controller uses
- | a simple trait to add these behaviors. Why don't you explore it?
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Registration & Login Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller handles the registration of new users, as well as the
+ | authentication of existing users. By default, this controller uses
+ | a simple trait to add these behaviors. Why don't you explore it?
+ |
+ */
- use AuthenticatesAndRegistersUsers;
+ use AuthenticatesAndRegistersUsers;
+ /**
+ * @var string
+ */
protected $redirectTo = '/dashboard';
+
+ /**
+ * @var AuthService
+ */
protected $authService;
+
+ /**
+ * @var AccountRepository
+ */
protected $accountRepo;
- /**
- * Create a new authentication controller instance.
- *
- * @param \Illuminate\Contracts\Auth\Guard $auth
- * @param \Illuminate\Contracts\Auth\Registrar $registrar
- * @return void
- */
- public function __construct(AccountRepository $repo, AuthService $authService)
- {
+ /**
+ * Create a new authentication controller instance.
+ *
+ * @param AccountRepository $repo
+ * @param AuthService $authService
+ * @internal param \Illuminate\Contracts\Auth\Guard $auth
+ * @internal param \Illuminate\Contracts\Auth\Registrar $registrar
+ */
+ public function __construct(AccountRepository $repo, AuthService $authService)
+ {
$this->accountRepo = $repo;
$this->authService = $authService;
+ }
- //$this->middleware('guest', ['except' => 'getLogout']);
- }
-
+ /**
+ * @param array $data
+ * @return mixed
+ */
public function validator(array $data)
{
return Validator::make($data, [
@@ -58,7 +73,8 @@ class AuthController extends Controller {
/**
* Create a new user instance after a valid registration.
*
- * @param array $data
+ * @param array $data
+ *
* @return User
*/
public function create(array $data)
@@ -70,11 +86,20 @@ class AuthController extends Controller {
]);
}
+ /**
+ * @param $provider
+ * @param Request $request
+ *
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function authLogin($provider, Request $request)
{
return $this->authService->execute($provider, $request->has('code'));
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function authUnlink()
{
$this->accountRepo->unlinkUserFromOauth(Auth::user());
@@ -83,6 +108,9 @@ class AuthController extends Controller {
return redirect()->to('/settings/' . ACCOUNT_USER_DETAILS);
}
+ /**
+ * @return \Illuminate\Http\Response
+ */
public function getLoginWrapper()
{
if (!Utils::isNinja() && !User::count()) {
@@ -92,6 +120,11 @@ class AuthController extends Controller {
return self::getLogin();
}
+ /**
+ * @param Request $request
+ *
+ * @return \Illuminate\Http\Response
+ */
public function postLoginWrapper(Request $request)
{
@@ -113,7 +146,7 @@ class AuthController extends Controller {
if ($request->link_accounts && $userId && Auth::user()->id != $userId) {
$users = $this->accountRepo->associateAccounts($userId, Auth::user()->id);
Session::flash('message', trans('texts.associated_accounts'));
- // check if other accounts are linked
+ // check if other accounts are linked
} else {
$users = $this->accountRepo->loadAccounts(Auth::user()->id);
}
@@ -127,14 +160,16 @@ class AuthController extends Controller {
return $response;
}
-
+ /**
+ * @return \Illuminate\Http\Response
+ */
public function getLogoutWrapper()
{
if (Auth::check() && !Auth::user()->registered) {
$account = Auth::user()->account;
$this->accountRepo->unlinkAccount($account);
if ($account->company->accounts->count() == 1) {
- $account->company->forceDelete();
+ $account->company->forceDelete();
}
$account->forceDelete();
}
diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php
index bd7d0bb0ef8b..e26ca7bc1fea 100644
--- a/app/Http/Controllers/Auth/PasswordController.php
+++ b/app/Http/Controllers/Auth/PasswordController.php
@@ -3,33 +3,36 @@
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
-class PasswordController extends Controller {
+class PasswordController extends Controller
+{
- /*
- |--------------------------------------------------------------------------
- | Password Reset Controller
- |--------------------------------------------------------------------------
- |
- | This controller is responsible for handling password reset requests
- | and uses a simple trait to include this behavior. You're free to
- | explore this trait and override any methods you wish to tweak.
- |
- */
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset requests
+ | and uses a simple trait to include this behavior. You're free to
+ | explore this trait and override any methods you wish to tweak.
+ |
+ */
- use ResetsPasswords;
+ use ResetsPasswords;
+ /**
+ * @var string
+ */
protected $redirectTo = '/dashboard';
-
- /**
- * Create a new password controller instance.
- *
- * @param \Illuminate\Contracts\Auth\Guard $auth
- * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
- * @return void
- */
- public function __construct()
- {
- $this->middleware('guest');
- }
+
+ /**
+ * Create a new password controller instance.
+ *
+ * @internal param \Illuminate\Contracts\Auth\Guard $auth
+ * @internal param \Illuminate\Contracts\Auth\PasswordBroker $passwords
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ }
}
diff --git a/app/Http/Controllers/BankAccountController.php b/app/Http/Controllers/BankAccountController.php
index 1c003cfd47b0..338894c6923f 100644
--- a/app/Http/Controllers/BankAccountController.php
+++ b/app/Http/Controllers/BankAccountController.php
@@ -2,19 +2,12 @@
use Cache;
use Auth;
-use Datatable;
-use DB;
use Input;
use Redirect;
use Session;
use View;
-use Validator;
-use stdClass;
use Crypt;
-use URL;
-use Utils;
use File;
-use App\Models\Gateway;
use App\Models\Account;
use App\Models\BankAccount;
use App\Ninja\Repositories\BankAccountRepository;
diff --git a/app/Http/Controllers/BaseAPIController.php b/app/Http/Controllers/BaseAPIController.php
index 7f4f22164d38..05ea89f89a0b 100644
--- a/app/Http/Controllers/BaseAPIController.php
+++ b/app/Http/Controllers/BaseAPIController.php
@@ -1,13 +1,10 @@
first();
if ($contact && !$contact->is_deleted) {
$account = $contact->account;
@@ -34,14 +38,15 @@ class AuthController extends Controller {
$data['clientFontUrl'] = $account->getFontsUrl();
}
}
-
- return view('clientauth.login')->with($data);
- }
- /**
+ return view('clientauth.login')->with($data);
+ }
+
+ /**
* Get the needed authorization credentials from the request.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
+ *
* @return array
*/
protected function getCredentials(Request $request)
@@ -50,20 +55,21 @@ class AuthController extends Controller {
$credentials['id'] = null;
$contactKey = session('contact_key');
- if($contactKey){
+ if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$credentials['id'] = $contact->id;
}
}
-
+
return $credentials;
}
-
- /**
+
+ /**
* Validate the user login request.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
+ *
* @return void
*/
protected function validateLogin(Request $request)
@@ -73,6 +79,9 @@ class AuthController extends Controller {
]);
}
+ /**
+ * @return mixed
+ */
public function getSessionExpired()
{
return view('clientauth.sessionexpired');
diff --git a/app/Http/Controllers/ClientAuth/PasswordController.php b/app/Http/Controllers/ClientAuth/PasswordController.php
index af3d97029edf..a7957cacf5d1 100644
--- a/app/Http/Controllers/ClientAuth/PasswordController.php
+++ b/app/Http/Controllers/ClientAuth/PasswordController.php
@@ -9,42 +9,47 @@ use Illuminate\Support\Facades\Password;
use App\Models\Contact;
use App\Models\Invitation;
+class PasswordController extends Controller
+{
-class PasswordController extends Controller {
+ /*
+ |--------------------------------------------------------------------------
+ | Password Reset Controller
+ |--------------------------------------------------------------------------
+ |
+ | This controller is responsible for handling password reset requests
+ | and uses a simple trait to include this behavior. You're free to
+ | explore this trait and override any methods you wish to tweak.
+ |
+ */
- /*
- |--------------------------------------------------------------------------
- | Password Reset Controller
- |--------------------------------------------------------------------------
- |
- | This controller is responsible for handling password reset requests
- | and uses a simple trait to include this behavior. You're free to
- | explore this trait and override any methods you wish to tweak.
- |
- */
-
- use ResetsPasswords;
+ use ResetsPasswords;
+ /**
+ * @var string
+ */
protected $redirectTo = '/client/dashboard';
-
- /**
- * Create a new password controller instance.
- *
- * @param \Illuminate\Contracts\Auth\Guard $auth
- * @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
- * @return void
- */
- public function __construct()
- {
- $this->middleware('guest');
- Config::set("auth.defaults.passwords","client");
- }
- public function showLinkRequestForm()
- {
- $data = array();
+ /**
+ * Create a new password controller instance.
+ *
+ * @internal param \Illuminate\Contracts\Auth\Guard $auth
+ * @internal param \Illuminate\Contracts\Auth\PasswordBroker $passwords
+ */
+ public function __construct()
+ {
+ $this->middleware('guest');
+ Config::set('auth.defaults.passwords', 'client');
+ }
+
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function showLinkRequestForm()
+ {
+ $data = [];
$contactKey = session('contact_key');
- if($contactKey){
+ if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$account = $contact->account;
@@ -54,14 +59,15 @@ class PasswordController extends Controller {
} else {
return \Redirect::to('/client/sessionexpired');
}
-
- return view('clientauth.password')->with($data);
- }
-
- /**
+
+ return view('clientauth.password')->with($data);
+ }
+
+ /**
* Send a reset link to the given user.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
+ *
* @return \Illuminate\Http\Response
*/
public function sendResetLinkEmail(Request $request)
@@ -70,14 +76,14 @@ class PasswordController extends Controller {
$contactId = null;
$contactKey = session('contact_key');
- if($contactKey){
+ if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$contactId = $contact->id;
}
}
-
- $response = Password::broker($broker)->sendResetLink(array('id'=>$contactId), function (Message $message) {
+
+ $response = Password::broker($broker)->sendResetLink(['id' => $contactId], function (Message $message) {
$message->subject($this->getEmailSubject());
});
@@ -90,15 +96,15 @@ class PasswordController extends Controller {
return $this->getSendResetLinkEmailFailureResponse($response);
}
}
-
+
/**
* Display the password reset view for the given token.
*
* If no token is present, display the link request form.
*
- * @param \Illuminate\Http\Request $request
- * @param string|null $key
- * @param string|null $token
+ * @param \Illuminate\Http\Request $request
+ * @param string|null $key
+ * @param string|null $token
* @return \Illuminate\Http\Response
*/
public function showResetForm(Request $request, $key = null, $token = null)
@@ -106,9 +112,9 @@ class PasswordController extends Controller {
if (is_null($token)) {
return $this->getEmail();
}
-
+
$data = compact('token');
- if($key) {
+ if ($key) {
$contact = Contact::where('contact_key', '=', $key)->first();
if ($contact && !$contact->is_deleted) {
$account = $contact->account;
@@ -132,28 +138,27 @@ class PasswordController extends Controller {
return view('clientauth.reset')->with($data);
}
-
-
+
/**
* Display the password reset view for the given token.
*
* If no token is present, display the link request form.
*
- * @param \Illuminate\Http\Request $request
- * @param string|null $key
- * @param string|null $token
+ * @param \Illuminate\Http\Request $request
+ * @param string|null $key
+ * @param string|null $token
* @return \Illuminate\Http\Response
*/
public function getReset(Request $request, $key = null, $token = null)
{
return $this->showResetForm($request, $key, $token);
}
-
+
/**
* Reset the given user's password.
*
- * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function reset(Request $request)
@@ -163,11 +168,11 @@ class PasswordController extends Controller {
$credentials = $request->only(
'password', 'password_confirmation', 'token'
);
-
+
$credentials['id'] = null;
$contactKey = session('contact_key');
- if($contactKey){
+ if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$credentials['id'] = $contact->id;
@@ -188,7 +193,7 @@ class PasswordController extends Controller {
return $this->getResetFailureResponse($request, $response);
}
}
-
+
/**
* Get the password reset validation rules.
*
diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php
index 66a5e1e25e0d..728e6fc91ca4 100644
--- a/app/Http/Controllers/ClientController.php
+++ b/app/Http/Controllers/ClientController.php
@@ -1,33 +1,21 @@
ENTITY_CLIENT,
'title' => trans('texts.clients'),
'sortCol' => '4',
@@ -67,7 +55,7 @@ class ClientController extends BaseController
'balance',
''
]),
- ));
+ ]);
}
public function getDatatable()
@@ -131,7 +119,7 @@ class ClientController extends BaseController
$token = $client->getGatewayToken();
- $data = array(
+ $data = [
'actionLinks' => $actionLinks,
'showBreadcrumbs' => false,
'client' => $client,
@@ -142,7 +130,7 @@ class ClientController extends BaseController
'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0,
'gatewayLink' => $token ? $token->gatewayLink() : false,
'gatewayName' => $token ? $token->gatewayName() : false,
- );
+ ];
return View::make('clients.show', $data);
}
@@ -155,7 +143,7 @@ class ClientController extends BaseController
public function create(ClientRequest $request)
{
if (Client::scope()->withTrashed()->count() > Auth::user()->getMaxNumClients()) {
- return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumClients()." clients"]);
+ return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumClients().' clients']);
}
$data = [
diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php
index 333b9f6ff751..c1cb81696146 100644
--- a/app/Http/Controllers/ClientPortalController.php
+++ b/app/Http/Controllers/ClientPortalController.php
@@ -2,7 +2,6 @@
use Auth;
use View;
-use DB;
use URL;
use Input;
use Utils;
@@ -98,7 +97,7 @@ class ClientPortalController extends BaseController
'phone',
]);
- $data = array();
+ $data = [];
$paymentTypes = $this->getPaymentTypes($account, $client, $invitation);
$paymentURL = '';
if (count($paymentTypes) == 1) {
@@ -120,7 +119,7 @@ class ClientPortalController extends BaseController
$showApprove = false;
}
- $data += array(
+ $data += [
'account' => $account,
'showApprove' => $showApprove,
'showBreadcrumbs' => false,
@@ -132,7 +131,7 @@ class ClientPortalController extends BaseController
'paymentTypes' => $paymentTypes,
'paymentURL' => $paymentURL,
'phantomjs' => Input::has('phantomjs'),
- );
+ ];
if ($paymentDriver = $account->paymentDriver($invitation, GATEWAY_TYPE_CREDIT_CARD)) {
$data += [
@@ -383,7 +382,7 @@ class ClientPortalController extends BaseController
private function getPaymentStatusLabel($model)
{
- $label = trans("texts.status_" . strtolower($model->payment_status_name));
+ $label = trans('texts.status_' . strtolower($model->payment_status_name));
$class = 'default';
switch ($model->payment_status_id) {
case PAYMENT_STATUS_PENDING:
@@ -512,7 +511,7 @@ class ClientPortalController extends BaseController
if(!$document->isPDFEmbeddable()){
- return Response::view('error', array('error'=>'Image does not exist!'), 404);
+ return Response::view('error', ['error'=>'Image does not exist!'], 404);
}
$authorized = false;
@@ -523,7 +522,7 @@ class ClientPortalController extends BaseController
}
if(!$authorized){
- return Response::view('error', array('error'=>'Not authorized'), 403);
+ return Response::view('error', ['error'=>'Not authorized'], 403);
}
if(substr($name, -3)=='.js'){
@@ -554,7 +553,7 @@ class ClientPortalController extends BaseController
$size = 0;
$maxSize = MAX_ZIP_DOCUMENTS_SIZE * 1000;
- $toZip = array();
+ $toZip = [];
foreach($documents as $document){
if($size + $document->size > $maxSize)break;
@@ -600,7 +599,7 @@ class ClientPortalController extends BaseController
$toZip = $this->getInvoiceZipDocuments($invoice);
if(!count($toZip)){
- return Response::view('error', array('error'=>'No documents small enough'), 404);
+ return Response::view('error', ['error'=>'No documents small enough'], 404);
}
$zip = new ZipArchive($invitation->account->name.' Invoice '.$invoice->invoice_number.'.zip');
@@ -608,7 +607,7 @@ class ClientPortalController extends BaseController
foreach($toZip as $name=>$document){
$fileStream = $document->getStream();
if($fileStream){
- $zip->init_file_stream_transfer($name, $document->size, array('time'=>$document->created_at->timestamp));
+ $zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]);
while ($buffer = fread($fileStream, 256000))$zip->stream_file_part($buffer);
fclose($fileStream);
$zip->complete_file_stream();
@@ -639,7 +638,7 @@ class ClientPortalController extends BaseController
}
if(!$authorized){
- return Response::view('error', array('error'=>'Not authorized'), 403);
+ return Response::view('error', ['error'=>'Not authorized'], 403);
}
return DocumentController::getDownloadResponse($document);
@@ -657,7 +656,7 @@ class ClientPortalController extends BaseController
$paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN);
$customer = $paymentDriver->customer($client->id);
- $data = array(
+ $data = [
'account' => $account,
'contact' => $contact,
'color' => $account->primary_color ? $account->primary_color : '#0b4d78',
@@ -668,7 +667,7 @@ class ClientPortalController extends BaseController
'gateway' => $account->getTokenGateway(),
'title' => trans('texts.payment_methods'),
'transactionToken' => $paymentDriver->createTransactionToken(),
- );
+ ];
return response()->view('payments.paymentmethods', $data);
}
@@ -730,7 +729,7 @@ class ClientPortalController extends BaseController
$client = $contact->client;
$account = $client->account;
- $validator = Validator::make(Input::all(), array('source' => 'required'));
+ $validator = Validator::make(Input::all(), ['source' => 'required']);
if ($validator->fails()) {
return Redirect::to($client->account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/');
}
@@ -768,7 +767,7 @@ class ClientPortalController extends BaseController
$client = $contact->client;
- $validator = Validator::make(Input::all(), array('public_id' => 'required'));
+ $validator = Validator::make(Input::all(), ['public_id' => 'required']);
if ($validator->fails()) {
return Redirect::to('client/invoices/recurring');
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index b3a6ac7b1f59..b0c144732f6a 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -4,8 +4,10 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
-abstract class Controller extends BaseController {
-
- use DispatchesJobs, ValidatesRequests;
-
+/**
+ * Class Controller
+ */
+abstract class Controller extends BaseController
+{
+ use DispatchesJobs, ValidatesRequests;
}
diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php
index ff1257d4456c..e9b66d6e8b85 100644
--- a/app/Http/Controllers/CreditController.php
+++ b/app/Http/Controllers/CreditController.php
@@ -1,13 +1,11 @@
ENTITY_CREDIT,
'title' => trans('texts.credits'),
'sortCol' => '4',
@@ -48,7 +46,7 @@ class CreditController extends BaseController
'private_notes',
''
]),
- ));
+ ]);
}
public function getDatatable($clientPublicId = null)
@@ -58,14 +56,14 @@ class CreditController extends BaseController
public function create(CreditRequest $request)
{
- $data = array(
+ $data = [
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
'credit' => null,
'method' => 'POST',
'url' => 'credits',
'title' => trans('texts.new_credit'),
'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(),
- );
+ ];
return View::make('credits.edit', $data);
}
diff --git a/app/Http/Controllers/DashboardApiController.php b/app/Http/Controllers/DashboardApiController.php
index 6d69c53f2a01..c97f1408b07e 100644
--- a/app/Http/Controllers/DashboardApiController.php
+++ b/app/Http/Controllers/DashboardApiController.php
@@ -2,8 +2,6 @@
use Auth;
use DB;
-use View;
-use App\Models\Activity;
class DashboardApiController extends BaseAPIController
{
diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php
index 71a63ab86174..209e88b0c0dc 100644
--- a/app/Http/Controllers/DashboardController.php
+++ b/app/Http/Controllers/DashboardController.php
@@ -7,8 +7,14 @@ use App\Models\Activity;
use App\Models\Invoice;
use App\Models\Payment;
+/**
+ * Class DashboardController
+ */
class DashboardController extends BaseController
{
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function index()
{
$view_all = Auth::user()->hasPermission('view_all');
diff --git a/app/Http/Controllers/DocumentAPIController.php b/app/Http/Controllers/DocumentAPIController.php
index 442b3923ccd2..01a05a17e2fa 100644
--- a/app/Http/Controllers/DocumentAPIController.php
+++ b/app/Http/Controllers/DocumentAPIController.php
@@ -1,17 +1,30 @@
documentRepo = $documentRepo;
}
+ /**
+ * @return \Illuminate\Http\Response
+ */
public function index()
{
$documents = Document::scope();
@@ -27,6 +43,11 @@ class DocumentAPIController extends BaseAPIController
}
+ /**
+ * @param DocumentRequest $request
+ *
+ * @return \Illuminate\Http\Response|\Redirect|\Symfony\Component\HttpFoundation\StreamedResponse
+ */
public function show(DocumentRequest $request)
{
$document = $request->entity();
@@ -34,6 +55,11 @@ class DocumentAPIController extends BaseAPIController
return DocumentController::getDownloadResponse($document);
}
+ /**
+ * @param CreateDocumentRequest $request
+ *
+ * @return \Illuminate\Http\Response
+ */
public function store(CreateDocumentRequest $request)
{
@@ -41,14 +67,4 @@ class DocumentAPIController extends BaseAPIController
return $this->itemResponse($document);
}
-
- public function update()
- {
- //stub
- }
-
- public function destroy($publicId)
- {
- //stub
- }
}
diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php
index 6f6b0bd0889d..f25a027f8662 100644
--- a/app/Http/Controllers/DocumentController.php
+++ b/app/Http/Controllers/DocumentController.php
@@ -1,17 +1,10 @@
entity();
if(empty($document->preview)){
- return Response::view('error', array('error'=>'Preview does not exist!'), 404);
+ return Response::view('error', ['error'=>'Preview does not exist!'], 404);
}
$direct_url = $document->getDirectPreviewUrl();
@@ -88,7 +81,7 @@ class DocumentController extends BaseController
}
if(!$document->isPDFEmbeddable()){
- return Response::view('error', array('error'=>'Image does not exist!'), 404);
+ return Response::view('error', ['error'=>'Image does not exist!'], 404);
}
$content = $document->preview?$document->getRawPreview():$document->getRaw();
diff --git a/app/Http/Controllers/ExpenseApiController.php b/app/Http/Controllers/ExpenseApiController.php
index 6d190c1a48c9..ea4425df86e8 100644
--- a/app/Http/Controllers/ExpenseApiController.php
+++ b/app/Http/Controllers/ExpenseApiController.php
@@ -2,13 +2,7 @@
use App\Models\Expense;
use App\Ninja\Repositories\ExpenseRepository;
-use App\Ninja\Transformers\ExpenseTransformer;
use App\Services\ExpenseService;
-use Utils;
-use Response;
-use Input;
-use Auth;
-
class ExpenseApiController extends BaseAPIController
{
diff --git a/app/Http/Controllers/ExpenseController.php b/app/Http/Controllers/ExpenseController.php
index d4184abf3fca..39a0b788fc2d 100644
--- a/app/Http/Controllers/ExpenseController.php
+++ b/app/Http/Controllers/ExpenseController.php
@@ -1,13 +1,9 @@
ENTITY_EXPENSE,
'title' => trans('texts.expenses'),
'sortCol' => '3',
@@ -58,7 +53,7 @@ class ExpenseController extends BaseController
'status',
''
]),
- ));
+ ]);
}
public function getDatatable($expensePublicId = null)
@@ -79,7 +74,7 @@ class ExpenseController extends BaseController
$vendor = null;
}
- $data = array(
+ $data = [
'vendorPublicId' => Input::old('vendor') ? Input::old('vendor') : $request->vendor_id,
'expense' => null,
'method' => 'POST',
@@ -89,7 +84,7 @@ class ExpenseController extends BaseController
'vendor' => $vendor,
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'clientPublicId' => $request->client_id,
- );
+ ];
$data = array_merge($data, self::getViewModel());
@@ -104,9 +99,9 @@ class ExpenseController extends BaseController
$actions = [];
if ($expense->invoice) {
- $actions[] = ['url' => URL::to("invoices/{$expense->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
+ $actions[] = ['url' => URL::to("invoices/{$expense->invoice->public_id}/edit"), 'label' => trans('texts.view_invoice')];
} else {
- $actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_expense")];
+ $actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans('texts.invoice_expense')];
}
$actions[] = \DropdownButton::DIVIDER;
@@ -117,7 +112,7 @@ class ExpenseController extends BaseController
$actions[] = ['url' => 'javascript:submitAction("restore")', 'label' => trans('texts.restore_expense')];
}
- $data = array(
+ $data = [
'vendor' => null,
'expense' => $expense,
'method' => 'PUT',
@@ -128,7 +123,7 @@ class ExpenseController extends BaseController
'vendorPublicId' => $expense->vendor ? $expense->vendor->public_id : null,
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'clientPublicId' => $expense->client ? $expense->client->public_id : null,
- );
+ ];
$data = array_merge($data, self::getViewModel());
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index d38f492486ae..41b28ffb139f 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -16,8 +16,16 @@ use App\Models\Payment;
use App\Models\Vendor;
use App\Models\VendorContact;
+/**
+ * Class ExportController
+ */
class ExportController extends BaseController
{
+ /**
+ * @param Request $request
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
public function doExport(Request $request)
{
$format = $request->input('format');
@@ -33,6 +41,12 @@ class ExportController extends BaseController
}
}
+ /**
+ * @param $request
+ * @param $fileName
+ *
+ * @return \Illuminate\Http\JsonResponse
+ */
private function returnJSON($request, $fileName)
{
$output = fopen('php://output', 'w') or Utils::fatalError();
@@ -62,7 +76,12 @@ class ExportController extends BaseController
return response()->json($data);
}
-
+ /**
+ * @param $request
+ * @param $fileName
+ *
+ * @return mixed
+ */
private function returnCSV($request, $fileName)
{
$data = $this->getData($request);
@@ -74,6 +93,12 @@ class ExportController extends BaseController
})->download('csv');
}
+ /**
+ * @param $request
+ * @param $fileName
+ *
+ * @return mixed
+ */
private function returnXLS($request, $fileName)
{
$user = Auth::user();
@@ -110,6 +135,11 @@ class ExportController extends BaseController
})->download('xls');
}
+ /**
+ * @param $request
+ *
+ * @return array
+ */
private function getData($request)
{
$account = Auth::user()->account;
@@ -184,12 +214,6 @@ class ExportController extends BaseController
->with('user', 'vendor.vendor_contacts')
->withTrashed()
->get();
-
- /*
- $data['expenses'] = Credit::scope()
- ->with('user', 'client.contacts')
- ->get();
- */
}
return $data;
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index f01c4a6f1354..395d4a0f242d 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -9,12 +9,22 @@ use Session;
use App\Models\Account;
use App\Libraries\Utils;
use App\Ninja\Mailers\Mailer;
-use Symfony\Component\Security\Core\Util\StringUtils;
+/**
+ * Class HomeController
+ */
class HomeController extends BaseController
{
+ /**
+ * @var Mailer
+ */
protected $mailer;
+ /**
+ * HomeController constructor.
+ *
+ * @param Mailer $mailer
+ */
public function __construct(Mailer $mailer)
{
//parent::__construct();
@@ -22,6 +32,9 @@ class HomeController extends BaseController
$this->mailer = $mailer;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function showIndex()
{
Session::reflash();
@@ -35,16 +48,25 @@ class HomeController extends BaseController
}
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function showTerms()
{
return View::make('public.terms', ['hideHeader' => true]);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function viewLogo()
{
return View::make('public.logo');
}
-
+
+ /**
+ * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
+ */
public function invoiceNow()
{
if (Auth::check() && Input::get('new_company')) {
@@ -68,6 +90,11 @@ class HomeController extends BaseController
}
}
+ /**
+ * @param $userType
+ * @param $version
+ * @return \Illuminate\Http\JsonResponse
+ */
public function newsFeed($userType, $version)
{
$response = Utils::getNewsFeedResponse($userType);
@@ -75,6 +102,9 @@ class HomeController extends BaseController
return Response::json($response);
}
+ /**
+ * @return string
+ */
public function hideMessage()
{
if (Auth::check() && Session::has('news_feed_id')) {
@@ -91,11 +121,17 @@ class HomeController extends BaseController
return 'success';
}
+ /**
+ * @return string
+ */
public function logError()
{
return Utils::logError(Input::get('error'), 'JavaScript');
}
+ /**
+ * @return mixed
+ */
public function keepAlive()
{
return RESULT_SUCCESS;
diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php
index 3e53170ced35..3e893d57b59a 100644
--- a/app/Http/Controllers/ImportController.php
+++ b/app/Http/Controllers/ImportController.php
@@ -7,7 +7,6 @@ use Input;
use Session;
use Redirect;
use App\Services\ImportService;
-use App\Http\Controllers\BaseController;
class ImportController extends BaseController
{
diff --git a/app/Http/Controllers/IntegrationController.php b/app/Http/Controllers/IntegrationController.php
index 740c91e36127..a55498db8f43 100644
--- a/app/Http/Controllers/IntegrationController.php
+++ b/app/Http/Controllers/IntegrationController.php
@@ -6,8 +6,14 @@ use Auth;
use Input;
use App\Models\Subscription;
+/**
+ * Class IntegrationController
+ */
class IntegrationController extends Controller
{
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ */
public function subscribe()
{
$eventId = Utils::lookupEventId(trim(Input::get('event')));
diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php
index cd7188c44591..ce95ef83d114 100644
--- a/app/Http/Controllers/InvoiceApiController.php
+++ b/app/Http/Controllers/InvoiceApiController.php
@@ -1,7 +1,6 @@
'javascript:onCloneClick()', 'label' => trans("texts.clone_{$entityType}")],
- ['url' => URL::to("{$entityType}s/{$entityType}_history/{$invoice->public_id}"), 'label' => trans("texts.view_history")],
+ ['url' => URL::to("{$entityType}s/{$entityType}_history/{$invoice->public_id}"), 'label' => trans('texts.view_history')],
DropdownButton::DIVIDER
];
if ($invoice->invoice_status_id < INVOICE_STATUS_SENT && !$invoice->is_recurring) {
- $actions[] = ['url' => 'javascript:onMarkClick()', 'label' => trans("texts.mark_sent")];
+ $actions[] = ['url' => 'javascript:onMarkClick()', 'label' => trans('texts.mark_sent')];
}
if ($entityType == ENTITY_QUOTE) {
if ($invoice->quote_invoice_id) {
- $actions[] = ['url' => URL::to("invoices/{$invoice->quote_invoice_id}/edit"), 'label' => trans("texts.view_invoice")];
+ $actions[] = ['url' => URL::to("invoices/{$invoice->quote_invoice_id}/edit"), 'label' => trans('texts.view_invoice')];
} else {
- $actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans("texts.convert_to_invoice")];
+ $actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
}
} elseif ($entityType == ENTITY_INVOICE) {
if ($invoice->quote_id) {
- $actions[] = ['url' => URL::to("quotes/{$invoice->quote_id}/edit"), 'label' => trans("texts.view_quote")];
+ $actions[] = ['url' => URL::to("quotes/{$invoice->quote_id}/edit"), 'label' => trans('texts.view_quote')];
}
if (!$invoice->is_recurring && $invoice->balance > 0) {
@@ -163,7 +159,7 @@ class InvoiceController extends BaseController
}
foreach ($invoice->payments as $payment) {
- $label = trans("texts.view_payment");
+ $label = trans('texts.view_payment');
if (count($invoice->payments) > 1) {
$label .= ' - ' . $account->formatMoney($payment->amount, $invoice->client);
}
@@ -184,7 +180,7 @@ class InvoiceController extends BaseController
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
}
- $data = array(
+ $data = [
'clients' => $clients->get(),
'entityType' => $entityType,
'showBreadcrumbs' => $clone,
@@ -196,7 +192,7 @@ class InvoiceController extends BaseController
'client' => $invoice->client,
'isRecurring' => $invoice->is_recurring,
'actions' => $actions,
- 'lastSent' => $lastSent);
+ 'lastSent' => $lastSent];
$data = array_merge($data, self::getViewModel($invoice));
if ($invoice->isSent() && $invoice->getAutoBillEnabled() && !$invoice->isPaid()) {
@@ -280,7 +276,7 @@ class InvoiceController extends BaseController
{
$recurringHelp = '';
foreach (preg_split("/((\r?\n)|(\r\n?))/", trans('texts.recurring_help')) as $line) {
- $parts = explode("=>", $line);
+ $parts = explode('=>', $line);
if (count($parts) > 1) {
$line = $parts[0].' => '.Utils::processVariables($parts[0]);
$recurringHelp .= ''.strip_tags($line).'';
@@ -291,7 +287,7 @@ class InvoiceController extends BaseController
$recurringDueDateHelp = '';
foreach (preg_split("/((\r?\n)|(\r\n?))/", trans('texts.recurring_due_date_help')) as $line) {
- $parts = explode("=>", $line);
+ $parts = explode('=>', $line);
if (count($parts) > 1) {
$line = $parts[0].' => '.Utils::processVariables($parts[0]);
$recurringDueDateHelp .= ''.strip_tags($line).'';
@@ -301,24 +297,24 @@ class InvoiceController extends BaseController
}
// Create due date options
- $recurringDueDates = array(
- trans('texts.use_client_terms') => array('value' => '', 'class' => 'monthly weekly'),
- );
+ $recurringDueDates = [
+ trans('texts.use_client_terms') => ['value' => '', 'class' => 'monthly weekly'],
+ ];
- $ends = array('th','st','nd','rd','th','th','th','th','th','th');
+ $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];
$dayStr = str_pad($i, 2, '0', STR_PAD_LEFT);
- $str = trans('texts.day_of_month', array('ordinal'=>$ordinal));
+ $str = trans('texts.day_of_month', ['ordinal'=>$ordinal]);
- $recurringDueDates[$str] = array('value' => "1998-01-$dayStr", 'data-num' => $i, 'class' => 'monthly');
+ $recurringDueDates[$str] = ['value' => "1998-01-$dayStr", 'data-num' => $i, 'class' => 'monthly'];
}
- $recurringDueDates[trans('texts.last_day_of_month')] = array('value' => "1998-01-31", 'data-num' => 31, 'class' => 'monthly');
+ $recurringDueDates[trans('texts.last_day_of_month')] = ['value' => '1998-01-31', 'data-num' => 31, 'class' => 'monthly'];
- $daysOfWeek = array(
+ $daysOfWeek = [
trans('texts.sunday'),
trans('texts.monday'),
trans('texts.tuesday'),
@@ -326,14 +322,14 @@ class InvoiceController extends BaseController
trans('texts.thursday'),
trans('texts.friday'),
trans('texts.saturday'),
- );
- foreach(array('1st','2nd','3rd','4th') as $i=>$ordinal){
+ ];
+ foreach(['1st','2nd','3rd','4th'] as $i=>$ordinal){
foreach($daysOfWeek as $j=>$dayOfWeek){
- $str = trans('texts.day_of_week_after', array('ordinal' => $ordinal, 'day' => $dayOfWeek));
+ $str = trans('texts.day_of_week_after', ['ordinal' => $ordinal, 'day' => $dayOfWeek]);
$day = $i * 7 + $j + 1;
$dayStr = str_pad($day, 2, '0', STR_PAD_LEFT);
- $recurringDueDates[$str] = array('value' => "1998-02-$dayStr", 'data-num' => $day, 'class' => 'weekly');
+ $recurringDueDates[$str] = ['value' => "1998-02-$dayStr", 'data-num' => $day, 'class' => 'weekly'];
}
}
@@ -375,7 +371,7 @@ class InvoiceController extends BaseController
'industries' => Cache::get('industries'),
'invoiceDesigns' => InvoiceDesign::getDesigns(),
'invoiceFonts' => Cache::get('fonts'),
- 'frequencies' => array(
+ 'frequencies' => [
1 => 'Weekly',
2 => 'Two weeks',
3 => 'Four weeks',
@@ -383,7 +379,7 @@ class InvoiceController extends BaseController
5 => 'Three months',
6 => 'Six months',
7 => 'Annually',
- ),
+ ],
'recurringDueDates' => $recurringDueDates,
'recurringHelp' => $recurringHelp,
'recurringDueDateHelp' => $recurringDueDateHelp,
diff --git a/app/Http/Controllers/NinjaController.php b/app/Http/Controllers/NinjaController.php
index 11f9238ae6b4..635207d76282 100644
--- a/app/Http/Controllers/NinjaController.php
+++ b/app/Http/Controllers/NinjaController.php
@@ -17,13 +17,35 @@ use App\Ninja\Mailers\ContactMailer;
class NinjaController extends BaseController
{
+ /**
+ * @var AccountRepository
+ */
+ protected $accountRepo;
+
+ /**
+ * @var ContactMailer
+ */
+ protected $contactMailer;
+
+ /**
+ * NinjaController constructor.
+ *
+ * @param AccountRepository $accountRepo
+ * @param ContactMailer $contactMailer
+ */
public function __construct(AccountRepository $accountRepo, ContactMailer $contactMailer)
{
$this->accountRepo = $accountRepo;
$this->contactMailer = $contactMailer;
}
- private function getLicensePaymentDetails($input, $affiliate)
+ /**
+ * @param array $input
+ * @param Affiliate $affiliate
+ *
+ * @return array
+ */
+ private function getLicensePaymentDetails(array $input, Affiliate $affiliate)
{
$country = Country::find($input['country_id']);
@@ -60,6 +82,9 @@ class NinjaController extends BaseController
];
}
+ /**
+ * @return $this|\Illuminate\Contracts\View\View
+ */
public function show_license_payment()
{
if (Input::has('return_url')) {
@@ -116,11 +141,14 @@ class NinjaController extends BaseController
return View::make('payments.stripe.credit_card', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function do_license_payment()
{
$testMode = Session::get('test_mode') === 'true';
- $rules = array(
+ $rules = [
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required',
@@ -133,7 +161,7 @@ class NinjaController extends BaseController
'state' => 'required',
'postal_code' => 'required',
'country_id' => 'required',
- );
+ ];
$validator = Validator::make(Input::all(), $rules);
@@ -192,7 +220,7 @@ class NinjaController extends BaseController
if (Session::has('return_url')) {
$data['redirectTo'] = Session::get('return_url')."?license_key={$license->license_key}&product_id=".Session::get('product_id');
- $data['message'] = "Redirecting to " . Session::get('return_url');
+ $data['message'] = 'Redirecting to ' . Session::get('return_url');
}
return View::make('public.license', $data);
@@ -202,6 +230,9 @@ class NinjaController extends BaseController
}
}
+ /**
+ * @return string
+ */
public function claim_license()
{
$licenseKey = Input::get('license_key');
diff --git a/app/Http/Controllers/OnlinePaymentController.php b/app/Http/Controllers/OnlinePaymentController.php
index 66b85a335656..60483bf7b2cc 100644
--- a/app/Http/Controllers/OnlinePaymentController.php
+++ b/app/Http/Controllers/OnlinePaymentController.php
@@ -2,11 +2,8 @@
use Session;
use Input;
-use Request;
use Utils;
use View;
-use Validator;
-use Cache;
use Exception;
use App\Models\Invitation;
use App\Models\Account;
@@ -16,14 +13,39 @@ use App\Services\PaymentService;
use App\Ninja\Mailers\UserMailer;
use App\Http\Requests\CreateOnlinePaymentRequest;
+/**
+ * Class OnlinePaymentController
+ */
class OnlinePaymentController extends BaseController
{
+ /**
+ * @var PaymentService
+ */
+ protected $paymentService;
+
+ /**
+ * @var UserMailer
+ */
+ protected $userMailer;
+
+ /**
+ * OnlinePaymentController constructor.
+ *
+ * @param PaymentService $paymentService
+ * @param UserMailer $userMailer
+ */
public function __construct(PaymentService $paymentService, UserMailer $userMailer)
{
$this->paymentService = $paymentService;
$this->userMailer = $userMailer;
}
+ /**
+ * @param $invitationKey
+ * @param bool $gatewayType
+ * @param bool $sourceId
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function showPayment($invitationKey, $gatewayType = false, $sourceId = false)
{
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')
@@ -42,6 +64,10 @@ class OnlinePaymentController extends BaseController
}
}
+ /**
+ * @param CreateOnlinePaymentRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function doPayment(CreateOnlinePaymentRequest $request)
{
$invitation = $request->invitation;
@@ -62,6 +88,11 @@ class OnlinePaymentController extends BaseController
}
}
+ /**
+ * @param bool $invitationKey
+ * @param bool $gatewayType
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function offsitePayment($invitationKey = false, $gatewayType = false)
{
$invitationKey = $invitationKey ?: Session::get('invitation_key');
@@ -84,6 +115,12 @@ class OnlinePaymentController extends BaseController
}
}
+ /**
+ * @param $paymentDriver
+ * @param $exception
+ * @param bool $showPayment
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function error($paymentDriver, $exception, $showPayment = false)
{
if (is_string($exception)) {
@@ -104,6 +141,10 @@ class OnlinePaymentController extends BaseController
return redirect()->to($route . $paymentDriver->invitation->invitation_key);
}
+ /**
+ * @param $routingNumber
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getBankInfo($routingNumber) {
if (strlen($routingNumber) != 9 || !preg_match('/\d{9}/', $routingNumber)) {
return response()->json([
@@ -126,6 +167,11 @@ class OnlinePaymentController extends BaseController
], 404);
}
+ /**
+ * @param $accountKey
+ * @param $gatewayId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function handlePaymentWebhook($accountKey, $gatewayId)
{
$gatewayId = intval($gatewayId);
diff --git a/app/Http/Controllers/PaymentApiController.php b/app/Http/Controllers/PaymentApiController.php
index 3355b6bff8f4..b311b1caf4d9 100644
--- a/app/Http/Controllers/PaymentApiController.php
+++ b/app/Http/Controllers/PaymentApiController.php
@@ -1,17 +1,11 @@
paymentRepo = $paymentRepo;
$this->contactMailer = $contactMailer;
$this->paymentService = $paymentService;
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function index()
{
- return View::make('list', array(
+ return View::make('list', [
'entityType' => ENTITY_PAYMENT,
'title' => trans('texts.payments'),
'sortCol' => '7',
@@ -44,14 +75,22 @@ class PaymentController extends BaseController
'status',
''
]),
- ));
+ ]);
}
+ /**
+ * @param null $clientPublicId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($clientPublicId = null)
{
return $this->paymentService->getDatatable($clientPublicId, Input::get('sSearch'));
}
+ /**
+ * @param PaymentRequest $request
+ * @return \Illuminate\Contracts\View\View
+ */
public function create(PaymentRequest $request)
{
$invoices = Invoice::scope()
@@ -62,29 +101,33 @@ class PaymentController extends BaseController
->with('client', 'invoice_status')
->orderBy('invoice_number')->get();
- $data = array(
+ $data = [
'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0),
'invoice' => null,
'invoices' => $invoices,
'payment' => null,
'method' => 'POST',
- 'url' => "payments",
+ 'url' => 'payments',
'title' => trans('texts.new_payment'),
'paymentTypes' => Cache::get('paymentTypes'),
'paymentTypeId' => Input::get('paymentTypeId'),
- 'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(), );
+ 'clients' => Client::scope()->viewable()->with('contacts')->orderBy('name')->get(), ];
return View::make('payments.edit', $data);
}
+ /**
+ * @param PaymentRequest $request
+ * @return \Illuminate\Contracts\View\View
+ */
public function edit(PaymentRequest $request)
{
$payment = $request->entity();
$payment->payment_date = Utils::fromSqlDate($payment->payment_date);
- $data = array(
+ $data = [
'client' => null,
'invoice' => null,
'invoices' => Invoice::scope()->invoiceType(INVOICE_TYPE_STANDARD)->where('is_recurring', '=', false)
@@ -94,11 +137,15 @@ class PaymentController extends BaseController
'url' => 'payments/'.$payment->public_id,
'title' => trans('texts.edit_payment'),
'paymentTypes' => Cache::get('paymentTypes'),
- 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
+ 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), ];
return View::make('payments.edit', $data);
}
+ /**
+ * @param CreatePaymentRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function store(CreatePaymentRequest $request)
{
$input = $request->input();
@@ -117,6 +164,10 @@ class PaymentController extends BaseController
return redirect()->to($payment->client->getRoute());
}
+ /**
+ * @param UpdatePaymentRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function update(UpdatePaymentRequest $request)
{
$payment = $this->paymentRepo->save($request->input(), $request->entity());
@@ -126,12 +177,15 @@ class PaymentController extends BaseController
return redirect()->to($payment->getRoute());
}
+ /**
+ * @return mixed
+ */
public function bulk()
{
$action = Input::get('action');
$amount = Input::get('amount');
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
- $count = $this->paymentService->bulk($ids, $action, array('amount'=>$amount));
+ $count = $this->paymentService->bulk($ids, $action, ['amount'=>$amount]);
if ($count > 0) {
$message = Utils::pluralize($action=='refund'?'refunded_payment':$action.'d_payment', $count);
@@ -140,5 +194,4 @@ class PaymentController extends BaseController
return redirect()->to('payments');
}
-
}
diff --git a/app/Http/Controllers/PaymentTermController.php b/app/Http/Controllers/PaymentTermController.php
index 35b57ce26d9d..30f3c5bf42d7 100644
--- a/app/Http/Controllers/PaymentTermController.php
+++ b/app/Http/Controllers/PaymentTermController.php
@@ -1,25 +1,25 @@
paymentTermService = $paymentTermService;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function index()
{
return Redirect::to('settings/' . ACCOUNT_PAYMENT_TERMS);
}
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable()
{
return $this->paymentTermService->getDatatable();
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Contracts\View\View
+ */
public function edit($publicId)
{
$data = [
@@ -49,6 +59,9 @@ class PaymentTermController extends BaseController
return View::make('accounts.payment_term', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function create()
{
$data = [
@@ -61,16 +74,27 @@ class PaymentTermController extends BaseController
return View::make('accounts.payment_term', $data);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function store()
{
return $this->save();
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function update($publicId)
{
return $this->save($publicId);
}
+ /**
+ * @param bool $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function save($publicId = false)
{
if ($publicId) {
@@ -89,6 +113,9 @@ class PaymentTermController extends BaseController
return Redirect::to('settings/' . ACCOUNT_PAYMENT_TERMS);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function bulk()
{
$action = Input::get('bulk_action');
diff --git a/app/Http/Controllers/ProductApiController.php b/app/Http/Controllers/ProductApiController.php
index 6a8756eda4b6..0143007d84dd 100644
--- a/app/Http/Controllers/ProductApiController.php
+++ b/app/Http/Controllers/ProductApiController.php
@@ -5,12 +5,26 @@ use App\Ninja\Repositories\ProductRepository;
use App\Http\Requests\CreateProductRequest;
use App\Http\Requests\UpdateProductRequest;
+/**
+ * Class ProductApiController
+ */
class ProductApiController extends BaseAPIController
{
- protected $productRepo;
-
+ /**
+ * @var string
+ */
protected $entityType = ENTITY_PRODUCT;
+ /**
+ * @var ProductRepository
+ */
+ protected $productRepo;
+
+ /**
+ * ProductApiController constructor.
+ *
+ * @param ProductRepository $productRepo
+ */
public function __construct(ProductRepository $productRepo)
{
parent::__construct();
@@ -18,6 +32,9 @@ class ProductApiController extends BaseAPIController
$this->productRepo = $productRepo;
}
+ /**
+ * @return \Illuminate\Http\Response
+ */
public function index()
{
$products = Product::scope()
@@ -27,6 +44,10 @@ class ProductApiController extends BaseAPIController
return $this->listResponse($products);
}
+ /**
+ * @param CreateProductRequest $request
+ * @return \Illuminate\Http\Response
+ */
public function store(CreateProductRequest $request)
{
$product = $this->productRepo->save($request->input());
@@ -34,6 +55,11 @@ class ProductApiController extends BaseAPIController
return $this->itemResponse($product);
}
+ /**
+ * @param UpdateProductRequest $request
+ * @param $publicId
+ * @return \Illuminate\Http\Response
+ */
public function update(UpdateProductRequest $request, $publicId)
{
if ($request->action) {
@@ -46,9 +72,4 @@ class ProductApiController extends BaseAPIController
return $this->itemResponse($product);
}
-
- public function destroy($publicId)
- {
- //stub
- }
}
diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php
index bd5eed57db94..626edbae2f1e 100644
--- a/app/Http/Controllers/ProductController.php
+++ b/app/Http/Controllers/ProductController.php
@@ -1,24 +1,30 @@
productService = $productService;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function index()
{
return Redirect::to('settings/' . ACCOUNT_PRODUCTS);
}
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable()
{
return $this->productService->getDatatable(Auth::user()->account_id);
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Contracts\View\View
+ */
public function edit($publicId)
{
$account = Auth::user()->account;
@@ -52,6 +68,9 @@ class ProductController extends BaseController
return View::make('accounts.product', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function create()
{
$account = Auth::user()->account;
@@ -68,16 +87,27 @@ class ProductController extends BaseController
return View::make('accounts.product', $data);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function store()
{
return $this->save();
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function update($publicId)
{
return $this->save($publicId);
}
+ /**
+ * @param bool $productPublicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function save($productPublicId = false)
{
if ($productPublicId) {
@@ -99,6 +129,9 @@ class ProductController extends BaseController
return Redirect::to('settings/' . ACCOUNT_PRODUCTS);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function bulk()
{
$action = Input::get('bulk_action');
diff --git a/app/Http/Controllers/QuoteApiController.php b/app/Http/Controllers/QuoteApiController.php
index 0a04b99bd004..d6c572ceb08e 100644
--- a/app/Http/Controllers/QuoteApiController.php
+++ b/app/Http/Controllers/QuoteApiController.php
@@ -1,13 +1,8 @@
ENTITY_QUOTE,
'account' => Auth::user()->account,
- 'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
+ 'products' => Product::scope()->orderBy('id')->get(['product_key', 'notes', 'cost', 'qty']),
'taxRateOptions' => $options,
'defaultTax' => $defaultTax,
'countries' => Cache::get('countries'),
@@ -160,15 +153,15 @@ class QuoteController extends BaseController
$count = $this->invoiceService->bulk($ids, $action);
if ($count > 0) {
- $key = $action == 'markSent' ? "updated_quote" : "{$action}d_quote";
+ $key = $action == 'markSent' ? 'updated_quote' : "{$action}d_quote";
$message = Utils::pluralize($key, $count);
Session::flash('message', $message);
}
if ($action == 'restore' && $count == 1) {
- return Redirect::to("quotes/".Utils::getFirst($ids));
+ return Redirect::to('quotes/'.Utils::getFirst($ids));
} else {
- return Redirect::to("quotes");
+ return Redirect::to('quotes');
}
}
diff --git a/app/Http/Controllers/RecurringInvoiceController.php b/app/Http/Controllers/RecurringInvoiceController.php
index 2982e04e3312..4a1d6431ed5a 100644
--- a/app/Http/Controllers/RecurringInvoiceController.php
+++ b/app/Http/Controllers/RecurringInvoiceController.php
@@ -3,10 +3,20 @@
use Utils;
use App\Ninja\Repositories\InvoiceRepository;
+/**
+ * Class RecurringInvoiceController
+ */
class RecurringInvoiceController extends BaseController
{
+ /**
+ * @var InvoiceRepository
+ */
protected $invoiceRepo;
+ /**
+ * RecurringInvoiceController constructor.
+ * @param InvoiceRepository $invoiceRepo
+ */
public function __construct(InvoiceRepository $invoiceRepo)
{
//parent::__construct();
@@ -14,6 +24,9 @@ class RecurringInvoiceController extends BaseController
$this->invoiceRepo = $invoiceRepo;
}
+ /**
+ * @return mixed
+ */
public function index()
{
$data = [
diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php
index d00280e60f29..aa169b3e58cd 100644
--- a/app/Http/Controllers/ReportController.php
+++ b/app/Http/Controllers/ReportController.php
@@ -14,8 +14,14 @@ use App\Models\Client;
use App\Models\Payment;
use App\Models\Expense;
+/**
+ * Class ReportController
+ */
class ReportController extends BaseController
{
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function d3()
{
$message = '';
@@ -42,6 +48,9 @@ class ReportController extends BaseController
return View::make('reports.d3', $data);
}
+ /**
+ * @return \Illuminate\Contracts\View\View
+ */
public function showReports()
{
$action = Input::get('action');
@@ -123,6 +132,12 @@ class ReportController extends BaseController
return View::make('reports.chart_builder', $params);
}
+ /**
+ * @param $groupBy
+ * @param $startDate
+ * @param $endDate
+ * @return array
+ */
private function generateChart($groupBy, $startDate, $endDate)
{
$width = 10;
@@ -221,6 +236,14 @@ class ReportController extends BaseController
];
}
+ /**
+ * @param $reportType
+ * @param $startDate
+ * @param $endDate
+ * @param $dateField
+ * @param $isExport
+ * @return array
+ */
private function generateReport($reportType, $startDate, $endDate, $dateField, $isExport)
{
if ($reportType == ENTITY_CLIENT) {
@@ -236,6 +259,13 @@ class ReportController extends BaseController
}
}
+ /**
+ * @param $startDate
+ * @param $endDate
+ * @param $dateField
+ * @param $isExport
+ * @return array
+ */
private function generateTaxRateReport($startDate, $endDate, $dateField, $isExport)
{
$columns = ['tax_name', 'tax_rate', 'amount', 'paid'];
@@ -313,6 +343,12 @@ class ReportController extends BaseController
}
+ /**
+ * @param $startDate
+ * @param $endDate
+ * @param $isExport
+ * @return array
+ */
private function generatePaymentReport($startDate, $endDate, $isExport)
{
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'payment_date', 'paid', 'method'];
@@ -358,6 +394,12 @@ class ReportController extends BaseController
];
}
+ /**
+ * @param $startDate
+ * @param $endDate
+ * @param $isExport
+ * @return array
+ */
private function generateInvoiceReport($startDate, $endDate, $isExport)
{
$columns = ['client', 'invoice_number', 'invoice_date', 'amount', 'payment_date', 'paid', 'method'];
@@ -413,6 +455,12 @@ class ReportController extends BaseController
];
}
+ /**
+ * @param $startDate
+ * @param $endDate
+ * @param $isExport
+ * @return array
+ */
private function generateClientReport($startDate, $endDate, $isExport)
{
$columns = ['client', 'amount', 'paid', 'balance'];
@@ -460,6 +508,12 @@ class ReportController extends BaseController
];
}
+ /**
+ * @param $startDate
+ * @param $endDate
+ * @param $isExport
+ * @return array
+ */
private function generateExpenseReport($startDate, $endDate, $isExport)
{
$columns = ['vendor', 'client', 'date', 'expense_amount', 'invoiced_amount'];
@@ -501,6 +555,13 @@ class ReportController extends BaseController
];
}
+ /**
+ * @param $data
+ * @param $currencyId
+ * @param $field
+ * @param $value
+ * @return mixed
+ */
private function addToTotals($data, $currencyId, $field, $value) {
$currencyId = $currencyId ?: Auth::user()->account->getCurrencyId();
@@ -513,6 +574,12 @@ class ReportController extends BaseController
return $data;
}
+ /**
+ * @param $reportType
+ * @param $data
+ * @param $columns
+ * @param $totals
+ */
private function export($reportType, $data, $columns, $totals)
{
$output = fopen('php://output', 'w') or Utils::fatalError();
diff --git a/app/Http/Controllers/TaskApiController.php b/app/Http/Controllers/TaskApiController.php
index a555d15b51db..02ac417cf089 100644
--- a/app/Http/Controllers/TaskApiController.php
+++ b/app/Http/Controllers/TaskApiController.php
@@ -1,12 +1,10 @@
ENTITY_TASK,
'title' => trans('texts.tasks'),
'sortCol' => '2',
@@ -57,9 +79,13 @@ class TaskController extends BaseController
'status',
''
]),
- ));
+ ]);
}
+ /**
+ * @param null $clientPublicId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($clientPublicId = null)
{
return $this->taskService->getDatatable($clientPublicId, Input::get('sSearch'));
@@ -68,13 +94,19 @@ class TaskController extends BaseController
/**
* Store a newly created resource in storage.
*
- * @return Response
+ * @param CreateTaskRequest $request
+ *
+ * @return \Illuminate\Http\RedirectResponse
*/
public function store(CreateTaskRequest $request)
{
return $this->save();
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function show($publicId)
{
Session::reflash();
@@ -85,7 +117,9 @@ class TaskController extends BaseController
/**
* Show the form for creating a new resource.
*
- * @return Response
+ * @param TaskRequest $request
+ *
+ * @return \Illuminate\Contracts\View\View
*/
public function create(TaskRequest $request)
{
@@ -109,8 +143,9 @@ class TaskController extends BaseController
/**
* Show the form for editing the specified resource.
*
- * @param int $id
- * @return Response
+ * @param TaskRequest $request
+ *
+ * @return \Illuminate\Contracts\View\View
*/
public function edit(TaskRequest $request)
{
@@ -120,15 +155,15 @@ class TaskController extends BaseController
$actions = [];
if ($task->invoice) {
- $actions[] = ['url' => URL::to("invoices/{$task->invoice->public_id}/edit"), 'label' => trans("texts.view_invoice")];
+ $actions[] = ['url' => URL::to("invoices/{$task->invoice->public_id}/edit"), 'label' => trans('texts.view_invoice')];
} else {
- $actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans("texts.invoice_task")];
+ $actions[] = ['url' => 'javascript:submitAction("invoice")', 'label' => trans('texts.invoice_task')];
// check for any open invoices
$invoices = $task->client_id ? $this->invoiceRepo->findOpenInvoices($task->client_id) : [];
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[] = ['url' => 'javascript:submitAction("add_to_invoice", '.$invoice->public_id.')', 'label' => trans('texts.add_to_invoice', ['invoice' => $invoice->invoice_number])];
}
}
@@ -161,8 +196,9 @@ class TaskController extends BaseController
/**
* Update the specified resource in storage.
*
- * @param int $id
- * @return Response
+ * @param UpdateTaskRequest $request
+ *
+ * @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateTaskRequest $request)
{
@@ -171,6 +207,9 @@ class TaskController extends BaseController
return $this->save($task->public_id);
}
+ /**
+ * @return array
+ */
private static function getViewModel()
{
return [
@@ -179,6 +218,10 @@ class TaskController extends BaseController
];
}
+ /**
+ * @param null $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
private function save($publicId = null)
{
$action = Input::get('action');
@@ -197,6 +240,9 @@ class TaskController extends BaseController
return Redirect::to("tasks/{$task->public_id}/edit");
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function bulk()
{
$action = Input::get('action');
@@ -256,7 +302,7 @@ class TaskController extends BaseController
}
}
}
-
+
private function checkTimezone()
{
if (!Auth::user()->account->timezone) {
diff --git a/app/Http/Controllers/TaxRateApiController.php b/app/Http/Controllers/TaxRateApiController.php
index 85756205d9a1..e5b0003d6e30 100644
--- a/app/Http/Controllers/TaxRateApiController.php
+++ b/app/Http/Controllers/TaxRateApiController.php
@@ -7,10 +7,20 @@ use App\Http\Requests\UpdateTaxRateRequest;
class TaxRateApiController extends BaseAPIController
{
+ /**
+ * @var TaxRateRepository
+ */
protected $taxRateRepo;
-
+
+ /**
+ * @var string
+ */
protected $entityType = ENTITY_TAX_RATE;
+ /**
+ * TaxRateApiController constructor.
+ * @param TaxRateRepository $taxRateRepo
+ */
public function __construct(TaxRateRepository $taxRateRepo)
{
parent::__construct();
@@ -34,6 +44,11 @@ class TaxRateApiController extends BaseAPIController
return $this->itemResponse($taxRate);
}
+ /**
+ * @param UpdateTaxRateRequest $request
+ * @param $publicId
+ * @return \Illuminate\Http\Response
+ */
public function update(UpdateTaxRateRequest $request, $publicId)
{
if ($request->action) {
@@ -46,9 +61,4 @@ class TaxRateApiController extends BaseAPIController
return $this->itemResponse($taxRate);
}
-
- public function destroy($publicId)
- {
- //stub
- }
}
diff --git a/app/Http/Controllers/TaxRateController.php b/app/Http/Controllers/TaxRateController.php
index cba4058756de..61129e2a834c 100644
--- a/app/Http/Controllers/TaxRateController.php
+++ b/app/Http/Controllers/TaxRateController.php
@@ -1,20 +1,14 @@
tokenService = $tokenService;
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function index()
{
return Redirect::to('settings/' . ACCOUNT_API_TOKENS);
}
+ /**
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable()
{
return $this->tokenService->getDatatable(Auth::user()->id);
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Contracts\View\View
+ */
public function edit($publicId)
{
$token = AccountToken::where('account_id', '=', Auth::user()->account_id)
@@ -50,19 +66,26 @@ class TokenController extends BaseController
return View::make('accounts.token', $data);
}
+ /**
+ * @param $publicId
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function update($publicId)
{
return $this->save($publicId);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function store()
{
return $this->save();
}
+
/**
- * Displays the form for account creation
- *
+ * @return \Illuminate\Contracts\View\View
*/
public function create()
{
@@ -76,6 +99,9 @@ class TokenController extends BaseController
return View::make('accounts.token', $data);
}
+ /**
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function bulk()
{
$action = Input::get('bulk_action');
@@ -87,9 +113,10 @@ class TokenController extends BaseController
return Redirect::to('settings/' . ACCOUNT_API_TOKENS);
}
+
/**
- * Stores new account
- *
+ * @param bool $tokenPublicId
+ * @return $this|\Illuminate\Http\RedirectResponse
*/
public function save($tokenPublicId = false)
{
diff --git a/app/Http/Controllers/UserApiController.php b/app/Http/Controllers/UserApiController.php
index 2869c3512f5a..be37ecc66c3f 100644
--- a/app/Http/Controllers/UserApiController.php
+++ b/app/Http/Controllers/UserApiController.php
@@ -5,7 +5,6 @@ use App\Ninja\Repositories\UserRepository;
use App\Ninja\Transformers\UserTransformer;
use Auth;
use App\Models\User;
-
use App\Http\Requests\CreateUserRequest;
use App\Http\Requests\UpdateUserRequest;
diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php
index c77cbe6b9b1a..ed5ff73084fa 100644
--- a/app/Http/Controllers/UserController.php
+++ b/app/Http/Controllers/UserController.php
@@ -1,10 +1,6 @@
'vendor',
'title' => trans('texts.vendors'),
'sortCol' => '4',
@@ -61,7 +50,7 @@ class VendorController extends BaseController
'date_created',
''
]),
- ));
+ ]);
}
public function getDatatable()
@@ -99,7 +88,7 @@ class VendorController extends BaseController
['label' => trans('texts.new_vendor'), 'url' => URL::to('/vendors/create/' . $vendor->public_id)]
];
- $data = array(
+ $data = [
'actionLinks' => $actionLinks,
'showBreadcrumbs' => false,
'vendor' => $vendor,
@@ -108,7 +97,7 @@ class VendorController extends BaseController
'hasRecurringInvoices' => false,
'hasQuotes' => false,
'hasTasks' => false,
- );
+ ];
return View::make('vendors.show', $data);
}
@@ -121,7 +110,7 @@ class VendorController extends BaseController
public function create(VendorRequest $request)
{
if (Vendor::scope()->count() > Auth::user()->getMaxNumVendors()) {
- return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumVendors()." vendors"]);
+ return View::make('error', ['hideHeader' => true, 'error' => "Sorry, you've exceeded the limit of ".Auth::user()->getMaxNumVendors().' vendors']);
}
$data = [
diff --git a/app/Http/Middleware/ApiCheck.php b/app/Http/Middleware/ApiCheck.php
index 524b718cc44f..19181b8da514 100644
--- a/app/Http/Middleware/ApiCheck.php
+++ b/app/Http/Middleware/ApiCheck.php
@@ -7,9 +7,11 @@ use Session;
use Response;
use Auth;
use Cache;
-
use App\Models\AccountToken;
+/**
+ * Class ApiCheck
+ */
class ApiCheck {
/**
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index e5135eeaa7fd..de82df62aea2 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -5,104 +5,116 @@ use Auth;
use Session;
use App\Models\Invitation;
use App\Models\Contact;
-use App\Models\Account;
-class Authenticate {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next, $guard = 'user')
- {
- $authenticated = Auth::guard($guard)->check();
+/**
+ * Class Authenticate
+ */
+class Authenticate
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @param string $guard
+ * @return mixed
+ */
+ public function handle($request, Closure $next, $guard = 'user')
+ {
+ $authenticated = Auth::guard($guard)->check();
- if($guard=='client'){
- if(!empty($request->invitation_key)){
- $contact_key = session('contact_key');
- if($contact_key) {
- $contact = $this->getContact($contact_key);
- $invitation = $this->getInvitation($request->invitation_key);
+ if ($guard == 'client') {
+ if (!empty($request->invitation_key)) {
+ $contact_key = session('contact_key');
+ if ($contact_key) {
+ $contact = $this->getContact($contact_key);
+ $invitation = $this->getInvitation($request->invitation_key);
- if (!$invitation) {
- return response()->view('error', [
- 'error' => trans('texts.invoice_not_found'),
- 'hideHeader' => true,
- ]);
- }
+ if (!$invitation) {
+ return response()->view('error', [
+ 'error' => trans('texts.invoice_not_found'),
+ 'hideHeader' => true,
+ ]);
+ }
- if ($contact && $contact->id != $invitation->contact_id) {
- // This is a different client; reauthenticate
- $authenticated = false;
- Auth::guard($guard)->logout();
- }
- Session::put('contact_key', $invitation->contact->contact_key);
- }
- }
+ if ($contact && $contact->id != $invitation->contact_id) {
+ // This is a different client; reauthenticate
+ $authenticated = false;
+ Auth::guard($guard)->logout();
+ }
+ Session::put('contact_key', $invitation->contact->contact_key);
+ }
+ }
- if (!empty($request->contact_key)) {
- $contact_key = $request->contact_key;
- Session::put('contact_key', $contact_key);
- } else {
- $contact_key = session('contact_key');
- }
+ if (!empty($request->contact_key)) {
+ $contact_key = $request->contact_key;
+ Session::put('contact_key', $contact_key);
+ } else {
+ $contact_key = session('contact_key');
+ }
- if ($contact_key) {
- $contact = $this->getContact($contact_key);
- } elseif (!empty($request->invitation_key)) {
- $invitation = $this->getInvitation($request->invitation_key);
- $contact = $invitation->contact;
- Session::put('contact_key', $contact->contact_key);
- } else {
- return \Redirect::to('client/sessionexpired');
- }
- $account = $contact->account;
+ if ($contact_key) {
+ $contact = $this->getContact($contact_key);
+ } elseif (!empty($request->invitation_key)) {
+ $invitation = $this->getInvitation($request->invitation_key);
+ $contact = $invitation->contact;
+ Session::put('contact_key', $contact->contact_key);
+ } else {
+ return \Redirect::to('client/sessionexpired');
+ }
+ $account = $contact->account;
- if(Auth::guard('user')->check() && Auth::user('user')->account_id === $account->id){
- // This is an admin; let them pretend to be a client
- $authenticated = true;
- }
+ if (Auth::guard('user')->check() && Auth::user('user')->account_id === $account->id) {
+ // This is an admin; let them pretend to be a client
+ $authenticated = true;
+ }
- // Does this account require portal passwords?
- if($account && (!$account->enable_portal_password || !$account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD))){
- $authenticated = true;
- }
+ // Does this account require portal passwords?
+ if ($account && (!$account->enable_portal_password || !$account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD))) {
+ $authenticated = true;
+ }
- if(!$authenticated && $contact && !$contact->password){
- $authenticated = true;
- }
- }
+ if (!$authenticated && $contact && !$contact->password) {
+ $authenticated = true;
+ }
+ }
- if (!$authenticated)
- {
- if ($request->ajax())
- {
- return response('Unauthorized.', 401);
- }
- else
- {
- return redirect()->guest($guard=='client'?'/client/login':'/login');
- }
- }
+ if (!$authenticated) {
+ if ($request->ajax()) {
+ return response('Unauthorized.', 401);
+ } else {
+ return redirect()->guest($guard == 'client' ? '/client/login' : '/login');
+ }
+ }
- return $next($request);
- }
+ return $next($request);
+ }
- protected function getInvitation($key){
- $invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first();
- if ($invitation && !$invitation->is_deleted) {
- return $invitation;
- }
- else return null;
- }
+ /**
+ * @param $key
+ * @return \Illuminate\Database\Eloquent\Model|null|static
+ */
+ protected function getInvitation($key)
+ {
+ $invitation = Invitation::withTrashed()->where('invitation_key', '=', $key)->first();
+ if ($invitation && !$invitation->is_deleted) {
+ return $invitation;
+ } else {
+ return null;
+ }
+ }
- protected function getContact($key){
- $contact = Contact::withTrashed()->where('contact_key', '=', $key)->first();
- if ($contact && !$contact->is_deleted) {
- return $contact;
- }
- else return null;
- }
+ /**
+ * @param $key
+ * @return \Illuminate\Database\Eloquent\Model|null|static
+ */
+ protected function getContact($key)
+ {
+ $contact = Contact::withTrashed()->where('contact_key', '=', $key)->first();
+ if ($contact && !$contact->is_deleted) {
+ return $contact;
+ } else {
+ return null;
+ }
+ }
}
diff --git a/app/Http/Middleware/DuplicateSubmissionCheck.php b/app/Http/Middleware/DuplicateSubmissionCheck.php
index 6f3374a47ebf..cffa06ecf9f4 100644
--- a/app/Http/Middleware/DuplicateSubmissionCheck.php
+++ b/app/Http/Middleware/DuplicateSubmissionCheck.php
@@ -1,19 +1,27 @@
is('api/v1/*')) {
return $next($request);
}
$path = $request->path();
-
+
if (strpos($path, 'charts_and_reports') !== false) {
return $next($request);
}
@@ -21,7 +29,7 @@ class DuplicateSubmissionCheck
if (in_array($request->method(), ['POST', 'PUT', 'DELETE'])) {
$lastPage = session(SESSION_LAST_REQUEST_PAGE);
$lastTime = session(SESSION_LAST_REQUEST_TIME);
-
+
if ($lastPage == $path && (microtime(true) - $lastTime <= 1)) {
return redirect('/')->with('warning', trans('texts.duplicate_post'));
}
diff --git a/app/Http/Middleware/PermissionsRequired.php b/app/Http/Middleware/PermissionsRequired.php
index af0e0015a37f..636bc82c8b2b 100644
--- a/app/Http/Middleware/PermissionsRequired.php
+++ b/app/Http/Middleware/PermissionsRequired.php
@@ -1,56 +1,64 @@
[action => permission]
+/**
+ * Class PermissionsRequired
+ */
+class PermissionsRequired
+{
+
+ /**
+ * @var array
*/
static protected $actions = [];
-
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next, $guard = 'user')
- {
- // Get the current route.
- $route = $request->route();
- // Get the current route actions.
- $actions = $route->getAction();
+ /**
+ * Handle an incoming request.
+ *
+ * @param Request $request
+ * @param Closure $next
+ * @param string $guard
+ *
+ * @return mixed
+ */
+ public function handle(Request $request, Closure $next, $guard = 'user')
+ {
+ // Get the current route.
+ $route = $request->route();
- // Check if we have any permissions to check the user has.
- if ($permissions = !empty($actions['permissions']) ? $actions['permissions'] : null)
- {
- if(!Auth::user($guard)->hasPermission($permissions, !empty($actions['permissions_require_all']))){
- return response('Unauthorized.', 401);
- }
- }
-
- // Check controller permissions
- $action = explode('@', $request->route()->getActionName());
- if(isset(static::$actions[$action[0]]) && isset(static::$actions[$action[0]][$action[1]])) {
- $controller_permissions = static::$actions[$action[0]][$action[1]];
- if(!Auth::user($guard)->hasPermission($controller_permissions)){
- return response('Unauthorized.', 401);
- }
+ // Get the current route actions.
+ $actions = $route->getAction();
+
+ // Check if we have any permissions to check the user has.
+ if ($permissions = !empty($actions['permissions']) ? $actions['permissions'] : null) {
+ if (!Auth::user($guard)->hasPermission($permissions, !empty($actions['permissions_require_all']))) {
+ return response('Unauthorized.', 401);
+ }
}
- return $next($request);
- }
+ // Check controller permissions
+ $action = explode('@', $request->route()->getActionName());
+ if (isset(static::$actions[$action[0]]) && isset(static::$actions[$action[0]][$action[1]])) {
+ $controller_permissions = static::$actions[$action[0]][$action[1]];
+ if (!Auth::user($guard)->hasPermission($controller_permissions)) {
+ return response('Unauthorized.', 401);
+ }
+ }
+
+ return $next($request);
+ }
/**
* add a controller's action permission
*
- * @param \App\Http\Controllers\Controller $controller
+ * @param Controller $controller
* @param array $permissions
*/
- public static function addPermission(\App\Http\Controllers\Controller $controller, $permissions)
+ public static function addPermission(Controller $controller, array $permissions)
{
static::$actions[get_class($controller)] = $permissions;
}
diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php
index da01a52b05fd..42bf47288975 100644
--- a/app/Http/Middleware/QueryLogging.php
+++ b/app/Http/Middleware/QueryLogging.php
@@ -1,20 +1,24 @@
method() . ' - ' . $request->url() . ": $count queries");
- //Log::info(json_encode($queries));
}
}
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index 41394b4cbd3f..1e0cb5a1331b 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -1,48 +1,51 @@
auth = $auth;
- }
+ /**
+ * Create a new filter instance.
+ *
+ * @param Guard $auth
+ */
+ public function __construct(Guard $auth)
+ {
+ $this->auth = $auth;
+ }
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if ($this->auth->check() && Client::scope()->count() > 0)
- {
+ /**
+ * Handle an incoming request.
+ *
+ * @param Request $request
+ * @param Closure $next
+ * @return mixed
+ */
+ public function handle(Request $request, Closure $next)
+ {
+ if ($this->auth->check() && Client::scope()->count() > 0) {
Session::reflash();
- return new RedirectResponse(url('/dashboard'));
- }
+ return new RedirectResponse(url('/dashboard'));
+ }
- return $next($request);
- }
+ return $next($request);
+ }
}
diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php
index 29cf7008af13..c8b89b002683 100644
--- a/app/Http/Middleware/StartupCheck.php
+++ b/app/Http/Middleware/StartupCheck.php
@@ -1,7 +1,7 @@
openRoutes as $route) {
+ /**
+ * Handle an incoming request.
+ *
+ * @param Request $request
+ * @param Closure $next
+ * @return mixed
+ */
+ public function handle(Request $request, Closure $next)
+ {
+ foreach ($this->openRoutes as $route) {
- if ($request->is($route)) {
- return $next($request);
- }
+ if ($request->is($route)) {
+ return $next($request);
+ }
}
- return parent::handle($request, $next);
- }
-
+ return parent::handle($request, $next);
+ }
}
diff --git a/app/Http/Requests/CreateBankAccountRequest.php b/app/Http/Requests/CreateBankAccountRequest.php
index eac988349c8d..a39e91cb34b4 100644
--- a/app/Http/Requests/CreateBankAccountRequest.php
+++ b/app/Http/Requests/CreateBankAccountRequest.php
@@ -1,7 +1,6 @@
$invoice->client->id,
]);
- $rules = array(
+ $rules = [
'amount' => "required|less_than:{$invoice->balance}|positive",
- );
+ ];
if ($this->payment_type_id == PAYMENT_TYPE_CREDIT) {
$rules['payment_type_id'] = 'has_credit:' . $invoice->client->public_id . ',' . $this->amount;
diff --git a/app/Http/Requests/CreatePaymentRequest.php b/app/Http/Requests/CreatePaymentRequest.php
index dbc830271197..ae1ed9f74eff 100644
--- a/app/Http/Requests/CreatePaymentRequest.php
+++ b/app/Http/Requests/CreatePaymentRequest.php
@@ -24,11 +24,11 @@ class CreatePaymentRequest extends PaymentRequest
$input = $this->input();
$invoice = Invoice::scope($input['invoice'])->firstOrFail();
- $rules = array(
+ $rules = [
'client' => 'required', // TODO: change to client_id once views are updated
'invoice' => 'required', // TODO: change to invoice_id once views are updated
'amount' => "required|less_than:{$invoice->balance}|positive",
- );
+ ];
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 d8fef50093b7..6a83dc0cbcb0 100644
--- a/app/Http/Requests/CreateTaxRateRequest.php
+++ b/app/Http/Requests/CreateTaxRateRequest.php
@@ -1,7 +1,6 @@
autoload as $entityType) {
if ($id = $this->input("{$entityType}_public_id") ?: $this->input("{$entityType}_id")) {
- $class = "App\\Models\\" . ucwords($entityType);
+ $class = 'App\\Models\\' . ucwords($entityType);
$entity = $class::scope($id)->firstOrFail();
$input[$entityType] = $entity;
$input[$entityType . '_id'] = $entity->id;
diff --git a/app/Http/Requests/UpdateAccountRequest.php b/app/Http/Requests/UpdateAccountRequest.php
index 0d24f73057bb..0d67304b910f 100644
--- a/app/Http/Requests/UpdateAccountRequest.php
+++ b/app/Http/Requests/UpdateAccountRequest.php
@@ -1,7 +1,6 @@
'auth:client'], function() {
Route::get('client/documents/{invitation_key}/{documents}/{filename?}', 'ClientPortalController@getDocument');
Route::get('client/documents/{invitation_key}/{filename?}', 'ClientPortalController@getInvoiceDocumentsZip');
- Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'ClientPortalController@quoteDatatable'));
- Route::get('api/client.invoices', array('as'=>'api.client.invoices', 'uses'=>'ClientPortalController@invoiceDatatable'));
- Route::get('api/client.recurring_invoices', array('as'=>'api.client.recurring_invoices', 'uses'=>'ClientPortalController@recurringInvoiceDatatable'));
- Route::get('api/client.documents', array('as'=>'api.client.documents', 'uses'=>'ClientPortalController@documentDatatable'));
- Route::get('api/client.payments', array('as'=>'api.client.payments', 'uses'=>'ClientPortalController@paymentDatatable'));
- Route::get('api/client.activity', array('as'=>'api.client.activity', 'uses'=>'ClientPortalController@activityDatatable'));
+ Route::get('api/client.quotes', ['as'=>'api.client.quotes', 'uses'=>'ClientPortalController@quoteDatatable']);
+ Route::get('api/client.invoices', ['as'=>'api.client.invoices', 'uses'=>'ClientPortalController@invoiceDatatable']);
+ Route::get('api/client.recurring_invoices', ['as'=>'api.client.recurring_invoices', 'uses'=>'ClientPortalController@recurringInvoiceDatatable']);
+ Route::get('api/client.documents', ['as'=>'api.client.documents', 'uses'=>'ClientPortalController@documentDatatable']);
+ Route::get('api/client.payments', ['as'=>'api.client.payments', 'uses'=>'ClientPortalController@paymentDatatable']);
+ Route::get('api/client.activity', ['as'=>'api.client.activity', 'uses'=>'ClientPortalController@activityDatatable']);
});
@@ -87,26 +87,26 @@ Route::post('/hook/email_opened', 'AppController@emailOpened');
Route::post('/payment_hook/{accountKey}/{gatewayId}', 'OnlinePaymentController@handlePaymentWebhook');
// Laravel auth routes
-Route::get('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@getRegister'));
-Route::post('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@postRegister'));
-Route::get('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@getLoginWrapper'));
-Route::post('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@postLoginWrapper'));
-Route::get('/logout', array('as' => 'logout', 'uses' => 'Auth\AuthController@getLogoutWrapper'));
-Route::get('/recover_password', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail'));
-Route::post('/recover_password', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail'));
-Route::get('/password/reset/{token}', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset'));
-Route::post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset'));
+Route::get('/signup', ['as' => 'signup', 'uses' => 'Auth\AuthController@getRegister']);
+Route::post('/signup', ['as' => 'signup', 'uses' => 'Auth\AuthController@postRegister']);
+Route::get('/login', ['as' => 'login', 'uses' => 'Auth\AuthController@getLoginWrapper']);
+Route::post('/login', ['as' => 'login', 'uses' => 'Auth\AuthController@postLoginWrapper']);
+Route::get('/logout', ['as' => 'logout', 'uses' => 'Auth\AuthController@getLogoutWrapper']);
+Route::get('/recover_password', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail']);
+Route::post('/recover_password', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail']);
+Route::get('/password/reset/{token}', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset']);
+Route::post('/password/reset', ['as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset']);
Route::get('/user/confirm/{code}', 'UserController@confirm');
// Client auth
-Route::get('/client/login', array('as' => 'login', 'uses' => 'ClientAuth\AuthController@getLogin'));
-Route::post('/client/login', array('as' => 'login', 'uses' => 'ClientAuth\AuthController@postLogin'));
-Route::get('/client/logout', array('as' => 'logout', 'uses' => 'ClientAuth\AuthController@getLogout'));
-Route::get('/client/sessionexpired', array('as' => 'logout', 'uses' => 'ClientAuth\AuthController@getSessionExpired'));
-Route::get('/client/recover_password', array('as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getEmail'));
-Route::post('/client/recover_password', array('as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postEmail'));
-Route::get('/client/password/reset/{invitation_key}/{token}', array('as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getReset'));
-Route::post('/client/password/reset', array('as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postReset'));
+Route::get('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\AuthController@getLogin']);
+Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\AuthController@postLogin']);
+Route::get('/client/logout', ['as' => 'logout', 'uses' => 'ClientAuth\AuthController@getLogout']);
+Route::get('/client/sessionexpired', ['as' => 'logout', 'uses' => 'ClientAuth\AuthController@getSessionExpired']);
+Route::get('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getEmail']);
+Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postEmail']);
+Route::get('/client/password/reset/{invitation_key}/{token}', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@getReset']);
+Route::post('/client/password/reset', ['as' => 'forgot', 'uses' => 'ClientAuth\PasswordController@postReset']);
if (Utils::isNinja()) {
@@ -124,29 +124,29 @@ Route::group(['middleware' => 'auth:user'], function() {
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
Route::get('hide_message', 'HomeController@hideMessage');
Route::get('force_inline_pdf', 'UserController@forcePDFJS');
- Route::get('account/getSearchData', array('as' => 'getSearchData', 'uses' => 'AccountController@getSearchData'));
+ Route::get('account/getSearchData', ['as' => 'getSearchData', 'uses' => 'AccountController@getSearchData']);
Route::get('settings/user_details', 'AccountController@showUserDetails');
Route::post('settings/user_details', 'AccountController@saveUserDetails');
Route::post('users/change_password', 'UserController@changePassword');
Route::resource('clients', 'ClientController');
- Route::get('api/clients', array('as'=>'api.clients', 'uses'=>'ClientController@getDatatable'));
- Route::get('api/activities/{client_id?}', array('as'=>'api.activities', 'uses'=>'ActivityController@getDatatable'));
+ Route::get('api/clients', ['as'=>'api.clients', 'uses'=>'ClientController@getDatatable']);
+ Route::get('api/activities/{client_id?}', ['as'=>'api.activities', 'uses'=>'ActivityController@getDatatable']);
Route::post('clients/bulk', 'ClientController@bulk');
Route::resource('tasks', 'TaskController');
- Route::get('api/tasks/{client_id?}', array('as'=>'api.tasks', 'uses'=>'TaskController@getDatatable'));
+ Route::get('api/tasks/{client_id?}', ['as'=>'api.tasks', 'uses'=>'TaskController@getDatatable']);
Route::get('tasks/create/{client_id?}', 'TaskController@create');
Route::post('tasks/bulk', 'TaskController@bulk');
- Route::get('api/recurring_invoices/{client_id?}', array('as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable'));
+ Route::get('api/recurring_invoices/{client_id?}', ['as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable']);
Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory');
Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory');
Route::resource('invoices', 'InvoiceController');
- Route::get('api/invoices/{client_id?}', array('as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable'));
+ Route::get('api/invoices/{client_id?}', ['as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable']);
Route::get('invoices/create/{client_id?}', 'InvoiceController@create');
Route::get('recurring_invoices/create/{client_id?}', 'InvoiceController@createRecurring');
Route::get('recurring_invoices', 'RecurringInvoiceController@index');
@@ -167,17 +167,17 @@ Route::group(['middleware' => 'auth:user'], function() {
Route::get('quotes/{invoices}', 'InvoiceController@edit');
Route::post('quotes', 'InvoiceController@store');
Route::get('quotes', 'QuoteController@index');
- Route::get('api/quotes/{client_id?}', array('as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable'));
+ Route::get('api/quotes/{client_id?}', ['as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable']);
Route::post('quotes/bulk', 'QuoteController@bulk');
Route::resource('payments', 'PaymentController');
Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create');
- Route::get('api/payments/{client_id?}', array('as'=>'api.payments', 'uses'=>'PaymentController@getDatatable'));
+ Route::get('api/payments/{client_id?}', ['as'=>'api.payments', 'uses'=>'PaymentController@getDatatable']);
Route::post('payments/bulk', 'PaymentController@bulk');
Route::resource('credits', 'CreditController');
Route::get('credits/create/{client_id?}/{invoice_id?}', 'CreditController@create');
- Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
+ Route::get('api/credits/{client_id?}', ['as'=>'api.credits', 'uses'=>'CreditController@getDatatable']);
Route::post('credits/bulk', 'CreditController@bulk');
Route::get('/resend_confirmation', 'AccountController@resendConfirmation');
@@ -186,14 +186,14 @@ Route::group(['middleware' => 'auth:user'], function() {
// vendor
Route::resource('vendors', 'VendorController');
- Route::get('api/vendor', array('as'=>'api.vendors', 'uses'=>'VendorController@getDatatable'));
+ Route::get('api/vendor', ['as'=>'api.vendors', 'uses'=>'VendorController@getDatatable']);
Route::post('vendors/bulk', 'VendorController@bulk');
// Expense
Route::resource('expenses', 'ExpenseController');
Route::get('expenses/create/{vendor_id?}/{client_id?}', 'ExpenseController@create');
- Route::get('api/expense', array('as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable'));
- Route::get('api/vendor_expense/{id}', array('as'=>'api.expense', 'uses'=>'ExpenseController@getDatatableVendor'));
+ Route::get('api/expense', ['as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable']);
+ Route::get('api/vendor_expense/{id}', ['as'=>'api.expense', 'uses'=>'ExpenseController@getDatatableVendor']);
Route::post('expenses/bulk', 'ExpenseController@bulk');
});
@@ -201,7 +201,7 @@ Route::group([
'middleware' => ['auth:user', 'permissions.required'],
'permissions' => 'admin',
], function() {
- Route::get('api/users', array('as'=>'api.users', 'uses'=>'UserController@getDatatable'));
+ Route::get('api/users', ['as'=>'api.users', 'uses'=>'UserController@getDatatable']);
Route::resource('users', 'UserController');
Route::post('users/bulk', 'UserController@bulk');
Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation');
@@ -212,15 +212,15 @@ Route::group([
Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount');
Route::get('/manage_companies', 'UserController@manageCompanies');
- Route::get('api/tokens', array('as'=>'api.tokens', 'uses'=>'TokenController@getDatatable'));
+ Route::get('api/tokens', ['as'=>'api.tokens', 'uses'=>'TokenController@getDatatable']);
Route::resource('tokens', 'TokenController');
Route::post('tokens/bulk', 'TokenController@bulk');
- Route::get('api/products', array('as'=>'api.products', 'uses'=>'ProductController@getDatatable'));
+ Route::get('api/products', ['as'=>'api.products', 'uses'=>'ProductController@getDatatable']);
Route::resource('products', 'ProductController');
Route::post('products/bulk', 'ProductController@bulk');
- Route::get('api/tax_rates', array('as'=>'api.tax_rates', 'uses'=>'TaxRateController@getDatatable'));
+ Route::get('api/tax_rates', ['as'=>'api.tax_rates', 'uses'=>'TaxRateController@getDatatable']);
Route::resource('tax_rates', 'TaxRateController');
Route::post('tax_rates/bulk', 'TaxRateController@bulk');
@@ -247,13 +247,13 @@ Route::group([
Route::get('gateways/create/{show_wepay?}', 'AccountGatewayController@create');
Route::resource('gateways', 'AccountGatewayController');
Route::get('gateways/{public_id}/resend_confirmation', 'AccountGatewayController@resendConfirmation');
- Route::get('api/gateways', array('as'=>'api.gateways', 'uses'=>'AccountGatewayController@getDatatable'));
+ Route::get('api/gateways', ['as'=>'api.gateways', 'uses'=>'AccountGatewayController@getDatatable']);
Route::post('account_gateways/bulk', 'AccountGatewayController@bulk');
Route::get('bank_accounts/import_ofx', 'BankAccountController@showImportOFX');
Route::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX');
Route::resource('bank_accounts', 'BankAccountController');
- Route::get('api/bank_accounts', array('as'=>'api.bank_accounts', 'uses'=>'BankAccountController@getDatatable'));
+ Route::get('api/bank_accounts', ['as'=>'api.bank_accounts', 'uses'=>'BankAccountController@getDatatable']);
Route::post('bank_accounts/bulk', 'BankAccountController@bulk');
Route::post('bank_accounts/validate', 'BankAccountController@validateAccount');
Route::post('bank_accounts/import_expenses/{bank_id}', 'BankAccountController@importExpenses');
diff --git a/app/Includes/parsecsv.lib.php b/app/Includes/parsecsv.lib.php
index c5941b9dbcbd..7fe04984db97 100644
--- a/app/Includes/parsecsv.lib.php
+++ b/app/Includes/parsecsv.lib.php
@@ -88,7 +88,7 @@ class parseCSV {
var $heading = true;
# override field names
- var $fields = array();
+ var $fields = [];
# sort entries by this field
var $sort_by = null;
@@ -141,10 +141,10 @@ class parseCSV {
var $file_data;
# array of field values in data parsed
- var $titles = array();
+ var $titles = [];
# two dimentional array of CSV data
- var $data = array();
+ var $data = [];
/**
@@ -193,7 +193,7 @@ class parseCSV {
* @param fields field names
* @return true or false
*/
- function save ($file = null, $data = array(), $append = false, $fields = array()) {
+ 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 ;
@@ -209,7 +209,7 @@ class parseCSV {
* @param delimiter delimiter used to separate data
* @return CSV data using delimiter of choice, or default
*/
- function output ($output = true, $filename = null, $data = array(), $fields = array(), $delimiter = null) {
+ 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);
@@ -259,7 +259,7 @@ class parseCSV {
$data = &$this->file_data;
}
- $chars = array();
+ $chars = [];
$strlen = strlen($data);
$enclosed = false;
$n = 1;
@@ -302,7 +302,7 @@ class parseCSV {
// filtering
$depth = ( $to_end ) ? $n-1 : $n ;
- $filtered = array();
+ $filtered = [];
foreach( $chars as $char => $value ) {
if ( $match = $this->_check_count($char, $value, $depth, $preferred) ) {
$filtered[$match] = $char;
@@ -349,11 +349,11 @@ class parseCSV {
} else return false;
}
- $rows = array();
- $row = array();
+ $rows = [];
+ $row = [];
$row_count = 0;
$current = '';
- $head = ( !empty($this->fields) ) ? $this->fields : array() ;
+ $head = ( !empty($this->fields) ) ? $this->fields : [] ;
$col = 0;
$enclosed = false;
$was_enclosed = false;
@@ -399,7 +399,7 @@ class parseCSV {
} else $rows[] = $row;
}
}
- $row = array();
+ $row = [];
$col = 0;
$row_count++;
if ( $this->sort_by === null && $this->limit !== null && count($rows) == $this->limit ) {
@@ -432,13 +432,13 @@ class parseCSV {
* @param delimiter field delimiter to use
* @return CSV data (text string)
*/
- function unparse ( $data = array(), $fields = array(), $append = false , $is_php = false, $delimiter = null) {
+ 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 = array();
+ $entry = [];
// create heading
if ( $this->heading && !$append ) {
@@ -446,7 +446,7 @@ class parseCSV {
$entry[] = $this->_enclose_value($value);
}
$string .= implode($delimiter, $entry).$this->linefeed;
- $entry = array();
+ $entry = [];
}
// create data
@@ -455,7 +455,7 @@ class parseCSV {
$entry[] = $this->_enclose_value($value);
}
$string .= implode($delimiter, $entry).$this->linefeed;
- $entry = array();
+ $entry = [];
}
return $string;
@@ -500,10 +500,10 @@ class parseCSV {
* @param conditions specified conditions that the row must match
* @return true of false
*/
- function _validate_row_conditions ($row = array(), $conditions = null) {
+ function _validate_row_conditions ($row = [], $conditions = null) {
if ( !empty($row) ) {
if ( !empty($conditions) ) {
- $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : array($conditions) ;
+ $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : [$conditions] ;
$or = '';
foreach( $conditions as $key => $value ) {
if ( strpos($value, ' AND ') !== false ) {
@@ -531,7 +531,7 @@ class parseCSV {
* @return true of false
*/
function _validate_row_condition ($row, $condition) {
- $operators = array(
+ $operators = [
'=', 'equals', 'is',
'!=', 'is not',
'<', 'is less than',
@@ -540,8 +540,8 @@ class parseCSV {
'>=', 'is greater than or equals',
'contains',
'does not contain',
- );
- $operators_regex = array();
+ ];
+ $operators_regex = [];
foreach( $operators as $value ) {
$operators_regex[] = preg_quote($value, '/');
}
@@ -553,9 +553,9 @@ class parseCSV {
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 = str_replace('\\n', "\n", $value);
+ $value = str_replace('\\r', "\r", $value);
+ $value = str_replace('\\t', "\t", $value);
$value = stripslashes($value);
}
}
@@ -604,7 +604,7 @@ class parseCSV {
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) == ' ') ) {
+ 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;
}
diff --git a/app/Libraries/OFX.php b/app/Libraries/OFX.php
index b32e308a4247..83edb3085d5f 100644
--- a/app/Libraries/OFX.php
+++ b/app/Libraries/OFX.php
@@ -24,7 +24,7 @@ class OFX
curl_setopt($c, CURLOPT_URL, $this->bank->url);
curl_setopt($c, CURLOPT_POST, 1);
// User-Agent: http://www.ofxhome.com/ofxforum/viewtopic.php?pid=108091#p108091
- curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type: application/x-ofx', 'User-Agent: httpclient'));
+ curl_setopt($c, CURLOPT_HTTPHEADER, ['Content-Type: application/x-ofx', 'User-Agent: httpclient']);
curl_setopt($c, CURLOPT_POSTFIELDS, $this->request);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
@@ -106,13 +106,13 @@ class Login
"\n".
"\n".
"20110412162900.000[-7:MST]\n".
- "".$this->id."\n".
- "".$this->pass."\n".
+ ''.$this->id."\n".
+ ''.$this->pass."\n".
"N\n".
"ENG\n".
"\n".
- "".$this->bank->org."\n".
- "".$this->bank->fid."\n".
+ ''.$this->bank->org."\n".
+ ''.$this->bank->fid."\n".
"\n".
"QWIN\n".
"2500\n".
@@ -120,7 +120,7 @@ class Login
"\n".
"\n".
"\n".
- "".md5(time().$this->bank->url.$this->id)."\n".
+ ''.md5(time().$this->bank->url.$this->id)."\n".
"\n".
"19900101\n".
"\n".
@@ -174,12 +174,12 @@ class Account
"\n".
"\n".
"20110412162900.000[-7:MST]\n".
- "".$this->login->id."\n".
- "".$this->login->pass."\n".
+ ''.$this->login->id."\n".
+ ''.$this->login->pass."\n".
"ENG\n".
"\n".
- "".$this->login->bank->org."\n".
- "".$this->login->bank->fid."\n".
+ ''.$this->login->bank->org."\n".
+ ''.$this->login->bank->fid."\n".
"\n".
"QWIN\n".
"2500\n".
@@ -189,16 +189,16 @@ class Account
$ofxRequest .=
" \n".
" \n".
- " ".md5(time().$this->login->bank->url.$this->id)."\n".
+ ' '.md5(time().$this->login->bank->url.$this->id)."\n".
" \n".
" \n".
- " ".$this->bankId."\n".
- " ".$this->id."\n".
- " ".$this->subType."\n".
+ ' '.$this->bankId."\n".
+ ' '.$this->id."\n".
+ ' '.$this->subType."\n".
" \n".
" \n".
" 20110301\n".
- " ".($includeTransactions ? 'Y' : 'N')."\n".
+ ' '.($includeTransactions ? 'Y' : 'N')."\n".
" \n".
" \n".
" \n".
@@ -207,21 +207,21 @@ class Account
$ofxRequest .=
" \n".
" \n".
- " ".md5(time().$this->login->bank->url.$this->id)."\n".
+ ' '.md5(time().$this->login->bank->url.$this->id)."\n".
" \n".
" \n".
- " ".$this->id."\n".
+ ' '.$this->id."\n".
" \n".
" \n".
" 20110320\n".
- " ".($includeTransactions ? 'Y' : 'N')."\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 ee50d233222b..572fae313d2c 100644
--- a/app/Libraries/Utils.php
+++ b/app/Libraries/Utils.php
@@ -2,7 +2,6 @@
use Auth;
use Cache;
-use DB;
use App;
use Schema;
use Session;
@@ -17,8 +16,6 @@ use stdClass;
use Carbon;
use WePay;
-use App\Models\Currency;
-
class Utils
{
public static function isRegistered()
@@ -223,7 +220,7 @@ class Utils
$data = [];
foreach ($input as $field) {
- if ($field == "checkbox") {
+ if ($field == 'checkbox') {
$data[] = $field;
} elseif ($field) {
$data[] = trans("texts.$field");
@@ -238,7 +235,7 @@ class Utils
public static function fatalError($message = false, $exception = false)
{
if (!$message) {
- $message = "An error occurred, please try again later.";
+ $message = 'An error occurred, please try again later.';
}
static::logError($message.' '.$exception);
@@ -534,7 +531,7 @@ class Utils
{
// http://stackoverflow.com/a/3172665
$f = ':';
- return sprintf("%02d%s%02d%s%02d", floor($t/3600), $f, ($t/60)%60, $f, $t%60);
+ return sprintf('%02d%s%02d%s%02d', floor($t/3600), $f, ($t/60)%60, $f, $t%60);
}
public static function today($formatResult = true)
@@ -646,8 +643,8 @@ class Utils
private static function getMonth($offset)
{
- $months = [ "january", "february", "march", "april", "may", "june",
- "july", "august", "september", "october", "november", "december", ];
+ $months = ['january', 'february', 'march', 'april', 'may', 'june',
+ 'july', 'august', 'september', 'october', 'november', 'december', ];
$month = intval(date('n')) - 1;
@@ -800,12 +797,12 @@ class Utils
public static function startsWith($haystack, $needle)
{
- return $needle === "" || strpos($haystack, $needle) === 0;
+ return $needle === '' || strpos($haystack, $needle) === 0;
}
public static function endsWith($haystack, $needle)
{
- return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
+ return $needle === '' || substr($haystack, -strlen($needle)) === $needle;
}
public static function getEntityRowClass($model)
@@ -909,7 +906,7 @@ class Utils
$name = trim($name);
$lastName = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name);
$firstName = trim(preg_replace('#'.$lastName.'#', '', $name));
- return array($firstName, $lastName);
+ return [$firstName, $lastName];
}
public static function decodePDF($string)
@@ -952,7 +949,7 @@ class Utils
$link = $prefix.$link;
}
- return link_to($link, $title, array('target' => '_blank'));
+ return link_to($link, $title, ['target' => '_blank']);
}
public static function wrapAdjustment($adjustment, $currencyId, $countryId)
@@ -990,8 +987,8 @@ class Utils
public static function addHttp($url)
{
- if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
- $url = "http://" . $url;
+ if (!preg_match('~^(?:f|ht)tps?://~i', $url)) {
+ $url = 'http://' . $url;
}
return $url;
diff --git a/app/Libraries/lib_autolink.php b/app/Libraries/lib_autolink.php
index 3bc86b843e29..fa98d75015e1 100644
--- a/app/Libraries/lib_autolink.php
+++ b/app/Libraries/lib_autolink.php
@@ -15,13 +15,13 @@
# functions to change the output.
#
- $GLOBALS['autolink_options'] = array(
+ $GLOBALS['autolink_options'] = [
# Should http:// be visibly stripped from the front
# of URLs?
'strip_protocols' => false,
- );
+ ];
####################################################################
@@ -69,7 +69,7 @@
# substring found - first check to see if we're inside a link tag already...
#
- $bits = preg_split("!!i", $pre);
+ $bits = preg_split('!!i', $pre);
$last_bit = array_pop($bits);
if (preg_match("!!i", $pre);
+ $bits = preg_split('!!i', $pre);
$last_bit = array_pop($bits);
if (preg_match("!activityRepo = $activityRepo;
}
- // Clients
+ /**
+ * @param ClientWasCreated $event
+ */
public function createdClient(ClientWasCreated $event)
{
$this->activityRepo->create(
@@ -51,6 +63,9 @@ class ActivityListener
);
}
+ /**
+ * @param ClientWasDeleted $event
+ */
public function deletedClient(ClientWasDeleted $event)
{
$this->activityRepo->create(
@@ -59,6 +74,9 @@ class ActivityListener
);
}
+ /**
+ * @param ClientWasArchived $event
+ */
public function archivedClient(ClientWasArchived $event)
{
if ($event->client->is_deleted) {
@@ -71,6 +89,9 @@ class ActivityListener
);
}
+ /**
+ * @param ClientWasRestored $event
+ */
public function restoredClient(ClientWasRestored $event)
{
$this->activityRepo->create(
@@ -79,7 +100,9 @@ class ActivityListener
);
}
- // Invoices
+ /**
+ * @param InvoiceWasCreated $event
+ */
public function createdInvoice(InvoiceWasCreated $event)
{
$this->activityRepo->create(
@@ -89,6 +112,9 @@ class ActivityListener
);
}
+ /**
+ * @param InvoiceWasUpdated $event
+ */
public function updatedInvoice(InvoiceWasUpdated $event)
{
if (! $event->invoice->isChanged()) {
@@ -107,6 +133,9 @@ class ActivityListener
$activity->save();
}
+ /**
+ * @param InvoiceWasDeleted $event
+ */
public function deletedInvoice(InvoiceWasDeleted $event)
{
$invoice = $event->invoice;
@@ -119,6 +148,9 @@ class ActivityListener
);
}
+ /**
+ * @param InvoiceWasArchived $event
+ */
public function archivedInvoice(InvoiceWasArchived $event)
{
if ($event->invoice->is_deleted) {
@@ -131,6 +163,9 @@ class ActivityListener
);
}
+ /**
+ * @param InvoiceWasRestored $event
+ */
public function restoredInvoice(InvoiceWasRestored $event)
{
$invoice = $event->invoice;
@@ -143,6 +178,9 @@ class ActivityListener
);
}
+ /**
+ * @param InvoiceInvitationWasEmailed $event
+ */
public function emailedInvoice(InvoiceInvitationWasEmailed $event)
{
$this->activityRepo->create(
@@ -154,6 +192,9 @@ class ActivityListener
);
}
+ /**
+ * @param InvoiceInvitationWasViewed $event
+ */
public function viewedInvoice(InvoiceInvitationWasViewed $event)
{
$this->activityRepo->create(
@@ -165,7 +206,9 @@ class ActivityListener
);
}
- // Quotes
+ /**
+ * @param QuoteWasCreated $event
+ */
public function createdQuote(QuoteWasCreated $event)
{
$this->activityRepo->create(
@@ -174,6 +217,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteWasUpdated $event
+ */
public function updatedQuote(QuoteWasUpdated $event)
{
if (! $event->quote->isChanged()) {
@@ -191,6 +237,9 @@ class ActivityListener
$activity->save();
}
+ /**
+ * @param QuoteWasDeleted $event
+ */
public function deletedQuote(QuoteWasDeleted $event)
{
$this->activityRepo->create(
@@ -199,6 +248,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteWasArchived $event
+ */
public function archivedQuote(QuoteWasArchived $event)
{
if ($event->quote->is_deleted) {
@@ -211,6 +263,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteWasRestored $event
+ */
public function restoredQuote(QuoteWasRestored $event)
{
$this->activityRepo->create(
@@ -219,6 +274,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteInvitationWasEmailed $event
+ */
public function emailedQuote(QuoteInvitationWasEmailed $event)
{
$this->activityRepo->create(
@@ -230,6 +288,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteInvitationWasViewed $event
+ */
public function viewedQuote(QuoteInvitationWasViewed $event)
{
$this->activityRepo->create(
@@ -241,6 +302,9 @@ class ActivityListener
);
}
+ /**
+ * @param QuoteInvitationWasApproved $event
+ */
public function approvedQuote(QuoteInvitationWasApproved $event)
{
$this->activityRepo->create(
@@ -252,7 +316,9 @@ class ActivityListener
);
}
- // Credits
+ /**
+ * @param CreditWasCreated $event
+ */
public function createdCredit(CreditWasCreated $event)
{
$this->activityRepo->create(
@@ -261,6 +327,9 @@ class ActivityListener
);
}
+ /**
+ * @param CreditWasDeleted $event
+ */
public function deletedCredit(CreditWasDeleted $event)
{
$this->activityRepo->create(
@@ -269,6 +338,9 @@ class ActivityListener
);
}
+ /**
+ * @param CreditWasArchived $event
+ */
public function archivedCredit(CreditWasArchived $event)
{
if ($event->credit->is_deleted) {
@@ -281,6 +353,9 @@ class ActivityListener
);
}
+ /**
+ * @param CreditWasRestored $event
+ */
public function restoredCredit(CreditWasRestored $event)
{
$this->activityRepo->create(
@@ -289,7 +364,9 @@ class ActivityListener
);
}
- // Payments
+ /**
+ * @param PaymentWasCreated $event
+ */
public function createdPayment(PaymentWasCreated $event)
{
$this->activityRepo->create(
@@ -300,6 +377,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentWasDeleted $event
+ */
public function deletedPayment(PaymentWasDeleted $event)
{
$payment = $event->payment;
@@ -312,6 +392,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentWasRefunded $event
+ */
public function refundedPayment(PaymentWasRefunded $event)
{
$payment = $event->payment;
@@ -324,6 +407,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentWasVoided $event
+ */
public function voidedPayment(PaymentWasVoided $event)
{
$payment = $event->payment;
@@ -336,6 +422,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentFailed $event
+ */
public function failedPayment(PaymentFailed $event)
{
$payment = $event->payment;
@@ -348,6 +437,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentWasArchived $event
+ */
public function archivedPayment(PaymentWasArchived $event)
{
if ($event->payment->is_deleted) {
@@ -360,6 +452,9 @@ class ActivityListener
);
}
+ /**
+ * @param PaymentWasRestored $event
+ */
public function restoredPayment(PaymentWasRestored $event)
{
$payment = $event->payment;
diff --git a/app/Listeners/AnalyticsListener.php b/app/Listeners/AnalyticsListener.php
index dd574368c462..7234e1a52c90 100644
--- a/app/Listeners/AnalyticsListener.php
+++ b/app/Listeners/AnalyticsListener.php
@@ -1,11 +1,16 @@
sendAnalytics($url);
- //Log::info($url);
$url = $base . "&t=item&in=plan&ip={$amount}&iq=1";
$this->sendAnalytics($url);
- //Log::info($url);
}
+ /**
+ * @param $data
+ */
private function sendAnalytics($data)
{
$data = json_encode($data);
@@ -48,7 +54,6 @@ class AnalyticsListener
];
curl_setopt_array($curl, $opts);
- $response = curl_exec($curl);
curl_close($curl);
}
-}
+}
\ No newline at end of file
diff --git a/app/Listeners/CreditListener.php b/app/Listeners/CreditListener.php
index fe8e174ab3ed..c8d16a4776c2 100644
--- a/app/Listeners/CreditListener.php
+++ b/app/Listeners/CreditListener.php
@@ -1,21 +1,33 @@
creditRepo = $creditRepo;
}
+ /**
+ * @param PaymentWasDeleted $event
+ */
public function deletedPayment(PaymentWasDeleted $event)
{
$payment = $event->payment;
@@ -33,6 +45,9 @@ class CreditListener
$credit->save();
}
+ /**
+ * @param PaymentWasRefunded $event
+ */
public function refundedPayment(PaymentWasRefunded $event)
{
$payment = $event->payment;
diff --git a/app/Listeners/ExpenseListener.php b/app/Listeners/ExpenseListener.php
index 6ef1d1175cd6..6f5c3752ef79 100644
--- a/app/Listeners/ExpenseListener.php
+++ b/app/Listeners/ExpenseListener.php
@@ -1,21 +1,32 @@
expenseRepo = $expenseRepo;
}
+ /**
+ * @param InvoiceWasDeleted $event
+ */
public function deletedInvoice(InvoiceWasDeleted $event)
{
// Release any tasks associated with the deleted invoice
diff --git a/app/Listeners/HandleUserLoggedIn.php b/app/Listeners/HandleUserLoggedIn.php
index bf39d7e34e11..75801ce33f1f 100644
--- a/app/Listeners/HandleUserLoggedIn.php
+++ b/app/Listeners/HandleUserLoggedIn.php
@@ -1,24 +1,27 @@
accountRepo = $accountRepo;
@@ -28,6 +31,7 @@ class HandleUserLoggedIn {
* Handle the event.
*
* @param UserLoggedIn $event
+ *
* @return void
*/
public function handle(UserLoggedIn $event)
@@ -54,5 +58,4 @@ class HandleUserLoggedIn {
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 42598334990f..8afd72f9a392 100644
--- a/app/Listeners/HandleUserSettingsChanged.php
+++ b/app/Listeners/HandleUserSettingsChanged.php
@@ -4,16 +4,18 @@ use Auth;
use Session;
use App\Events\UserSettingsChanged;
use App\Ninja\Repositories\AccountRepository;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Contracts\Queue\ShouldBeQueued;
use App\Ninja\Mailers\UserMailer;
+/**
+ * Class HandleUserSettingsChanged
+ */
class HandleUserSettingsChanged {
/**
* Create the event handler.
- *
- * @return void
+ *
+ * @param AccountRepository $accountRepo
+ * @param UserMailer $userMailer
*/
public function __construct(AccountRepository $accountRepo, UserMailer $userMailer)
{
@@ -25,6 +27,7 @@ class HandleUserSettingsChanged {
* Handle the event.
*
* @param UserSettingsChanged $event
+ *
* @return void
*/
public function handle(UserSettingsChanged $event)
@@ -44,5 +47,4 @@ class HandleUserSettingsChanged {
Session::flash('warning', trans('texts.verify_email'));
}
}
-
}
diff --git a/app/Listeners/HandleUserSignedUp.php b/app/Listeners/HandleUserSignedUp.php
index 6433a1b5b4ad..11fd3b90fb2c 100644
--- a/app/Listeners/HandleUserSignedUp.php
+++ b/app/Listeners/HandleUserSignedUp.php
@@ -3,19 +3,29 @@
use Utils;
use Auth;
use App\Events\UserSignedUp;
-use App\Models\Activity;
use App\Ninja\Repositories\AccountRepository;
use App\Ninja\Mailers\UserMailer;
+/**
+ * Class HandleUserSignedUp
+ */
class HandleUserSignedUp
{
+ /**
+ * @var AccountRepository
+ */
protected $accountRepo;
+
+ /**
+ * @var UserMailer
+ */
protected $userMailer;
/**
* Create the event handler.
- *
- * @return void
+ *
+ * @param AccountRepository $accountRepo
+ * @param UserMailer $userMailer
*/
public function __construct(AccountRepository $accountRepo, UserMailer $userMailer)
{
@@ -27,6 +37,7 @@ class HandleUserSignedUp
* Handle the event.
*
* @param UserSignedUp $event
+ *
* @return void
*/
public function handle(UserSignedUp $event)
diff --git a/app/Listeners/InvoiceListener.php b/app/Listeners/InvoiceListener.php
index d5d20ae991c6..566d9b4994c2 100644
--- a/app/Listeners/InvoiceListener.php
+++ b/app/Listeners/InvoiceListener.php
@@ -2,7 +2,6 @@
use Utils;
use Auth;
-use App\Events\InvoiceWasEmailed;
use App\Events\InvoiceWasUpdated;
use App\Events\InvoiceWasCreated;
use App\Events\PaymentWasCreated;
@@ -13,8 +12,14 @@ use App\Events\PaymentWasVoided;
use App\Events\PaymentFailed;
use App\Events\InvoiceInvitationWasViewed;
+/**
+ * Class InvoiceListener
+ */
class InvoiceListener
{
+ /**
+ * @param InvoiceWasCreated $event
+ */
public function createdInvoice(InvoiceWasCreated $event)
{
if (Utils::hasFeature(FEATURE_DIFFERENT_DESIGNS)) {
@@ -34,18 +39,27 @@ class InvoiceListener
}
}
+ /**
+ * @param InvoiceWasUpdated $event
+ */
public function updatedInvoice(InvoiceWasUpdated $event)
{
$invoice = $event->invoice;
$invoice->updatePaidStatus(false);
}
+ /**
+ * @param InvoiceInvitationWasViewed $event
+ */
public function viewedInvoice(InvoiceInvitationWasViewed $event)
{
$invitation = $event->invitation;
$invitation->markViewed();
}
+ /**
+ * @param PaymentWasCreated $event
+ */
public function createdPayment(PaymentWasCreated $event)
{
$payment = $event->payment;
@@ -57,6 +71,9 @@ class InvoiceListener
$invoice->updatePaidStatus();
}
+ /**
+ * @param PaymentWasDeleted $event
+ */
public function deletedPayment(PaymentWasDeleted $event)
{
$payment = $event->payment;
@@ -67,6 +84,9 @@ class InvoiceListener
$invoice->updatePaidStatus();
}
+ /**
+ * @param PaymentWasRefunded $event
+ */
public function refundedPayment(PaymentWasRefunded $event)
{
$payment = $event->payment;
@@ -77,6 +97,9 @@ class InvoiceListener
$invoice->updatePaidStatus();
}
+ /**
+ * @param PaymentWasVoided $event
+ */
public function voidedPayment(PaymentWasVoided $event)
{
$payment = $event->payment;
@@ -87,6 +110,9 @@ class InvoiceListener
$invoice->updatePaidStatus();
}
+ /**
+ * @param PaymentFailed $event
+ */
public function failedPayment(PaymentFailed $event)
{
$payment = $event->payment;
@@ -97,6 +123,9 @@ class InvoiceListener
$invoice->updatePaidStatus();
}
+ /**
+ * @param PaymentWasRestored $event
+ */
public function restoredPayment(PaymentWasRestored $event)
{
if ( ! $event->fromDeleted) {
diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php
index 87a685944919..d18b0a32671b 100644
--- a/app/Listeners/NotificationListener.php
+++ b/app/Listeners/NotificationListener.php
@@ -2,29 +2,50 @@
use App\Ninja\Mailers\UserMailer;
use App\Ninja\Mailers\ContactMailer;
-
use App\Events\InvoiceWasEmailed;
use App\Events\QuoteWasEmailed;
use App\Events\InvoiceInvitationWasViewed;
use App\Events\QuoteInvitationWasViewed;
use App\Events\QuoteInvitationWasApproved;
use App\Events\PaymentWasCreated;
-use App\Ninja\Notifications;
use App\Services\PushService;
+/**
+ * Class NotificationListener
+ */
class NotificationListener
{
+ /**
+ * @var UserMailer
+ */
protected $userMailer;
+ /**
+ * @var ContactMailer
+ */
protected $contactMailer;
+ /**
+ * @var PushService
+ */
protected $pushService;
+ /**
+ * NotificationListener constructor.
+ * @param UserMailer $userMailer
+ * @param ContactMailer $contactMailer
+ * @param PushService $pushService
+ */
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer, PushService $pushService)
{
$this->userMailer = $userMailer;
$this->contactMailer = $contactMailer;
$this->pushService = $pushService;
- }
+ }
+ /**
+ * @param $invoice
+ * @param $type
+ * @param null $payment
+ */
private function sendEmails($invoice, $type, $payment = null)
{
foreach ($invoice->account->users as $user)
@@ -36,36 +57,54 @@ class NotificationListener
}
}
+ /**
+ * @param InvoiceWasEmailed $event
+ */
public function emailedInvoice(InvoiceWasEmailed $event)
{
$this->sendEmails($event->invoice, 'sent');
$this->pushService->sendNotification($event->invoice, 'sent');
}
+ /**
+ * @param QuoteWasEmailed $event
+ */
public function emailedQuote(QuoteWasEmailed $event)
{
$this->sendEmails($event->quote, 'sent');
$this->pushService->sendNotification($event->quote, 'sent');
}
+ /**
+ * @param InvoiceInvitationWasViewed $event
+ */
public function viewedInvoice(InvoiceInvitationWasViewed $event)
{
$this->sendEmails($event->invoice, 'viewed');
$this->pushService->sendNotification($event->invoice, 'viewed');
}
+ /**
+ * @param QuoteInvitationWasViewed $event
+ */
public function viewedQuote(QuoteInvitationWasViewed $event)
{
$this->sendEmails($event->quote, 'viewed');
$this->pushService->sendNotification($event->quote, 'viewed');
}
+ /**
+ * @param QuoteInvitationWasApproved $event
+ */
public function approvedQuote(QuoteInvitationWasApproved $event)
{
$this->sendEmails($event->quote, 'approved');
$this->pushService->sendNotification($event->quote, 'approved');
}
+ /**
+ * @param PaymentWasCreated $event
+ */
public function createdPayment(PaymentWasCreated $event)
{
// only send emails for online payments
diff --git a/app/Listeners/QuoteListener.php b/app/Listeners/QuoteListener.php
index de857a4bae54..d1b85bdf4ef3 100644
--- a/app/Listeners/QuoteListener.php
+++ b/app/Listeners/QuoteListener.php
@@ -1,12 +1,15 @@
invitation;
diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php
index 50d6f3be9240..5b84413cb25a 100644
--- a/app/Listeners/SubscriptionListener.php
+++ b/app/Listeners/SubscriptionListener.php
@@ -1,67 +1,92 @@
client->account);
$this->checkSubscriptions(EVENT_CREATE_CLIENT, $event->client, $transformer);
}
+ /**
+ * @param QuoteWasCreated $event
+ */
public function createdQuote(QuoteWasCreated $event)
{
$transformer = new InvoiceTransformer($event->quote->account);
$this->checkSubscriptions(EVENT_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT);
}
+ /**
+ * @param PaymentWasCreated $event
+ */
public function createdPayment(PaymentWasCreated $event)
{
$transformer = new PaymentTransformer($event->payment->account);
$this->checkSubscriptions(EVENT_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]);
}
+ /**
+ * @param InvoiceWasCreated $event
+ */
public function createdInvoice(InvoiceWasCreated $event)
{
$transformer = new InvoiceTransformer($event->invoice->account);
$this->checkSubscriptions(EVENT_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT);
}
+ /**
+ * @param CreditWasCreated $event
+ */
public function createdCredit(CreditWasCreated $event)
{
}
+ /**
+ * @param VendorWasCreated $event
+ */
public function createdVendor(VendorWasCreated $event)
{
}
+ /**
+ * @param ExpenseWasCreated $event
+ */
public function createdExpense(ExpenseWasCreated $event)
{
}
+ /**
+ * @param $eventId
+ * @param $entity
+ * @param $transformer
+ * @param string $include
+ */
private function checkSubscriptions($eventId, $entity, $transformer, $include = '')
{
if ( ! EntityModel::$notifySubscriptions) {
diff --git a/app/Listeners/TaskListener.php b/app/Listeners/TaskListener.php
index b2038bb3f22f..a49a243b9f38 100644
--- a/app/Listeners/TaskListener.php
+++ b/app/Listeners/TaskListener.php
@@ -3,8 +3,14 @@
use App\Models\Task;
use App\Events\InvoiceWasDeleted;
+/**
+ * Class TaskListener
+ */
class TaskListener
{
+ /**
+ * @param InvoiceWasDeleted $event
+ */
public function deletedInvoice(InvoiceWasDeleted $event)
{
// Release any tasks associated with the deleted invoice
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 4a00da54c89a..e88b0b908c58 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -7,34 +7,51 @@ use DateTime;
use Event;
use Cache;
use App;
-use File;
-use App\Models\Document;
-use App\Models\AccountGateway;
use App\Events\UserSettingsChanged;
use Illuminate\Support\Facades\Storage;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laracasts\Presenter\PresentableTrait;
+/**
+ * Class Account
+ */
class Account extends Eloquent
{
use PresentableTrait;
use SoftDeletes;
- public static $plan_prices = array(
- PLAN_PRO => array(
+ /**
+ * @var array
+ */
+ public static $plan_prices = [
+ PLAN_PRO => [
PLAN_TERM_MONTHLY => PLAN_PRICE_PRO_MONTHLY,
PLAN_TERM_YEARLY => PLAN_PRICE_PRO_YEARLY,
- ),
- PLAN_ENTERPRISE => array(
+ ],
+ PLAN_ENTERPRISE => [
PLAN_TERM_MONTHLY => PLAN_PRICE_ENTERPRISE_MONTHLY,
PLAN_TERM_YEARLY => PLAN_PRICE_ENTERPRISE_YEARLY,
- ),
- );
+ ],
+ ];
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\AccountPresenter';
+
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+
+ /**
+ * @var array
+ */
protected $hidden = ['ip'];
+ /**
+ * @var array
+ */
protected $fillable = [
'name',
'id_number',
@@ -64,6 +81,9 @@ class Account extends Eloquent
'enable_second_tax_rate',
];
+ /**
+ * @var array
+ */
public static $basicSettings = [
ACCOUNT_COMPANY_DETAILS,
ACCOUNT_USER_DETAILS,
@@ -77,6 +97,9 @@ class Account extends Eloquent
ACCOUNT_MANAGEMENT,
];
+ /**
+ * @var array
+ */
public static $advancedSettings = [
ACCOUNT_INVOICE_SETTINGS,
ACCOUNT_INVOICE_DESIGN,
@@ -89,136 +112,210 @@ class Account extends Eloquent
ACCOUNT_API_TOKENS,
];
- /*
- protected $casts = [
- 'invoice_settings' => 'object',
- ];
- */
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function account_tokens()
{
return $this->hasMany('App\Models\AccountToken');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function users()
{
return $this->hasMany('App\Models\User');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function clients()
{
return $this->hasMany('App\Models\Client');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function contacts()
{
return $this->hasMany('App\Models\Contact');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function invoices()
{
return $this->hasMany('App\Models\Invoice');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function account_gateways()
{
return $this->hasMany('App\Models\AccountGateway');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function bank_accounts()
{
return $this->hasMany('App\Models\BankAccount');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function tax_rates()
{
return $this->hasMany('App\Models\TaxRate');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function products()
{
return $this->hasMany('App\Models\Product');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function country()
{
return $this->belongsTo('App\Models\Country');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function timezone()
{
return $this->belongsTo('App\Models\Timezone');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function language()
{
return $this->belongsTo('App\Models\Language');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function date_format()
{
return $this->belongsTo('App\Models\DateFormat');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function datetime_format()
{
return $this->belongsTo('App\Models\DatetimeFormat');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function size()
{
return $this->belongsTo('App\Models\Size');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function currency()
{
return $this->belongsTo('App\Models\Currency');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function industry()
{
return $this->belongsTo('App\Models\Industry');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function default_tax_rate()
{
return $this->belongsTo('App\Models\TaxRate');
}
+ /**
+ * @return mixed
+ */
public function expenses()
{
return $this->hasMany('App\Models\Expense','account_id','id')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function payments()
{
return $this->hasMany('App\Models\Payment','account_id','id')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function company()
{
return $this->belongsTo('App\Models\Company');
}
+ /**
+ * @return mixed
+ */
public function expenseCategories()
{
return $this->hasMany('App\Models\ExpenseCategory','account_id','id')->withTrashed();
}
+ /**
+ * @param $value
+ */
public function setIndustryIdAttribute($value)
{
$this->attributes['industry_id'] = $value ?: null;
}
+ /**
+ * @param $value
+ */
public function setCountryIdAttribute($value)
{
$this->attributes['country_id'] = $value ?: null;
}
+ /**
+ * @param $value
+ */
public function setSizeIdAttribute($value)
{
$this->attributes['size_id'] = $value ?: null;
}
+ /**
+ * @param int $gatewayId
+ * @return bool
+ */
public function isGatewayConfigured($gatewayId = 0)
{
if ( ! $this->relationLoaded('account_gateways')) {
@@ -232,11 +329,17 @@ class Account extends Eloquent
}
}
+ /**
+ * @return bool
+ */
public function isEnglish()
{
return !$this->language_id || $this->language_id == DEFAULT_LANGUAGE;
}
+ /**
+ * @return bool
+ */
public function hasInvoicePrefix()
{
if ( ! $this->invoice_number_prefix && ! $this->quote_number_prefix) {
@@ -246,6 +349,9 @@ class Account extends Eloquent
return $this->invoice_number_prefix != $this->quote_number_prefix;
}
+ /**
+ * @return mixed
+ */
public function getDisplayName()
{
if ($this->name) {
@@ -258,12 +364,18 @@ class Account extends Eloquent
return $user->getDisplayName();
}
+ /**
+ * @return string
+ */
public function getCityState()
{
$swap = $this->country && $this->country->swap_postal_code;
return Utils::cityStateZip($this->city, $this->state, $this->postal_code, $swap);
}
+ /**
+ * @return mixed
+ */
public function getMomentDateTimeFormat()
{
$format = $this->datetime_format ? $this->datetime_format->format_moment : DEFAULT_DATETIME_MOMENT_FORMAT;
@@ -275,6 +387,9 @@ class Account extends Eloquent
return $format;
}
+ /**
+ * @return string
+ */
public function getMomentDateFormat()
{
$format = $this->getMomentDateTimeFormat();
@@ -284,6 +399,9 @@ class Account extends Eloquent
return trim($format);
}
+ /**
+ * @return string
+ */
public function getTimezone()
{
if ($this->timezone) {
@@ -293,6 +411,10 @@ class Account extends Eloquent
}
}
+ /**
+ * @param string $date
+ * @return DateTime|null|string
+ */
public function getDateTime($date = 'now')
{
if ( ! $date) {
@@ -306,11 +428,20 @@ class Account extends Eloquent
return $date;
}
+ /**
+ * @return mixed
+ */
public function getCustomDateFormat()
{
return $this->date_format ? $this->date_format->format : DEFAULT_DATE_FORMAT;
}
+ /**
+ * @param $amount
+ * @param null $client
+ * @param bool $hideSymbol
+ * @return string
+ */
public function formatMoney($amount, $client = null, $hideSymbol = false)
{
if ($client && $client->currency_id) {
@@ -334,11 +465,18 @@ class Account extends Eloquent
return Utils::formatMoney($amount, $currencyId, $countryId, $hideSymbol);
}
+ /**
+ * @return mixed
+ */
public function getCurrencyId()
{
return $this->currency_id ?: DEFAULT_CURRENCY;
}
+ /**
+ * @param $date
+ * @return null|string
+ */
public function formatDate($date)
{
$date = $this->getDateTime($date);
@@ -350,6 +488,10 @@ class Account extends Eloquent
return $date->format($this->getCustomDateFormat());
}
+ /**
+ * @param $date
+ * @return null|string
+ */
public function formatDateTime($date)
{
$date = $this->getDateTime($date);
@@ -361,6 +503,10 @@ class Account extends Eloquent
return $date->format($this->getCustomDateTimeFormat());
}
+ /**
+ * @param $date
+ * @return null|string
+ */
public function formatTime($date)
{
$date = $this->getDateTime($date);
@@ -372,11 +518,17 @@ class Account extends Eloquent
return $date->format($this->getCustomTimeFormat());
}
+ /**
+ * @return string
+ */
public function getCustomTimeFormat()
{
return $this->military_time ? 'H:i' : 'g:i a';
}
+ /**
+ * @return mixed
+ */
public function getCustomDateTimeFormat()
{
$format = $this->datetime_format ? $this->datetime_format->format : DEFAULT_DATETIME_FORMAT;
@@ -398,12 +550,17 @@ class Account extends Eloquent
}
*/
+ /**
+ * @param bool $type
+ * @return AccountGateway|bool
+ */
public function getGatewayByType($type = false)
{
if ( ! $this->relationLoaded('account_gateways')) {
$this->load('account_gateways');
}
+ /** @var AccountGateway $accountGateway */
foreach ($this->account_gateways as $accountGateway) {
if ( ! $type) {
return $accountGateway;
@@ -419,6 +576,9 @@ class Account extends Eloquent
return false;
}
+ /**
+ * @return array
+ */
public function availableGatewaysIds()
{
if ( ! $this->relationLoaded('account_gateways')) {
@@ -452,8 +612,14 @@ class Account extends Eloquent
return $gatewayIds;
}
+ /**
+ * @param bool $invitation
+ * @param bool $gatewayType
+ * @return bool
+ */
public function paymentDriver($invitation = false, $gatewayType = false)
{
+ /** @var AccountGateway $accountGateway */
if ($accountGateway = $this->getGatewayByType($gatewayType)) {
return $accountGateway->paymentDriver($invitation, $gatewayType);
}
@@ -461,16 +627,27 @@ class Account extends Eloquent
return false;
}
+ /**
+ * @return mixed
+ */
public function gatewayIds()
{
return $this->account_gateways()->pluck('gateway_id')->toArray();
}
+ /**
+ * @param $gatewayId
+ * @return bool
+ */
public function hasGatewayId($gatewayId)
{
return in_array($gatewayId, $this->gatewayIds());
}
+ /**
+ * @param $gatewayId
+ * @return bool
+ */
public function getGatewayConfig($gatewayId)
{
foreach ($this->account_gateways as $gateway) {
@@ -482,6 +659,9 @@ class Account extends Eloquent
return false;
}
+ /**
+ * @return bool
+ */
public function hasLogo()
{
if($this->logo == ''){
@@ -491,6 +671,9 @@ class Account extends Eloquent
return !empty($this->logo);
}
+ /**
+ * @return mixed
+ */
public function getLogoDisk(){
return Storage::disk(env('LOGO_FILESYSTEM', 'logos'));
}
@@ -515,6 +698,9 @@ class Account extends Eloquent
$this->save();
}
+ /**
+ * @return null
+ */
public function getLogoRaw(){
if(!$this->hasLogo()){
return null;
@@ -524,6 +710,10 @@ class Account extends Eloquent
return $disk->get($this->logo);
}
+ /**
+ * @param bool $cachebuster
+ * @return null|string
+ */
public function getLogoURL($cachebuster = false)
{
if(!$this->hasLogo()){
@@ -549,6 +739,9 @@ class Account extends Eloquent
return Document::getDirectFileUrl($this->logo, $this->getLogoDisk());
}
+ /**
+ * @return mixed
+ */
public function getPrimaryUser()
{
return $this->users()
@@ -556,6 +749,11 @@ class Account extends Eloquent
->first();
}
+ /**
+ * @param $userId
+ * @param $name
+ * @return null
+ */
public function getToken($userId, $name)
{
foreach ($this->account_tokens as $token) {
@@ -567,6 +765,9 @@ class Account extends Eloquent
return null;
}
+ /**
+ * @return mixed|null
+ */
public function getLogoWidth()
{
if(!$this->hasLogo()){
@@ -576,6 +777,9 @@ class Account extends Eloquent
return $this->logo_width;
}
+ /**
+ * @return mixed|null
+ */
public function getLogoHeight()
{
if(!$this->hasLogo()){
@@ -585,6 +789,11 @@ class Account extends Eloquent
return $this->logo_height;
}
+ /**
+ * @param $entityType
+ * @param null $clientId
+ * @return mixed
+ */
public function createInvoice($entityType = ENTITY_INVOICE, $clientId = null)
{
$invoice = Invoice::createNew();
@@ -619,6 +828,10 @@ class Account extends Eloquent
return $invoice;
}
+ /**
+ * @param $invoice_type_id
+ * @return string
+ */
public function getNumberPrefix($invoice_type_id)
{
if ( ! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) {
@@ -628,6 +841,10 @@ class Account extends Eloquent
return ($invoice_type_id == INVOICE_TYPE_QUOTE ? $this->quote_number_prefix : $this->invoice_number_prefix) ?: '';
}
+ /**
+ * @param $invoice_type_id
+ * @return bool
+ */
public function hasNumberPattern($invoice_type_id)
{
if ( ! $this->hasFeature(FEATURE_INVOICE_SETTINGS)) {
@@ -637,6 +854,10 @@ class Account extends Eloquent
return $invoice_type_id == INVOICE_TYPE_QUOTE ? ($this->quote_number_pattern ? true : false) : ($this->invoice_number_pattern ? true : false);
}
+ /**
+ * @param $invoice
+ * @return string
+ */
public function hasClientNumberPattern($invoice)
{
$pattern = $invoice->invoice_type_id == INVOICE_TYPE_QUOTE ? $this->quote_number_pattern : $this->invoice_number_pattern;
@@ -644,6 +865,10 @@ class Account extends Eloquent
return strstr($pattern, '$custom');
}
+ /**
+ * @param $invoice
+ * @return bool|mixed
+ */
public function getNumberPattern($invoice)
{
$pattern = $invoice->invoice_type_id == INVOICE_TYPE_QUOTE ? $this->quote_number_pattern : $this->invoice_number_pattern;
@@ -680,6 +905,11 @@ class Account extends Eloquent
return $pattern;
}
+ /**
+ * @param $pattern
+ * @param $invoice
+ * @return mixed
+ */
private function getClientInvoiceNumber($pattern, $invoice)
{
if (!$invoice->client) {
@@ -699,17 +929,30 @@ class Account extends Eloquent
return str_replace($search, $replace, $pattern);
}
+ /**
+ * @param $invoice_type_id
+ * @return mixed
+ */
public function getCounter($invoice_type_id)
{
return $invoice_type_id == INVOICE_TYPE_QUOTE && !$this->share_counter ? $this->quote_number_counter : $this->invoice_number_counter;
}
+ /**
+ * @param $entityType
+ * @return mixed|string
+ */
public function previewNextInvoiceNumber($entityType = ENTITY_INVOICE)
{
$invoice = $this->createInvoice($entityType);
return $this->getNextInvoiceNumber($invoice);
}
+ /**
+ * @param $invoice
+ * @param bool $validateUnique
+ * @return mixed|string
+ */
public function getNextInvoiceNumber($invoice, $validateUnique = true)
{
if ($this->hasNumberPattern($invoice->invoice_type_id)) {
@@ -749,6 +992,9 @@ class Account extends Eloquent
return $number;
}
+ /**
+ * @param $invoice
+ */
public function incrementCounter($invoice)
{
// if they didn't use the counter don't increment it
@@ -765,6 +1011,9 @@ class Account extends Eloquent
$this->save();
}
+ /**
+ * @param null $updatedAt
+ */
public function loadAllData($updatedAt = null)
{
$map = [
@@ -788,6 +1037,9 @@ class Account extends Eloquent
}
}
+ /**
+ * @param bool $client
+ */
public function loadLocalizationSettings($client = false)
{
$this->load('timezone', 'date_format', 'datetime_format', 'language');
@@ -813,6 +1065,9 @@ class Account extends Eloquent
Session::put(SESSION_DATETIME_FORMAT, $format);
}
+ /**
+ * @return array
+ */
public function getInvoiceLabels()
{
$data = [];
@@ -872,11 +1127,17 @@ class Account extends Eloquent
return $data;
}
+ /**
+ * @return bool
+ */
public function isNinjaAccount()
{
return $this->account_key === NINJA_ACCOUNT_KEY;
}
+ /**
+ * @param $plan
+ */
public function startTrial($plan)
{
if ( ! Utils::isNinja()) {
@@ -888,6 +1149,10 @@ class Account extends Eloquent
$this->company->save();
}
+ /**
+ * @param $feature
+ * @return bool
+ */
public function hasFeature($feature)
{
if (Utils::isNinjaDev()) {
@@ -954,6 +1219,10 @@ class Account extends Eloquent
}
}
+ /**
+ * @param null $plan_details
+ * @return bool
+ */
public function isPro(&$plan_details = null)
{
if (!Utils::isNinjaProd()) {
@@ -969,6 +1238,10 @@ class Account extends Eloquent
return !empty($plan_details);
}
+ /**
+ * @param null $plan_details
+ * @return bool
+ */
public function isEnterprise(&$plan_details = null)
{
if (!Utils::isNinjaProd()) {
@@ -984,6 +1257,11 @@ class Account extends Eloquent
return $plan_details && $plan_details['plan'] == PLAN_ENTERPRISE;
}
+ /**
+ * @param bool $include_inactive
+ * @param bool $include_trial
+ * @return array|null
+ */
public function getPlanDetails($include_inactive = false, $include_trial = true)
{
if (!$this->company) {
@@ -1053,7 +1331,7 @@ class Account extends Eloquent
}
if ($use_plan) {
- return array(
+ return [
'trial' => false,
'plan' => $plan,
'started' => DateTime::createFromFormat('Y-m-d', $this->company->plan_started),
@@ -1061,18 +1339,21 @@ class Account extends Eloquent
'paid' => DateTime::createFromFormat('Y-m-d', $this->company->plan_paid),
'term' => $this->company->plan_term,
'active' => $plan_active,
- );
+ ];
} else {
- return array(
+ return [
'trial' => true,
'plan' => $trial_plan,
'started' => $trial_started,
'expires' => $trial_expires,
'active' => $trial_active,
- );
+ ];
}
}
+ /**
+ * @return bool
+ */
public function isTrial()
{
if (!Utils::isNinjaProd()) {
@@ -1084,13 +1365,17 @@ class Account extends Eloquent
return $plan_details && $plan_details['trial'];
}
+ /**
+ * @param null $plan
+ * @return array|bool
+ */
public function isEligibleForTrial($plan = null)
{
if (!$this->company->trial_plan) {
if ($plan) {
return $plan == PLAN_PRO || $plan == PLAN_ENTERPRISE;
} else {
- return array(PLAN_PRO, PLAN_ENTERPRISE);
+ return [PLAN_PRO, PLAN_ENTERPRISE];
}
}
@@ -1098,13 +1383,16 @@ class Account extends Eloquent
if ($plan) {
return $plan != PLAN_PRO;
} else {
- return array(PLAN_ENTERPRISE);
+ return [PLAN_ENTERPRISE];
}
}
return false;
}
+ /**
+ * @return int
+ */
public function getCountTrialDaysLeft()
{
$planDetails = $this->getPlanDetails(true);
@@ -1119,6 +1407,9 @@ class Account extends Eloquent
return $interval ? $interval->d : 0;
}
+ /**
+ * @return mixed
+ */
public function getRenewalDate()
{
$planDetails = $this->getPlanDetails();
@@ -1133,6 +1424,9 @@ class Account extends Eloquent
return $date->format('Y-m-d');
}
+ /**
+ * @return float|null
+ */
public function getLogoSize()
{
if(!$this->hasLogo()){
@@ -1142,16 +1436,26 @@ class Account extends Eloquent
return round($this->logo_size / 1000);
}
+ /**
+ * @return bool
+ */
public function isLogoTooLarge()
{
return $this->getLogoSize() > MAX_LOGO_FILE_SIZE;
}
+ /**
+ * @param $eventId
+ * @return \Illuminate\Database\Eloquent\Model|null|static
+ */
public function getSubscription($eventId)
{
return Subscription::where('account_id', '=', $this->id)->where('event_id', '=', $eventId)->first();
}
+ /**
+ * @return $this
+ */
public function hideFieldsForViz()
{
foreach ($this->clients as $client) {
@@ -1198,6 +1502,10 @@ class Account extends Eloquent
return $this;
}
+ /**
+ * @param $entityType
+ * @return mixed
+ */
public function getDefaultEmailSubject($entityType)
{
if (strpos($entityType, 'reminder') !== false) {
@@ -1207,6 +1515,10 @@ class Account extends Eloquent
return trans("texts.{$entityType}_subject", ['invoice' => '$invoice', 'account' => '$account']);
}
+ /**
+ * @param $entityType
+ * @return mixed
+ */
public function getEmailSubject($entityType)
{
if ($this->hasFeature(FEATURE_CUSTOM_EMAILS)) {
@@ -1221,29 +1533,39 @@ class Account extends Eloquent
return $this->getDefaultEmailSubject($entityType);
}
+ /**
+ * @param $entityType
+ * @param bool $message
+ * @return string
+ */
public function getDefaultEmailTemplate($entityType, $message = false)
{
if (strpos($entityType, 'reminder') !== false) {
$entityType = ENTITY_INVOICE;
}
- $template = "\$client,
";
+ $template = '$client,
';
if ($this->hasFeature(FEATURE_CUSTOM_EMAILS) && $this->email_design_id != EMAIL_DESIGN_PLAIN) {
- $template .= "" . trans("texts.{$entityType}_message_button", ['amount' => '$amount']) . "
" .
- "\$viewButton
";
+ $template .= '' . trans("texts.{$entityType}_message_button", ['amount' => '$amount']) . '
' .
+ '$viewButton
';
} else {
- $template .= "" . trans("texts.{$entityType}_message", ['amount' => '$amount']) . "
" .
- "\$viewLink
";
+ $template .= '' . trans("texts.{$entityType}_message", ['amount' => '$amount']) . '
' .
+ '$viewLink
';
}
if ($message) {
$template .= "$message\r\n\r\n";
}
- return $template . "\$footer";
+ return $template . '$footer';
}
+ /**
+ * @param $entityType
+ * @param bool $message
+ * @return mixed
+ */
public function getEmailTemplate($entityType, $message = false)
{
$template = false;
@@ -1261,21 +1583,32 @@ class Account extends Eloquent
return str_replace('/>', ' />', $template);
}
+ /**
+ * @param string $view
+ * @return string
+ */
public function getTemplateView($view = '')
{
return $this->getEmailDesignId() == EMAIL_DESIGN_PLAIN ? $view : 'design' . $this->getEmailDesignId();
}
+ /**
+ * @return mixed|string
+ */
public function getEmailFooter()
{
if ($this->email_footer) {
// Add line breaks if HTML isn't already being used
return strip_tags($this->email_footer) == $this->email_footer ? nl2br($this->email_footer) : $this->email_footer;
} else {
- return "" . trans('texts.email_signature') . "\n
\$account
";
+ return '' . trans('texts.email_signature') . "\n
\$account
";
}
}
+ /**
+ * @param $reminder
+ * @return bool
+ */
public function getReminderDate($reminder)
{
if ( ! $this->{"enable_reminder{$reminder}"}) {
@@ -1288,7 +1621,11 @@ class Account extends Eloquent
return date('Y-m-d', strtotime("$plusMinus $numDays days"));
}
- public function getInvoiceReminder($invoice)
+ /**
+ * @param Invoice $invoice
+ * @return bool|string
+ */
+ public function getInvoiceReminder(Invoice $invoice)
{
for ($i=1; $i<=3; $i++) {
if ($date = $this->getReminderDate($i)) {
@@ -1302,6 +1639,10 @@ class Account extends Eloquent
return false;
}
+ /**
+ * @param null $storage_gateway
+ * @return bool
+ */
public function showTokenCheckbox(&$storage_gateway = null)
{
if (!($storage_gateway = $this->getTokenGatewayId())) {
@@ -1312,6 +1653,9 @@ class Account extends Eloquent
|| $this->token_billing_type_id == TOKEN_BILLING_OPT_OUT;
}
+ /**
+ * @return bool
+ */
public function getTokenGatewayId() {
if ($this->isGatewayConfigured(GATEWAY_STRIPE)) {
return GATEWAY_STRIPE;
@@ -1324,6 +1668,9 @@ class Account extends Eloquent
}
}
+ /**
+ * @return bool|void
+ */
public function getTokenGateway() {
$gatewayId = $this->getTokenGatewayId();
if (!$gatewayId) {
@@ -1333,11 +1680,17 @@ class Account extends Eloquent
return $this->getGatewayConfig($gatewayId);
}
+ /**
+ * @return bool
+ */
public function selectTokenCheckbox()
{
return $this->token_billing_type_id == TOKEN_BILLING_OPT_OUT;
}
+ /**
+ * @return string
+ */
public function getSiteUrl()
{
$url = SITE_URL;
@@ -1352,6 +1705,10 @@ class Account extends Eloquent
return $url;
}
+ /**
+ * @param $host
+ * @return bool
+ */
public function checkSubdomain($host)
{
if (!$this->subdomain) {
@@ -1368,6 +1725,11 @@ class Account extends Eloquent
return true;
}
+ /**
+ * @param $field
+ * @param bool $entity
+ * @return bool
+ */
public function showCustomField($field, $entity = false)
{
if ($this->hasFeature(FEATURE_INVOICE_SETTINGS)) {
@@ -1384,16 +1746,25 @@ class Account extends Eloquent
return Utils::isEmpty($entity->$field) ? false : true;
}
+ /**
+ * @return bool
+ */
public function attachPDF()
{
return $this->hasFeature(FEATURE_PDF_ATTACHMENT) && $this->pdf_email_attachment;
}
+ /**
+ * @return mixed
+ */
public function getEmailDesignId()
{
return $this->hasFeature(FEATURE_CUSTOM_EMAILS) ? $this->email_design_id : EMAIL_DESIGN_PLAIN;
}
+ /**
+ * @return string
+ */
public function clientViewCSS(){
$css = '';
@@ -1414,12 +1785,16 @@ class Account extends Eloquent
return $css;
}
+ /**
+ * @param string $protocol
+ * @return string
+ */
public function getFontsUrl($protocol = ''){
$bodyFont = $this->getHeaderFontId();
$headerFont = $this->getBodyFontId();
$bodyFontSettings = Utils::getFromCache($bodyFont, 'fonts');
- $google_fonts = array($bodyFontSettings['google_font']);
+ $google_fonts = [$bodyFontSettings['google_font']];
if($headerFont != $bodyFont){
$headerFontSettings = Utils::getFromCache($headerFont, 'fonts');
@@ -1429,22 +1804,38 @@ class Account extends Eloquent
return ($protocol?$protocol.':':'').'//fonts.googleapis.com/css?family='.implode('|',$google_fonts);
}
+ /**
+ * @return mixed
+ */
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() {
return ($this->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN) && $this->body_font_id) ? $this->body_font_id : DEFAULT_BODY_FONT;
}
+ /**
+ * @return null
+ */
public function getHeaderFontName(){
return Utils::getFromCache($this->getHeaderFontId(), 'fonts')['name'];
}
+ /**
+ * @return null
+ */
public function getBodyFontName(){
return Utils::getFromCache($this->getBodyFontId(), 'fonts')['name'];
}
+ /**
+ * @param bool $include_weight
+ * @return string
+ */
public function getHeaderFontCss($include_weight = true){
$font_data = Utils::getFromCache($this->getHeaderFontId(), 'fonts');
$css = 'font-family:'.$font_data['css_stack'].';';
@@ -1456,6 +1847,10 @@ class Account extends Eloquent
return $css;
}
+ /**
+ * @param bool $include_weight
+ * @return string
+ */
public function getBodyFontCss($include_weight = true){
$font_data = Utils::getFromCache($this->getBodyFontId(), 'fonts');
$css = 'font-family:'.$font_data['css_stack'].';';
@@ -1467,12 +1862,18 @@ class Account extends Eloquent
return $css;
}
+ /**
+ * @return array
+ */
public function getFonts(){
- return array_unique(array($this->getHeaderFontId(), $this->getBodyFontId()));
+ return array_unique([$this->getHeaderFontId(), $this->getBodyFontId()]);
}
+ /**
+ * @return array
+ */
public function getFontsData(){
- $data = array();
+ $data = [];
foreach($this->getFonts() as $font){
$data[] = Utils::getFromCache($font, 'fonts');
@@ -1481,6 +1882,9 @@ class Account extends Eloquent
return $data;
}
+ /**
+ * @return array
+ */
public function getFontFolders(){
return array_map(function($item){return $item['folder'];}, $this->getFontsData());
}
diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php
index 15842486a98e..a2250b9bfc24 100644
--- a/app/Models/AccountGateway.php
+++ b/app/Models/AccountGateway.php
@@ -1,28 +1,45 @@
belongsTo('App\Models\Gateway');
}
+ /**
+ * @return array
+ */
public function getCreditcardTypes()
{
$flags = unserialize(CREDIT_CARDS);
@@ -37,19 +54,28 @@ class AccountGateway extends EntityModel
return $arrayOfImages;
}
+ /**
+ * @param $provider
+ * @return string
+ */
public static function paymentDriverClass($provider)
{
- $folder = "App\\Ninja\\PaymentDrivers\\";
+ $folder = 'App\\Ninja\\PaymentDrivers\\';
$class = $folder . $provider . 'PaymentDriver';
$class = str_replace('_', '', $class);
if (class_exists($class)) {
return $class;
} else {
- return $folder . "BasePaymentDriver";
+ return $folder . 'BasePaymentDriver';
}
}
+ /**
+ * @param bool $invitation
+ * @param bool $gatewayType
+ * @return mixed
+ */
public function paymentDriver($invitation = false, $gatewayType = false)
{
$class = static::paymentDriverClass($this->gateway->provider);
@@ -57,26 +83,43 @@ class AccountGateway extends EntityModel
return new $class($this, $invitation, $gatewayType);
}
+ /**
+ * @param $gatewayId
+ * @return bool
+ */
public function isGateway($gatewayId)
{
return $this->gateway_id == $gatewayId;
}
+ /**
+ * @param $config
+ */
public function setConfig($config)
{
$this->config = Crypt::encrypt(json_encode($config));
}
+ /**
+ * @return mixed
+ */
public function getConfig()
{
return json_decode(Crypt::decrypt($this->config));
}
+ /**
+ * @param $field
+ * @return mixed
+ */
public function getConfigField($field)
{
return object_get($this->getConfig(), $field, false);
}
+ /**
+ * @return bool|mixed
+ */
public function getPublishableStripeKey()
{
if ( ! $this->isGateway(GATEWAY_STRIPE)) {
@@ -86,16 +129,25 @@ class AccountGateway extends EntityModel
return $this->getConfigField('publishableKey');
}
+ /**
+ * @return bool
+ */
public function getAchEnabled()
{
return !empty($this->getConfigField('enableAch'));
}
+ /**
+ * @return bool
+ */
public function getPayPalEnabled()
{
return !empty($this->getConfigField('enablePayPal'));
}
+ /**
+ * @return bool|mixed
+ */
public function getPlaidSecret()
{
if ( ! $this->isGateway(GATEWAY_STRIPE)) {
@@ -105,6 +157,9 @@ class AccountGateway extends EntityModel
return $this->getConfigField('plaidSecret');
}
+ /**
+ * @return bool|mixed
+ */
public function getPlaidClientId()
{
if ( ! $this->isGateway(GATEWAY_STRIPE)) {
@@ -114,6 +169,9 @@ class AccountGateway extends EntityModel
return $this->getConfigField('plaidClientId');
}
+ /**
+ * @return bool|mixed
+ */
public function getPlaidPublicKey()
{
if ( ! $this->isGateway(GATEWAY_STRIPE)) {
@@ -123,11 +181,17 @@ class AccountGateway extends EntityModel
return $this->getConfigField('plaidPublicKey');
}
+ /**
+ * @return bool
+ */
public function getPlaidEnabled()
{
return !empty($this->getPlaidClientId()) && $this->getAchEnabled();
}
+ /**
+ * @return null|string
+ */
public function getPlaidEnvironment()
{
if (!$this->getPlaidClientId()) {
@@ -139,6 +203,9 @@ class AccountGateway extends EntityModel
return substr(trim($stripe_key), 0, 8) == 'pk_test_' ? 'tartan' : 'production';
}
+ /**
+ * @return string
+ */
public function getWebhookUrl()
{
$account = $this->account ? $this->account : Account::find($this->account_id);
diff --git a/app/Models/AccountGatewayToken.php b/app/Models/AccountGatewayToken.php
index 363bd26e86a2..b7fc767112fb 100644
--- a/app/Models/AccountGatewayToken.php
+++ b/app/Models/AccountGatewayToken.php
@@ -3,34 +3,64 @@
use Eloquent;
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class AccountGatewayToken
+ */
class AccountGatewayToken extends Eloquent
{
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @var array
+ */
protected $casts = [];
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function payment_methods()
{
return $this->hasMany('App\Models\PaymentMethod');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account_gateway()
{
return $this->belongsTo('App\Models\AccountGateway');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasOne
+ */
public function default_payment_method()
{
return $this->hasOne('App\Models\PaymentMethod', 'id', 'default_payment_method_id');
}
+ /**
+ * @return mixed
+ */
public function autoBillLater()
{
return $this->default_payment_method->requiresDelayedAutoBill();
}
+ /**
+ * @param $query
+ * @param $clientId
+ * @param $accountGatewayId
+ * @return mixed
+ */
public function scopeClientAndGateway($query, $clientId, $accountGatewayId)
{
$query->where('client_id', '=', $clientId)
@@ -39,11 +69,17 @@ class AccountGatewayToken extends Eloquent
return $query;
}
+ /**
+ * @return mixed
+ */
public function gatewayName()
{
return $this->account_gateway->gateway->name;
}
+ /**
+ * @return bool|string
+ */
public function gatewayLink()
{
$accountGateway = $this->account_gateway;
diff --git a/app/Models/AccountToken.php b/app/Models/AccountToken.php
index 55781aabb95e..5ef52e170117 100644
--- a/app/Models/AccountToken.php
+++ b/app/Models/AccountToken.php
@@ -2,21 +2,36 @@
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class AccountToken
+ */
class AccountToken extends EntityModel
{
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_TOKEN;
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
diff --git a/app/Models/Activity.php b/app/Models/Activity.php
index 2fa9e6e8e349..f36e14eaebe8 100644
--- a/app/Models/Activity.php
+++ b/app/Models/Activity.php
@@ -2,55 +2,85 @@
use Auth;
use Eloquent;
-use Utils;
-use Session;
-use Request;
-use Carbon;
+/**
+ * Class Activity
+ */
class Activity extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @param $query
+ * @return mixed
+ */
public function scopeScope($query)
{
return $query->whereAccountId(Auth::user()->account_id);
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function contact()
{
return $this->belongsTo('App\Models\Contact')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function credit()
{
return $this->belongsTo('App\Models\Credit')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function payment()
{
return $this->belongsTo('App\Models\Payment')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function getMessage()
{
$activityTypeId = $this->activity_type_id;
diff --git a/app/Models/Affiliate.php b/app/Models/Affiliate.php
index 63fcb71ce357..4945080ed7ea 100644
--- a/app/Models/Affiliate.php
+++ b/app/Models/Affiliate.php
@@ -2,8 +2,17 @@
use Eloquent;
+/**
+ * Class Affiliate
+ */
class Affiliate extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @var bool
+ */
protected $softDelete = true;
}
diff --git a/app/Models/BalanceAffecting.php b/app/Models/BalanceAffecting.php
index 0ba99f73a284..1486b7ba8269 100644
--- a/app/Models/BalanceAffecting.php
+++ b/app/Models/BalanceAffecting.php
@@ -1,5 +1,8 @@
config);
diff --git a/app/Models/BankAccount.php b/app/Models/BankAccount.php
index 6bb0a5437038..617c04ae94c5 100644
--- a/app/Models/BankAccount.php
+++ b/app/Models/BankAccount.php
@@ -1,24 +1,37 @@
belongsTo('App\Models\Bank');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function bank_subaccounts()
{
return $this->hasMany('App\Models\BankSubaccount');
diff --git a/app/Models/BankSubaccount.php b/app/Models/BankSubaccount.php
index 0cd33568e0ab..4cda62da0403 100644
--- a/app/Models/BankSubaccount.php
+++ b/app/Models/BankSubaccount.php
@@ -1,19 +1,28 @@
belongsTo('App\Models\BankAccount');
diff --git a/app/Models/Client.php b/app/Models/Client.php
index 1863120f223f..fd0aa127682e 100644
--- a/app/Models/Client.php
+++ b/app/Models/Client.php
@@ -5,17 +5,28 @@ use DB;
use Carbon;
use Laracasts\Presenter\PresentableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
-use App\Models\AccountGatewayToken;
+/**
+ * Class Client
+ */
class Client extends EntityModel
{
use PresentableTrait;
use SoftDeletes;
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\ClientPresenter';
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var array
+ */
protected $fillable = [
'name',
'id_number',
@@ -38,16 +49,46 @@ class Client extends EntityModel
'website',
];
+ /**
+ * @var string
+ */
public static $fieldName = 'name';
+ /**
+ * @var string
+ */
public static $fieldPhone = 'work_phone';
+ /**
+ * @var string
+ */
public static $fieldAddress1 = 'address1';
+ /**
+ * @var string
+ */
public static $fieldAddress2 = 'address2';
+ /**
+ * @var string
+ */
public static $fieldCity = 'city';
+ /**
+ * @var string
+ */
public static $fieldState = 'state';
+ /**
+ * @var string
+ */
public static $fieldPostalCode = 'postal_code';
+ /**
+ * @var string
+ */
public static $fieldNotes = 'notes';
+ /**
+ * @var string
+ */
public static $fieldCountry = 'country';
+ /**
+ * @return array
+ */
public static function getImportColumns()
{
return [
@@ -67,6 +108,9 @@ class Client extends EntityModel
];
}
+ /**
+ * @return array
+ */
public static function getImportMap()
{
return [
@@ -85,66 +129,107 @@ class Client extends EntityModel
];
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function invoices()
{
return $this->hasMany('App\Models\Invoice');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function payments()
{
return $this->hasMany('App\Models\Payment');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function contacts()
{
return $this->hasMany('App\Models\Contact');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function country()
{
return $this->belongsTo('App\Models\Country');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function currency()
{
return $this->belongsTo('App\Models\Currency');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function language()
{
return $this->belongsTo('App\Models\Language');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function size()
{
return $this->belongsTo('App\Models\Size');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function industry()
{
return $this->belongsTo('App\Models\Industry');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function credits()
{
return $this->hasMany('App\Models\Credit');
}
+ /**
+ * @return mixed
+ */
public function expenses()
{
return $this->hasMany('App\Models\Expense','client_id','id')->withTrashed();
}
+ /**
+ * @param $data
+ * @param bool $isPrimary
+ * @return \Illuminate\Database\Eloquent\Model
+ */
public function addContact($data, $isPrimary = false)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false);
@@ -170,6 +255,10 @@ class Client extends EntityModel
return $this->contacts()->save($contact);
}
+ /**
+ * @param $balanceAdjustment
+ * @param $paidToDateAdjustment
+ */
public function updateBalances($balanceAdjustment, $paidToDateAdjustment)
{
if ($balanceAdjustment === 0 && $paidToDateAdjustment === 0) {
@@ -182,11 +271,17 @@ class Client extends EntityModel
$this->save();
}
+ /**
+ * @return string
+ */
public function getRoute()
{
return "/clients/{$this->public_id}";
}
+ /**
+ * @return float|int
+ */
public function getTotalCredit()
{
return DB::table('credits')
@@ -195,11 +290,17 @@ class Client extends EntityModel
->sum('balance');
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
}
+ /**
+ * @return mixed
+ */
public function getPrimaryContact()
{
return $this->contacts()
@@ -207,6 +308,9 @@ class Client extends EntityModel
->first();
}
+ /**
+ * @return mixed|string
+ */
public function getDisplayName()
{
if ($this->name) {
@@ -221,17 +325,26 @@ class Client extends EntityModel
return $contact->getDisplayName();
}
+ /**
+ * @return string
+ */
public function getCityState()
{
$swap = $this->country && $this->country->swap_postal_code;
return Utils::cityStateZip($this->city, $this->state, $this->postal_code, $swap);
}
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_CLIENT;
}
+ /**
+ * @return bool
+ */
public function hasAddress()
{
$fields = [
@@ -252,6 +365,9 @@ class Client extends EntityModel
return false;
}
+ /**
+ * @return string
+ */
public function getDateCreated()
{
if ($this->created_at == '0000-00-00 00:00:00') {
@@ -261,6 +377,9 @@ class Client extends EntityModel
}
}
+ /**
+ * @return bool
+ */
public function getGatewayToken()
{
$accountGateway = $this->account->getGatewayByType(GATEWAY_TYPE_TOKEN);
@@ -272,6 +391,9 @@ class Client extends EntityModel
return AccountGatewayToken::clientAndGateway($this->id, $accountGateway->id)->first();
}
+ /**
+ * @return bool
+ */
public function defaultPaymentMethod()
{
if ($token = $this->getGatewayToken()) {
@@ -281,6 +403,9 @@ class Client extends EntityModel
return false;
}
+ /**
+ * @return bool
+ */
public function autoBillLater()
{
if ($token = $this->getGatewayToken()) {
@@ -294,11 +419,17 @@ class Client extends EntityModel
return false;
}
+ /**
+ * @return mixed
+ */
public function getAmount()
{
return $this->balance + $this->paid_to_date;
}
+ /**
+ * @return mixed
+ */
public function getCurrencyId()
{
if ($this->currency_id) {
@@ -312,6 +443,9 @@ class Client extends EntityModel
return $this->account->currency_id ?: DEFAULT_CURRENCY;
}
+ /**
+ * @return string
+ */
public function getCurrencyCode()
{
if ($this->currency) {
@@ -325,6 +459,10 @@ class Client extends EntityModel
return $this->account->currency ? $this->account->currency->code : 'USD';
}
+ /**
+ * @param $isQuote
+ * @return mixed
+ */
public function getCounter($isQuote)
{
return $isQuote ? $this->quote_number_counter : $this->invoice_number_counter;
@@ -336,6 +474,9 @@ class Client extends EntityModel
$this->save();
}
+ /**
+ * @return bool
+ */
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 1345db9e4bfb..847289a88eb2 100644
--- a/app/Models/Company.php
+++ b/app/Models/Company.php
@@ -3,17 +3,29 @@
use Eloquent;
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class Company
+ */
class Company extends Eloquent
{
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
-
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function accounts()
{
return $this->hasMany('App\Models\Account');
}
-
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function payment()
{
return $this->belongsTo('App\Models\Payment');
diff --git a/app/Models/Contact.php b/app/Models/Contact.php
index 51d84f291150..fbac37117e13 100644
--- a/app/Models/Contact.php
+++ b/app/Models/Contact.php
@@ -1,6 +1,5 @@
belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function getPersonType()
{
return PERSON_CONTACT;
}
+ /**
+ * @return mixed|string
+ */
public function getName()
{
return $this->getDisplayName();
}
+ /**
+ * @return mixed|string
+ */
public function getDisplayName()
{
if ($this->getFullName()) {
@@ -60,15 +101,22 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa
}
}
+ /**
+ * @param $contact_key
+ * @return mixed
+ */
public function getContactKeyAttribute($contact_key)
{
if (empty($contact_key) && $this->id) {
$this->contact_key = $contact_key = str_random(RANDOM_KEY_LENGTH);
- static::where('id', $this->id)->update(array('contact_key' => $contact_key));
+ static::where('id', $this->id)->update(['contact_key' => $contact_key]);
}
return $contact_key;
}
+ /**
+ * @return string
+ */
public function getFullName()
{
if ($this->first_name || $this->last_name) {
@@ -78,6 +126,9 @@ class Contact extends EntityModel implements AuthenticatableContract, CanResetPa
}
}
+ /**
+ * @return string
+ */
public function getLinkAttribute()
{
return \URL::to('client/dashboard/' . $this->contact_key);
diff --git a/app/Models/Country.php b/app/Models/Country.php
index 8a87500e3299..d764a76b30cd 100644
--- a/app/Models/Country.php
+++ b/app/Models/Country.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class Country
+ */
class Country extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @var array
+ */
protected $visible = [
'id',
'name',
@@ -15,11 +24,17 @@ class Country extends Eloquent
'decimal_separator'
];
+ /**
+ * @var array
+ */
protected $casts = [
'swap_postal_code' => 'boolean',
'swap_currency_symbol' => 'boolean',
];
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
diff --git a/app/Models/Credit.php b/app/Models/Credit.php
index 340417e7d424..02a38777509f 100644
--- a/app/Models/Credit.php
+++ b/app/Models/Credit.php
@@ -4,44 +4,75 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use App\Events\CreditWasCreated;
use Laracasts\Presenter\PresentableTrait;
+/**
+ * Class Credit
+ */
class Credit extends EntityModel
{
use SoftDeletes;
use PresentableTrait;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\CreditPresenter';
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return string
+ */
public function getName()
{
return '';
}
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_CREDIT;
}
+ /**
+ * @param $amount
+ * @return mixed
+ */
public function apply($amount)
{
if ($amount > $this->balance) {
diff --git a/app/Models/Currency.php b/app/Models/Currency.php
index eb058aa67497..c4b55a46c257 100644
--- a/app/Models/Currency.php
+++ b/app/Models/Currency.php
@@ -2,14 +2,26 @@
use Eloquent;
+/**
+ * Class Currency
+ */
class Currency extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @var array
+ */
protected $casts = [
'swap_currency_symbol' => 'boolean',
];
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
diff --git a/app/Models/DateFormat.php b/app/Models/DateFormat.php
index 47afafb4cc76..cc421169d2d2 100644
--- a/app/Models/DateFormat.php
+++ b/app/Models/DateFormat.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class DateFormat
+ */
class DateFormat extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return bool|string
+ */
public function __toString()
{
$date = mktime(0, 0, 0, 12, 31, date('Y'));
diff --git a/app/Models/DatetimeFormat.php b/app/Models/DatetimeFormat.php
index 6b7edf85ec63..a7876a29e8f6 100644
--- a/app/Models/DatetimeFormat.php
+++ b/app/Models/DatetimeFormat.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class DatetimeFormat
+ */
class DatetimeFormat extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return bool|string
+ */
public function __toString()
{
$date = mktime(0, 0, 0, 12, 31, date('Y'));
diff --git a/app/Models/Document.php b/app/Models/Document.php
index 81784f6ca892..ebf0855df1b5 100644
--- a/app/Models/Document.php
+++ b/app/Models/Document.php
@@ -2,77 +2,95 @@
use Illuminate\Support\Facades\Storage;
use DB;
-use Auth;
+/**
+ * Class Document
+ */
class Document extends EntityModel
{
+ /**
+ * @var array
+ */
protected $fillable = [
'invoice_id',
'expense_id',
];
- public static $extraExtensions = array(
+ /**
+ * @var array
+ */
+ public static $extraExtensions = [
'jpg' => 'jpeg',
'tif' => 'tiff',
- );
+ ];
- public static $allowedMimes = array(// Used by Dropzone.js; does not affect what the server accepts
+ /**
+ * @var array
+ */
+ public static $allowedMimes = [// Used by Dropzone.js; does not affect what the server accepts
'image/png', 'image/jpeg', 'image/tiff', 'application/pdf', 'image/gif', 'image/vnd.adobe.photoshop', 'text/plain',
'application/msword',
'application/excel', 'application/vnd.ms-excel', 'application/x-excel', 'application/x-msexcel',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/postscript', 'image/svg+xml',
'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.ms-powerpoint',
- );
+ ];
- public static $types = array(
- 'png' => array(
+ /**
+ * @var array
+ */
+ public static $types = [
+ 'png' => [
'mime' => 'image/png',
- ),
- 'ai' => array(
+ ],
+ 'ai' => [
'mime' => 'application/postscript',
- ),
- 'svg' => array(
+ ],
+ 'svg' => [
'mime' => 'image/svg+xml',
- ),
- 'jpeg' => array(
+ ],
+ 'jpeg' => [
'mime' => 'image/jpeg',
- ),
- 'tiff' => array(
+ ],
+ 'tiff' => [
'mime' => 'image/tiff',
- ),
- 'pdf' => array(
+ ],
+ 'pdf' => [
'mime' => 'application/pdf',
- ),
- 'gif' => array(
+ ],
+ 'gif' => [
'mime' => 'image/gif',
- ),
- 'psd' => array(
+ ],
+ 'psd' => [
'mime' => 'image/vnd.adobe.photoshop',
- ),
- 'txt' => array(
+ ],
+ 'txt' => [
'mime' => 'text/plain',
- ),
- 'doc' => array(
+ ],
+ 'doc' => [
'mime' => 'application/msword',
- ),
- 'xls' => array(
+ ],
+ 'xls' => [
'mime' => 'application/vnd.ms-excel',
- ),
- 'ppt' => array(
+ ],
+ 'ppt' => [
'mime' => 'application/vnd.ms-powerpoint',
- ),
- 'xlsx' => array(
+ ],
+ 'xlsx' => [
'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- ),
- 'docx' => array(
+ ],
+ 'docx' => [
'mime' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- ),
- 'pptx' => array(
+ ],
+ 'pptx' => [
'mime' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
- ),
- );
+ ],
+ ];
+ /**
+ * @param array $attributes
+ * @return $this
+ */
public function fill(array $attributes)
{
parent::fill($attributes);
@@ -84,43 +102,74 @@ class Document extends EntityModel
return $this;
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function expense()
{
return $this->belongsTo('App\Models\Expense')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function getDisk(){
return Storage::disk(!empty($this->disk)?$this->disk:env('DOCUMENT_FILESYSTEM', 'documents'));
}
+ /**
+ * @param $value
+ */
public function setDiskAttribute($value)
{
$this->attributes['disk'] = $value?$value:env('DOCUMENT_FILESYSTEM', 'documents');
}
+ /**
+ * @return null|string
+ */
public function getDirectUrl(){
return static::getDirectFileUrl($this->path, $this->getDisk());
}
+ /**
+ * @return null|string
+ */
public function getDirectPreviewUrl(){
return $this->preview?static::getDirectFileUrl($this->preview, $this->getDisk(), true):null;
}
+ /**
+ * @param $path
+ * @param $disk
+ * @param bool $prioritizeSpeed
+ * @return null|string
+ * @throws \OpenCloud\Common\Exceptions\NoNameError
+ */
public static function getDirectFileUrl($path, $disk, $prioritizeSpeed = false){
$adapter = $disk->getAdapter();
$fullPath = $adapter->applyPathPrefix($path);
@@ -156,50 +205,81 @@ class Document extends EntityModel
return null;
}
+ /**
+ * @return mixed
+ */
public function getRaw(){
$disk = $this->getDisk();
return $disk->get($this->path);
}
+ /**
+ * @return mixed
+ */
public function getStream(){
$disk = $this->getDisk();
return $disk->readStream($this->path);
}
+ /**
+ * @return mixed
+ */
public function getRawPreview(){
$disk = $this->getDisk();
return $disk->get($this->preview);
}
+ /**
+ * @return \Illuminate\Contracts\Routing\UrlGenerator|string
+ */
public function getUrl(){
return url('documents/'.$this->public_id.'/'.$this->name);
}
+ /**
+ * @param $invitation
+ * @return \Illuminate\Contracts\Routing\UrlGenerator|string
+ */
public function getClientUrl($invitation){
return url('client/documents/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
}
+ /**
+ * @return bool
+ */
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;
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;
return url('client/documents/js/'.$this->public_id.'/'.$this->name.'.js');
}
+ /**
+ * @return \Illuminate\Contracts\Routing\UrlGenerator|null|string
+ */
public function getPreviewUrl(){
return $this->preview?url('documents/preview/'.$this->public_id.'/'.$this->name.'.'.pathinfo($this->preview, PATHINFO_EXTENSION)):null;
}
+ /**
+ * @return array
+ */
public function toArray()
{
$array = parent::toArray();
@@ -210,6 +290,9 @@ class Document extends EntityModel
return $array;
}
+ /**
+ * @return mixed
+ */
public function cloneDocument(){
$document = Document::createNew($this);
$document->path = $this->path;
diff --git a/app/Models/EntityModel.php b/app/Models/EntityModel.php
index 470284320af4..9e350f9ba8b7 100644
--- a/app/Models/EntityModel.php
+++ b/app/Models/EntityModel.php
@@ -4,13 +4,29 @@ use Auth;
use Eloquent;
use Utils;
+/**
+ * Class EntityModel
+ */
class EntityModel extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @var array
+ */
protected $hidden = ['id'];
+ /**
+ * @var bool
+ */
public static $notifySubscriptions = true;
+ /**
+ * @param null $context
+ * @return mixed
+ */
public static function createNew($context = null)
{
$className = get_called_class();
@@ -52,6 +68,10 @@ class EntityModel extends Eloquent
return $entity;
}
+ /**
+ * @param $publicId
+ * @return mixed
+ */
public static function getPrivateId($publicId)
{
$className = get_called_class();
@@ -59,6 +79,9 @@ class EntityModel extends Eloquent
return $className::scope($publicId)->withTrashed()->value('id');
}
+ /**
+ * @return string
+ */
public function getActivityKey()
{
return '[' . $this->getEntityType().':'.$this->public_id.':'.$this->getDisplayName() . ']';
@@ -76,6 +99,12 @@ class EntityModel extends Eloquent
}
*/
+ /**
+ * @param $query
+ * @param bool $publicId
+ * @param bool $accountId
+ * @return mixed
+ */
public function scopeScope($query, $publicId = false, $accountId = false)
{
if (!$accountId) {
@@ -95,6 +124,10 @@ class EntityModel extends Eloquent
return $query;
}
+ /**
+ * @param $query
+ * @return mixed
+ */
public function scopeViewable($query)
{
if (Auth::check() && ! Auth::user()->hasPermission('view_all')) {
@@ -104,26 +137,44 @@ class EntityModel extends Eloquent
return $query;
}
+ /**
+ * @param $query
+ * @return mixed
+ */
public function scopeWithArchived($query)
{
return $query->withTrashed()->where('is_deleted', '=', false);
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->public_id;
}
+ /**
+ * @return mixed
+ */
public function getDisplayName()
{
return $this->getName();
}
+ /**
+ * @param $entityType
+ * @return string
+ */
public static function getClassName($entityType)
{
return 'App\\Models\\' . ucwords(Utils::toCamelCase($entityType));
}
+ /**
+ * @param $entityType
+ * @return string
+ */
public static function getTransformerName($entityType)
{
return 'App\\Ninja\\Transformers\\' . ucwords(Utils::toCamelCase($entityType)) . 'Transformer';
@@ -139,6 +190,9 @@ class EntityModel extends Eloquent
}
// converts "App\Models\Client" to "client_id"
+ /**
+ * @return string
+ */
public function getKeyField()
{
$class = get_class($this);
diff --git a/app/Models/Expense.php b/app/Models/Expense.php
index 9fcd598261f0..364b5d509687 100644
--- a/app/Models/Expense.php
+++ b/app/Models/Expense.php
@@ -6,15 +6,27 @@ use App\Events\ExpenseWasCreated;
use App\Events\ExpenseWasUpdated;
use App\Events\ExpenseWasDeleted;
+/**
+ * Class Expense
+ */
class Expense extends EntityModel
{
// Expenses
use SoftDeletes;
use PresentableTrait;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\ExpensePresenter';
+ /**
+ * @var array
+ */
protected $fillable = [
'client_id',
'vendor_id',
@@ -28,36 +40,58 @@ class Expense extends EntityModel
'bank_id',
'transaction_id',
];
+
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function vendor()
{
return $this->belongsTo('App\Models\Vendor')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function documents()
{
return $this->hasMany('App\Models\Document')->orderBy('id');
}
+ /**
+ * @return mixed
+ */
public function getName()
{
if($this->expense_number)
@@ -66,31 +100,49 @@ class Expense extends EntityModel
return $this->public_id;
}
+ /**
+ * @return mixed
+ */
public function getDisplayName()
{
return $this->getName();
}
+ /**
+ * @return string
+ */
public function getRoute()
{
return "/expenses/{$this->public_id}";
}
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_EXPENSE;
}
+ /**
+ * @return bool
+ */
public function isExchanged()
{
return $this->invoice_currency_id != $this->expense_currency_id;
}
+ /**
+ * @return float
+ */
public function convertedAmount()
{
return round($this->amount * $this->exchange_rate, 2);
}
+ /**
+ * @return array
+ */
public function toArray()
{
$array = parent::toArray();
@@ -100,6 +152,11 @@ class Expense extends EntityModel
return $array;
}
+ /**
+ * @param $query
+ * @param null $bankdId
+ * @return mixed
+ */
public function scopeBankId($query, $bankdId = null)
{
if ($bankdId) {
diff --git a/app/Models/ExpenseCategory.php b/app/Models/ExpenseCategory.php
index 9c65353ce688..5f479a35d89f 100644
--- a/app/Models/ExpenseCategory.php
+++ b/app/Models/ExpenseCategory.php
@@ -2,16 +2,24 @@
use Illuminate\Database\Eloquent\SoftDeletes;
-
+/**
+ * Class ExpenseCategory
+ */
class ExpenseCategory extends EntityModel
{
// Expense Categories
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $fillable = [
'name',
];
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function expense()
{
return $this->belongsTo('App\Models\Expense');
diff --git a/app/Models/Font.php b/app/Models/Font.php
index b9518a91ba4d..442daeaae269 100644
--- a/app/Models/Font.php
+++ b/app/Models/Font.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class Font
+ */
class Font extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/Frequency.php b/app/Models/Frequency.php
index b4a7b5c339c3..d4072f3b8068 100644
--- a/app/Models/Frequency.php
+++ b/app/Models/Frequency.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class Frequency
+ */
class Frequency extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php
index 49b59d2c050d..27751b7f897f 100644
--- a/app/Models/Gateway.php
+++ b/app/Models/Gateway.php
@@ -4,10 +4,19 @@ use Eloquent;
use Omnipay;
use Utils;
+/**
+ * Class Gateway
+ */
class Gateway extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @var array
+ */
public static $gatewayTypes = [
GATEWAY_TYPE_CREDIT_CARD,
GATEWAY_TYPE_BANK_TRANSFER,
@@ -19,6 +28,9 @@ class Gateway extends Eloquent
// these will appear in the primary gateway select
// the rest are shown when selecting 'more options'
+ /**
+ * @var array
+ */
public static $preferred = [
GATEWAY_PAYPAL_EXPRESS,
GATEWAY_BITPAY,
@@ -31,12 +43,18 @@ class Gateway extends Eloquent
// allow adding these gateway if another gateway
// is already configured
+ /**
+ * @var array
+ */
public static $alternate = [
GATEWAY_PAYPAL_EXPRESS,
GATEWAY_BITPAY,
GATEWAY_DWOLLA,
];
+ /**
+ * @var array
+ */
public static $hiddenFields = [
// PayPal
'headerImageUrl',
@@ -49,6 +67,9 @@ class Gateway extends Eloquent
'returnUrl',
];
+ /**
+ * @var array
+ */
public static $optionalFields = [
// PayPal
'testMode',
@@ -57,21 +78,36 @@ class Gateway extends Eloquent
'sandbox',
];
+ /**
+ * @return string
+ */
public function getLogoUrl()
{
return '/images/gateways/logo_'.$this->provider.'.png';
}
+ /**
+ * @param $gatewayId
+ * @return bool
+ */
public function isGateway($gatewayId)
{
return $this->id == $gatewayId;
}
+ /**
+ * @param $type
+ * @return string
+ */
public static function getPaymentTypeName($type)
{
return Utils::toCamelCase(strtolower(str_replace('PAYMENT_TYPE_', '', $type)));
}
+ /**
+ * @param $gatewayIds
+ * @return int
+ */
public static function hasStandardGateway($gatewayIds)
{
$diff = array_diff($gatewayIds, static::$alternate);
@@ -79,6 +115,10 @@ class Gateway extends Eloquent
return count($diff);
}
+ /**
+ * @param $query
+ * @param $accountGatewaysIds
+ */
public function scopePrimary($query, $accountGatewaysIds)
{
$query->where('payment_library_id', '=', 1)
@@ -87,6 +127,10 @@ class Gateway extends Eloquent
->whereIn('id', $accountGatewaysIds);
}
+ /**
+ * @param $query
+ * @param $accountGatewaysIds
+ */
public function scopeSecondary($query, $accountGatewaysIds)
{
$query->where('payment_library_id', '=', 1)
@@ -95,6 +139,9 @@ class Gateway extends Eloquent
->whereIn('id', $accountGatewaysIds);
}
+ /**
+ * @return string|\Symfony\Component\Translation\TranslatorInterface
+ */
public function getHelp()
{
$link = '';
@@ -119,6 +166,9 @@ class Gateway extends Eloquent
return $key != $str ? $str : '';
}
+ /**
+ * @return mixed
+ */
public function getFields()
{
return Omnipay::create($this->provider)->getDefaultParameters();
diff --git a/app/Models/Industry.php b/app/Models/Industry.php
index fe2d1fa1e2ac..be4920b151c0 100644
--- a/app/Models/Industry.php
+++ b/app/Models/Industry.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class Industry
+ */
class Industry extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php
index 6ea384848f23..58d070141c0f 100644
--- a/app/Models/Invitation.php
+++ b/app/Models/Invitation.php
@@ -4,26 +4,44 @@ use Utils;
use Carbon;
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class Invitation
+ */
class Invitation extends EntityModel
{
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function contact()
{
return $this->belongsTo('App\Models\Contact')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
@@ -31,6 +49,11 @@ class Invitation extends EntityModel
// If we're getting the link for PhantomJS to generate the PDF
// we need to make sure it's served from our site
+ /**
+ * @param string $type
+ * @param bool $forceOnsite
+ * @return string
+ */
public function getLink($type = 'view', $forceOnsite = false)
{
if (!$this->account) {
@@ -51,6 +74,9 @@ class Invitation extends EntityModel
return "{$url}/{$type}/{$this->invitation_key}";
}
+ /**
+ * @return bool|string
+ */
public function getStatus()
{
$hasValue = false;
@@ -70,11 +96,17 @@ class Invitation extends EntityModel
return $hasValue ? implode($parts, '
') : false;
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->invitation_key;
}
+ /**
+ * @param null $messageId
+ */
public function markSent($messageId = null)
{
$this->message_id = $messageId;
diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php
index 5a645b333067..f0cbe2789e74 100644
--- a/app/Models/Invoice.php
+++ b/app/Models/Invoice.php
@@ -2,11 +2,8 @@
use Utils;
use DateTime;
-use URL;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laracasts\Presenter\PresentableTrait;
-use App\Models\BalanceAffecting;
-use App\Models\Client;
use App\Events\QuoteWasCreated;
use App\Events\QuoteWasUpdated;
use App\Events\InvoiceWasCreated;
@@ -14,6 +11,9 @@ use App\Events\InvoiceWasUpdated;
use App\Events\InvoiceInvitationWasEmailed;
use App\Events\QuoteInvitationWasEmailed;
+/**
+ * Class Invoice
+ */
class Invoice extends EntityModel implements BalanceAffecting
{
use PresentableTrait;
@@ -22,9 +22,18 @@ class Invoice extends EntityModel implements BalanceAffecting
SoftDeletes::trashed as parentTrashed;
}
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\InvoicePresenter';
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var array
+ */
protected $fillable = [
'tax_name1',
'tax_rate1',
@@ -32,6 +41,9 @@ class Invoice extends EntityModel implements BalanceAffecting
'tax_rate2',
];
+ /**
+ * @var array
+ */
protected $casts = [
'is_recurring' => 'boolean',
'has_tasks' => 'boolean',
@@ -40,6 +52,9 @@ class Invoice extends EntityModel implements BalanceAffecting
];
// used for custom invoice numbers
+ /**
+ * @var array
+ */
public static $patternFields = [
'counter',
'custom1',
@@ -49,14 +64,38 @@ class Invoice extends EntityModel implements BalanceAffecting
'date:',
];
+ /**
+ * @var string
+ */
public static $fieldInvoiceNumber = 'invoice_number';
+ /**
+ * @var string
+ */
public static $fieldInvoiceDate = 'invoice_date';
+ /**
+ * @var string
+ */
public static $fieldDueDate = 'due_date';
+ /**
+ * @var string
+ */
public static $fieldAmount = 'amount';
+ /**
+ * @var string
+ */
public static $fieldPaid = 'paid';
+ /**
+ * @var string
+ */
public static $fieldNotes = 'notes';
+ /**
+ * @var string
+ */
public static $fieldTerms = 'terms';
+ /**
+ * @return array
+ */
public static function getImportColumns()
{
return [
@@ -71,6 +110,9 @@ class Invoice extends EntityModel implements BalanceAffecting
];
}
+ /**
+ * @return array
+ */
public static function getImportMap()
{
return [
@@ -83,22 +125,35 @@ class Invoice extends EntityModel implements BalanceAffecting
'notes' => 'notes',
];
}
+
+ /**
+ * @return string
+ */
public function getRoute()
{
$entityType = $this->getEntityType();
return "/{$entityType}s/{$this->public_id}/edit";
}
+ /**
+ * @return mixed
+ */
public function getDisplayName()
{
return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number;
}
+ /**
+ * @return bool
+ */
public function affectsBalance()
{
return $this->isType(INVOICE_TYPE_STANDARD) && !$this->is_recurring;
}
+ /**
+ * @return float|int
+ */
public function getAdjustment()
{
if (!$this->affectsBalance()) {
@@ -108,11 +163,17 @@ class Invoice extends EntityModel implements BalanceAffecting
return $this->getRawAdjustment();
}
+ /**
+ * @return float
+ */
private function getRawAdjustment()
{
return floatval($this->amount) - floatval($this->getOriginal('amount'));
}
+ /**
+ * @return bool
+ */
public function isChanged()
{
if ($this->getRawAdjustment() != 0) {
@@ -137,6 +198,10 @@ class Invoice extends EntityModel implements BalanceAffecting
return false;
}
+ /**
+ * @param bool $calculate
+ * @return int|mixed
+ */
public function getAmountPaid($calculate = false)
{
if ($this->isType(INVOICE_TYPE_QUOTE) || $this->is_recurring) {
@@ -154,6 +219,9 @@ class Invoice extends EntityModel implements BalanceAffecting
}
}
+ /**
+ * @return bool
+ */
public function trashed()
{
if ($this->client && $this->client->trashed()) {
@@ -163,96 +231,158 @@ class Invoice extends EntityModel implements BalanceAffecting
return self::parentTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function invoice_items()
{
return $this->hasMany('App\Models\InvoiceItem')->orderBy('id');
}
+ /**
+ * @return mixed
+ */
public function documents()
{
return $this->hasMany('App\Models\Document')->orderBy('id');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function invoice_status()
{
return $this->belongsTo('App\Models\InvoiceStatus');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function invoice_design()
{
return $this->belongsTo('App\Models\InvoiceDesign');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function payments()
{
return $this->hasMany('App\Models\Payment', 'invoice_id', 'id');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function recurring_invoice()
{
return $this->belongsTo('App\Models\Invoice');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function recurring_invoices()
{
return $this->hasMany('App\Models\Invoice', 'recurring_invoice_id');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function frequency()
{
return $this->belongsTo('App\Models\Frequency');
}
+ /**
+ * @return mixed
+ */
public function invitations()
{
return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id');
}
+ /**
+ * @return mixed
+ */
public function expenses()
{
return $this->hasMany('App\Models\Expense','invoice_id','id')->withTrashed();
}
+ /**
+ * @param $query
+ * @return mixed
+ */
public function scopeInvoices($query)
{
return $query->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD)
->where('is_recurring', '=', false);
}
+ /**
+ * @param $query
+ * @return mixed
+ */
public function scopeQuotes($query)
{
return $query->where('invoice_type_id', '=', INVOICE_TYPE_QUOTE)
->where('is_recurring', '=', false);
}
+ /**
+ * @param $query
+ * @param $typeId
+ * @return mixed
+ */
public function scopeInvoiceType($query, $typeId)
{
return $query->where('invoice_type_id', '=', $typeId);
}
+ /**
+ * @param $typeId
+ * @return bool
+ */
public function isType($typeId) {
return $this->invoice_type_id == $typeId;
}
+ /**
+ * @return bool
+ */
public function isQuote() {
return $this->isType(INVOICE_TYPE_QUOTE);
}
+ /**
+ * @param bool $notify
+ */
public function markInvitationsSent($notify = false)
{
foreach ($this->invitations as $invitation) {
@@ -260,6 +390,11 @@ class Invoice extends EntityModel implements BalanceAffecting
}
}
+ /**
+ * @param $invitation
+ * @param bool $messageId
+ * @param bool $notify
+ */
public function markInvitationSent($invitation, $messageId = false, $notify = true)
{
if (!$this->isSent()) {
@@ -290,6 +425,9 @@ class Invoice extends EntityModel implements BalanceAffecting
}
}
+ /**
+ * @param bool $save
+ */
public function updatePaidStatus($save = true)
{
$statusId = false;
@@ -317,6 +455,10 @@ class Invoice extends EntityModel implements BalanceAffecting
}
}
+ /**
+ * @param $balanceAdjustment
+ * @param int $partial
+ */
public function updateBalances($balanceAdjustment, $partial = 0)
{
if ($this->is_deleted) {
@@ -332,57 +474,91 @@ class Invoice extends EntityModel implements BalanceAffecting
$this->save();
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number;
}
+ /**
+ * @return string
+ */
public function getFileName()
{
$entityType = $this->getEntityType();
return trans("texts.$entityType") . '_' . $this->invoice_number . '.pdf';
}
+ /**
+ * @return string
+ */
public function getPDFPath()
{
return storage_path() . '/pdfcache/cache-' . $this->id . '.pdf';
}
+ /**
+ * @param $invoice
+ * @return string
+ */
public static function calcLink($invoice)
{
return link_to('invoices/' . $invoice->public_id, $invoice->invoice_number);
}
+ /**
+ * @return string
+ */
public function getLink()
{
return self::calcLink($this);
}
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return $this->isType(INVOICE_TYPE_QUOTE) ? ENTITY_QUOTE : ENTITY_INVOICE;
}
+ /**
+ * @return bool
+ */
public function isSent()
{
return $this->invoice_status_id >= INVOICE_STATUS_SENT;
}
+ /**
+ * @return bool
+ */
public function isViewed()
{
return $this->invoice_status_id >= INVOICE_STATUS_VIEWED;
}
+ /**
+ * @return bool
+ */
public function isPartial()
{
return $this->invoice_status_id >= INVOICE_STATUS_PARTIAL;
}
+ /**
+ * @return bool
+ */
public function isPaid()
{
return $this->invoice_status_id >= INVOICE_STATUS_PAID;
}
+ /**
+ * @return bool
+ */
public function isOverdue()
{
if ( ! $this->due_date) {
@@ -392,11 +568,17 @@ class Invoice extends EntityModel implements BalanceAffecting
return time() > strtotime($this->due_date);
}
+ /**
+ * @return mixed
+ */
public function getRequestedAmount()
{
return $this->partial > 0 ? $this->partial : $this->balance;
}
+ /**
+ * @return string
+ */
public function getCurrencyCode()
{
if ($this->client->currency) {
@@ -408,6 +590,9 @@ class Invoice extends EntityModel implements BalanceAffecting
}
}
+ /**
+ * @return $this
+ */
public function hidePrivateFields()
{
$this->setVisible([
@@ -551,6 +736,10 @@ class Invoice extends EntityModel implements BalanceAffecting
return $this;
}
+ /**
+ * @return bool|\Recurr\RecurrenceCollection
+ * @throws \Recurr\Exception\MissingData
+ */
public function getSchedule()
{
if (!$this->start_date || !$this->is_recurring || !$this->frequency_id) {
@@ -581,6 +770,9 @@ class Invoice extends EntityModel implements BalanceAffecting
return $dates;
}
+ /**
+ * @return null
+ */
public function getNextSendDate()
{
if ($this->start_date && !$this->last_sent_date) {
@@ -599,6 +791,10 @@ class Invoice extends EntityModel implements BalanceAffecting
return $schedule[1]->getStart();
}
+ /**
+ * @param null $invoice_date
+ * @return mixed|null
+ */
public function getDueDate($invoice_date = null){
if(!$this->is_recurring) {
return $this->due_date ? $this->due_date : null;
@@ -659,8 +855,8 @@ class Invoice extends EntityModel implements BalanceAffecting
$dueDate = mktime(0, 0, 0, $dueMonth, $dueDay, $dueYear);
}
else if($monthVal == 2) {// February; day of week
- $ordinals = array('first', 'second', 'third', 'fourth');
- $daysOfWeek = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
+ $ordinals = ['first', 'second', 'third', 'fourth'];
+ $daysOfWeek = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
$ordinalIndex = ceil($dayVal / 7) - 1;// 1-7 are "first"; 8-14 are "second", etc.
$dayOfWeekIndex = ($dayVal - 1) % 7;// 1,8,15,22 are Sunday, 2,9,16,23 are Monday, etc.
@@ -687,6 +883,11 @@ class Invoice extends EntityModel implements BalanceAffecting
return null;
}
+ /**
+ * @param int $min
+ * @param int $max
+ * @return null
+ */
public function getPrettySchedule($min = 1, $max = 10)
{
if (!$schedule = $this->getSchedule($max)) {
@@ -711,6 +912,9 @@ class Invoice extends EntityModel implements BalanceAffecting
return implode('
', $dates);
}
+ /**
+ * @return string
+ */
private function getRecurrenceRule()
{
$rule = '';
@@ -757,6 +961,9 @@ class Invoice extends EntityModel implements BalanceAffecting
}
*/
+ /**
+ * @return bool
+ */
public function shouldSendToday()
{
if (!$this->start_date || strtotime($this->start_date) > strtotime('now')) {
@@ -779,7 +986,7 @@ class Invoice extends EntityModel implements BalanceAffecting
$date1 = new DateTime($this->last_sent_date);
$date2 = new DateTime();
$diff = $date2->diff($date1);
- $daysSinceLastSent = $diff->format("%a");
+ $daysSinceLastSent = $diff->format('%a');
$monthsSinceLastSent = ($diff->format('%y') * 12) + $diff->format('%m');
if ($daysSinceLastSent == 0) {
@@ -809,6 +1016,9 @@ class Invoice extends EntityModel implements BalanceAffecting
return false;
}
+ /**
+ * @return bool|string
+ */
public function getPDFString()
{
if (!env('PHANTOMJS_CLOUD_KEY')) {
@@ -836,6 +1046,11 @@ class Invoice extends EntityModel implements BalanceAffecting
return Utils::decodePDF($pdfString);
}
+ /**
+ * @param $invoiceItem
+ * @param $invoiceTotal
+ * @return float|int
+ */
public function getItemTaxable($invoiceItem, $invoiceTotal)
{
$total = $invoiceItem->qty * $invoiceItem->cost;
@@ -852,6 +1067,9 @@ class Invoice extends EntityModel implements BalanceAffecting
return $total;
}
+ /**
+ * @return float|int|mixed
+ */
public function getTaxable()
{
$total = 0;
@@ -882,6 +1100,10 @@ class Invoice extends EntityModel implements BalanceAffecting
// if $calculatePaid is true we'll loop through each payment to
// determine the sum, otherwise we'll use the cached paid_to_date amount
+ /**
+ * @param bool $calculatePaid
+ * @return array
+ */
public function getTaxes($calculatePaid = false)
{
$taxes = [];
@@ -919,6 +1141,13 @@ class Invoice extends EntityModel implements BalanceAffecting
return $taxes;
}
+ /**
+ * @param $taxes
+ * @param $name
+ * @param $rate
+ * @param $amount
+ * @param $paid
+ */
private function calculateTax(&$taxes, $name, $rate, $amount, $paid)
{
if ( ! $amount) {
@@ -942,11 +1171,17 @@ class Invoice extends EntityModel implements BalanceAffecting
$taxes[$key]['paid'] += $paid;
}
+ /**
+ * @return bool
+ */
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;
@@ -954,6 +1189,9 @@ class Invoice extends EntityModel implements BalanceAffecting
return false;
}
+ /**
+ * @return bool
+ */
public function getAutoBillEnabled() {
if (!$this->is_recurring) {
$recurInvoice = $this->recurring_invoice;
diff --git a/app/Models/InvoiceDesign.php b/app/Models/InvoiceDesign.php
index 51f15b035ad6..c89c14f38f2c 100644
--- a/app/Models/InvoiceDesign.php
+++ b/app/Models/InvoiceDesign.php
@@ -3,12 +3,20 @@
use Eloquent;
use Auth;
use Cache;
-use App\Models\InvoiceDesign;
+/**
+ * Class InvoiceDesign
+ */
class InvoiceDesign extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return mixed
+ */
public static function getDesigns()
{
$account = Auth::user()->account;
diff --git a/app/Models/InvoiceItem.php b/app/Models/InvoiceItem.php
index e80482bafdb8..6598a24bed76 100644
--- a/app/Models/InvoiceItem.php
+++ b/app/Models/InvoiceItem.php
@@ -2,11 +2,20 @@
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class InvoiceItem
+ */
class InvoiceItem extends EntityModel
{
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var array
+ */
protected $fillable = [
'tax_name1',
'tax_rate1',
@@ -14,21 +23,33 @@ class InvoiceItem extends EntityModel
'tax_rate2',
];
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function product()
{
return $this->belongsTo('App\Models\Product');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
diff --git a/app/Models/InvoiceStatus.php b/app/Models/InvoiceStatus.php
index 36164d26c6c0..24948f845127 100644
--- a/app/Models/InvoiceStatus.php
+++ b/app/Models/InvoiceStatus.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class InvoiceStatus
+ */
class InvoiceStatus extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/Language.php b/app/Models/Language.php
index 084c2fe86da7..efce90844fea 100644
--- a/app/Models/Language.php
+++ b/app/Models/Language.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class Language
+ */
class Language extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
diff --git a/app/Models/License.php b/app/Models/License.php
index 93898f8d7d18..39b82b7ecc83 100644
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@ -3,9 +3,18 @@
use Eloquent;
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class License
+ */
class License extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = true;
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
}
diff --git a/app/Models/OwnedByClientTrait.php b/app/Models/OwnedByClientTrait.php
index 7f11448324b9..dc6e6208aea7 100644
--- a/app/Models/OwnedByClientTrait.php
+++ b/app/Models/OwnedByClientTrait.php
@@ -1,7 +1,13 @@
client) {
diff --git a/app/Models/Payment.php b/app/Models/Payment.php
index 8e496c602a33..c6aa790fac0f 100644
--- a/app/Models/Payment.php
+++ b/app/Models/Payment.php
@@ -6,69 +6,109 @@ use App\Events\PaymentWasCreated;
use App\Events\PaymentWasRefunded;
use App\Events\PaymentWasVoided;
use App\Events\PaymentCompleted;
-use App\Events\PaymentVoided;
use App\Events\PaymentFailed;
-use App\Models\PaymentMethod;
use Laracasts\Presenter\PresentableTrait;
+/**
+ * Class Payment
+ */
class Payment extends EntityModel
{
use PresentableTrait;
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\PaymentPresenter';
+ /**
+ * @return mixed
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function invitation()
{
return $this->belongsTo('App\Models\Invitation');
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function contact()
{
return $this->belongsTo('App\Models\Contact');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account_gateway()
{
return $this->belongsTo('App\Models\AccountGateway');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function payment_type()
{
return $this->belongsTo('App\Models\PaymentType');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function payment_method()
{
return $this->belongsTo('App\Models\PaymentMethod');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function payment_status()
{
return $this->belongsTo('App\Models\PaymentStatus');
}
+ /**
+ * @return string
+ */
public function getRoute()
{
return "/payments/{$this->public_id}/edit";
@@ -81,41 +121,66 @@ class Payment extends EntityModel
}
*/
+ /**
+ * @return mixed
+ */
public function getName()
{
return trim("payment {$this->transaction_reference}");
}
+ /**
+ * @return bool
+ */
public function isPending()
{
return $this->payment_status_id == PAYMENT_STATUS_PENDING;
}
+ /**
+ * @return bool
+ */
public function isFailed()
{
return $this->payment_status_id == PAYMENT_STATUS_FAILED;
}
+ /**
+ * @return bool
+ */
public function isCompleted()
{
return $this->payment_status_id == PAYMENT_STATUS_COMPLETED;
}
+ /**
+ * @return bool
+ */
public function isPartiallyRefunded()
{
return $this->payment_status_id == PAYMENT_STATUS_PARTIALLY_REFUNDED;
}
+ /**
+ * @return bool
+ */
public function isRefunded()
{
return $this->payment_status_id == PAYMENT_STATUS_REFUNDED;
}
+ /**
+ * @return bool
+ */
public function isVoided()
{
return $this->payment_status_id == PAYMENT_STATUS_VOIDED;
}
+ /**
+ * @param null $amount
+ * @return bool
+ */
public function recordRefund($amount = null)
{
if ($this->isRefunded() || $this->isVoided()) {
@@ -140,6 +205,9 @@ class Payment extends EntityModel
return true;
}
+ /**
+ * @return bool
+ */
public function markVoided()
{
if ($this->isVoided() || $this->isPartiallyRefunded() || $this->isRefunded()) {
@@ -162,6 +230,9 @@ class Payment extends EntityModel
Event::fire(new PaymentCompleted($this));
}
+ /**
+ * @param string $failureMessage
+ */
public function markFailed($failureMessage = '')
{
$this->payment_status_id = PAYMENT_STATUS_FAILED;
@@ -170,16 +241,25 @@ class Payment extends EntityModel
Event::fire(new PaymentFailed($this));
}
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_PAYMENT;
}
+ /**
+ * @return mixed
+ */
public function getCompletedAmount()
{
return $this->amount - $this->refunded;
}
+ /**
+ * @return mixed|null|\stdClass|string
+ */
public function getBankDataAttribute()
{
if (!$this->routing_number) {
@@ -188,6 +268,10 @@ class Payment extends EntityModel
return PaymentMethod::lookupBankData($this->routing_number);
}
+ /**
+ * @param $bank_name
+ * @return null
+ */
public function getBankNameAttribute($bank_name)
{
if ($bank_name) {
@@ -198,6 +282,10 @@ class Payment extends EntityModel
return $bankData?$bankData->name:null;
}
+ /**
+ * @param $value
+ * @return null|string
+ */
public function getLast4Attribute($value)
{
return $value ? str_pad($value, 4, '0', STR_PAD_LEFT) : null;
diff --git a/app/Models/PaymentLibrary.php b/app/Models/PaymentLibrary.php
index 3f0f5c860d86..d9445015d2b3 100644
--- a/app/Models/PaymentLibrary.php
+++ b/app/Models/PaymentLibrary.php
@@ -2,11 +2,23 @@
use Eloquent;
+/**
+ * Class PaymentLibrary
+ */
class PaymentLibrary extends Eloquent
{
+ /**
+ * @var string
+ */
protected $table = 'payment_libraries';
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function gateways()
{
return $this->hasMany('App\Models\Gateway', 'payment_library_id');
diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php
index f35631aafd8a..1a0f865be141 100644
--- a/app/Models/PaymentMethod.php
+++ b/app/Models/PaymentMethod.php
@@ -1,48 +1,80 @@
belongsTo('App\Models\Account');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function contact()
{
return $this->belongsTo('App\Models\Contact');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account_gateway_token()
{
return $this->belongsTo('App\Models\AccountGatewayToken');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function payment_type()
{
return $this->belongsTo('App\Models\PaymentType');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function currency()
{
return $this->belongsTo('App\Models\Currency');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function payments()
{
return $this->hasMany('App\Models\Payments');
}
+ /**
+ * @return mixed|null|\stdClass|string
+ */
public function getBankDataAttribute()
{
if (!$this->routing_number) {
@@ -51,6 +83,10 @@ class PaymentMethod extends EntityModel
return static::lookupBankData($this->routing_number);
}
+ /**
+ * @param $bank_name
+ * @return null
+ */
public function getBankNameAttribute($bank_name)
{
if ($bank_name) {
@@ -61,11 +97,20 @@ class PaymentMethod extends EntityModel
return $bankData?$bankData->name:null;
}
+ /**
+ * @param $value
+ * @return null|string
+ */
public function getLast4Attribute($value)
{
return $value ? str_pad($value, 4, '0', STR_PAD_LEFT) : null;
}
+ /**
+ * @param $query
+ * @param $clientId
+ * @return mixed
+ */
public function scopeClientId($query, $clientId)
{
return $query->with(['contact' => function($query) use ($clientId) {
@@ -73,6 +118,10 @@ class PaymentMethod extends EntityModel
}]);
}
+ /**
+ * @param $query
+ * @param $isBank
+ */
public function scopeIsBankAccount($query, $isBank)
{
if ($isBank) {
@@ -82,11 +131,18 @@ class PaymentMethod extends EntityModel
}
}
+ /**
+ * @return \Illuminate\Contracts\Routing\UrlGenerator|string
+ */
public function imageUrl()
{
return url(sprintf('/images/credit_cards/%s.png', str_replace(' ', '', strtolower($this->payment_type->name))));
}
+ /**
+ * @param $routingNumber
+ * @return mixed|null|\stdClass|string
+ */
public static function lookupBankData($routingNumber) {
$cached = Cache::get('bankData:'.$routingNumber);
@@ -149,11 +205,17 @@ class PaymentMethod extends EntityModel
}
}
+ /**
+ * @return bool
+ */
public function requiresDelayedAutoBill()
{
return $this->payment_type_id == PAYMENT_TYPE_ACH;
}
+ /**
+ * @return mixed
+ */
public function gatewayType()
{
if ($this->payment_type_id == PAYMENT_TYPE_ACH) {
diff --git a/app/Models/PaymentStatus.php b/app/Models/PaymentStatus.php
index fdb1e0f43d5b..d4c06899e56e 100644
--- a/app/Models/PaymentStatus.php
+++ b/app/Models/PaymentStatus.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class PaymentStatus
+ */
class PaymentStatus extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/PaymentTerm.php b/app/Models/PaymentTerm.php
index c5e85668f84f..1c3397a5ab22 100644
--- a/app/Models/PaymentTerm.php
+++ b/app/Models/PaymentTerm.php
@@ -2,13 +2,25 @@
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class PaymentTerm
+ */
class PaymentTerm extends EntityModel
{
//use SoftDeletes;
-
+
+ /**
+ * @var bool
+ */
public $timestamps = true;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @return mixed
+ */
public function getEntityType()
{
return ENTITY_PAYMENT_TERM;
diff --git a/app/Models/PaymentType.php b/app/Models/PaymentType.php
index f7c0ecd36d79..01e96239fde0 100644
--- a/app/Models/PaymentType.php
+++ b/app/Models/PaymentType.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class PaymentType
+ */
class PaymentType extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/Product.php b/app/Models/Product.php
index 548d7b384521..ba22c58339e2 100644
--- a/app/Models/Product.php
+++ b/app/Models/Product.php
@@ -1,13 +1,21 @@
where('product_key', '=', $key)->first();
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function default_tax_rate()
{
return $this->belongsTo('App\Models\TaxRate');
diff --git a/app/Models/Size.php b/app/Models/Size.php
index 99d1b12f5d0c..16526d83f046 100644
--- a/app/Models/Size.php
+++ b/app/Models/Size.php
@@ -2,10 +2,19 @@
use Eloquent;
+/**
+ * Class Size
+ */
class Size extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
diff --git a/app/Models/Subscription.php b/app/Models/Subscription.php
index 3592ac81490a..d4e064068276 100644
--- a/app/Models/Subscription.php
+++ b/app/Models/Subscription.php
@@ -1,12 +1,20 @@
belongsTo('App\Models\Account');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function invoice()
{
return $this->belongsTo('App\Models\Invoice');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function client()
{
return $this->belongsTo('App\Models\Client')->withTrashed();
}
+ /**
+ * @param $task
+ * @return string
+ */
public static function calcStartTime($task)
{
$parts = json_decode($task->time_log) ?: [];
@@ -43,11 +64,18 @@ class Task extends EntityModel
}
}
+ /**
+ * @return string
+ */
public function getStartTime()
{
return self::calcStartTime($this);
}
+ /**
+ * @param $task
+ * @return int
+ */
public static function calcDuration($task)
{
$duration = 0;
@@ -64,11 +92,17 @@ class Task extends EntityModel
return $duration;
}
+ /**
+ * @return int
+ */
public function getDuration()
{
return self::calcDuration($this);
}
+ /**
+ * @return int
+ */
public function getCurrentDuration()
{
$parts = json_decode($this->time_log) ?: [];
@@ -81,12 +115,18 @@ class Task extends EntityModel
}
}
+ /**
+ * @return bool
+ */
public function hasPreviousDuration()
{
$parts = json_decode($this->time_log) ?: [];
return count($parts) && (count($parts[0]) && $parts[0][1]);
}
+ /**
+ * @return float
+ */
public function getHours()
{
return round($this->getDuration() / (60 * 60), 2);
diff --git a/app/Models/TaxRate.php b/app/Models/TaxRate.php
index 384ccf933b36..a69b6a563761 100644
--- a/app/Models/TaxRate.php
+++ b/app/Models/TaxRate.php
@@ -1,23 +1,37 @@
belongsTo('App\Models\User')->withTrashed();
diff --git a/app/Models/Theme.php b/app/Models/Theme.php
index d9a4d2419d2d..3cb2255a7e3a 100644
--- a/app/Models/Theme.php
+++ b/app/Models/Theme.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class Theme
+ */
class Theme extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/Timezone.php b/app/Models/Timezone.php
index 5c00fd12da61..20c4479c8b3a 100644
--- a/app/Models/Timezone.php
+++ b/app/Models/Timezone.php
@@ -2,7 +2,13 @@
use Eloquent;
+/**
+ * Class Timezone
+ */
class Timezone extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 96cb7bc1191e..68a3d1470f6f 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -1,7 +1,6 @@
0b0001,
'view_all' => 0b0010,
'edit_all' => 0b0100,
- );
+ ];
use Authenticatable, Authorizable, CanResetPassword;
@@ -52,28 +57,46 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $hidden = ['password', 'remember_token', 'confirmation_code'];
use SoftDeletes;
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function theme()
{
return $this->belongsTo('App\Models\Theme');
}
+ /**
+ * @param $value
+ */
public function setEmailAttribute($value)
{
$this->attributes['email'] = $this->attributes['username'] = $value;
}
+ /**
+ * @return mixed|string
+ */
public function getName()
{
return $this->getDisplayName();
}
+ /**
+ * @return mixed
+ */
public function getPersonType()
{
return PERSON_USER;
@@ -109,36 +132,59 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
return $this->email;
}
+ /**
+ * @return mixed
+ */
public function isPro()
{
return $this->account->isPro();
}
+ /**
+ * @param $feature
+ * @return mixed
+ */
public function hasFeature($feature)
{
return $this->account->hasFeature($feature);
}
+ /**
+ * @return bool
+ */
public function isPaidPro()
{
return $this->isPro($accountDetails) && !$accountDetails['trial'];
}
+ /**
+ * @return mixed
+ */
public function isTrial()
{
return $this->account->isTrial();
}
+ /**
+ * @param null $plan
+ * @return mixed
+ */
public function isEligibleForTrial($plan = null)
{
return $this->account->isEligibleForTrial($plan);
}
+ /**
+ * @return int
+ */
public function maxInvoiceDesignId()
{
return $this->hasFeature(FEATURE_MORE_INVOICE_DESIGNS) ? 11 : (Utils::isNinja() ? COUNT_FREE_DESIGNS : COUNT_FREE_DESIGNS_SELF_HOST);
}
+ /**
+ * @return mixed|string
+ */
public function getDisplayName()
{
if ($this->getFullName()) {
@@ -150,6 +196,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
+ /**
+ * @return string
+ */
public function getFullName()
{
if ($this->first_name || $this->last_name) {
@@ -159,16 +208,27 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
+ /**
+ * @return bool
+ */
public function showGreyBackground()
{
return !$this->theme_id || in_array($this->theme_id, [2, 3, 5, 6, 7, 8, 10, 11, 12]);
}
+ /**
+ * @return mixed
+ */
public function getRequestsCount()
{
return Session::get(SESSION_COUNTER, 0);
}
+ /**
+ * @param bool $success
+ * @param bool $forced
+ * @return bool
+ */
public function afterSave($success = true, $forced = false)
{
if ($this->email) {
@@ -178,6 +238,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
+ /**
+ * @return mixed
+ */
public function getMaxNumClients()
{
if ($this->hasFeature(FEATURE_MORE_CLIENTS)) {
@@ -191,6 +254,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
return MAX_NUM_CLIENTS;
}
+ /**
+ * @return mixed
+ */
public function getMaxNumVendors()
{
if ($this->hasFeature(FEATURE_MORE_CLIENTS)) {
@@ -201,16 +267,25 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
+ /**
+ * @return mixed
+ */
public function getRememberToken()
{
return $this->remember_token;
}
+ /**
+ * @param string $value
+ */
public function setRememberToken($value)
{
$this->remember_token = $value;
}
+ /**
+ * @return string
+ */
public function getRememberTokenName()
{
return 'remember_token';
@@ -234,6 +309,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
+ /**
+ * @param $user
+ */
public static function onUpdatingUser($user)
{
if ($user->password != $user->getOriginal('password')) {
@@ -247,6 +325,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
}
}
+ /**
+ * @param $user
+ */
public static function onUpdatedUser($user)
{
if (!$user->getOriginal('email')
@@ -259,6 +340,9 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
event(new UserSettingsChanged($user));
}
+ /**
+ * @return bool
+ */
public function isEmailBeingChanged()
{
return Utils::isNinjaProd()
@@ -299,7 +383,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
* @return mixed
*/
protected function getPermissionsAttribute($value){
- $permissions = array();
+ $permissions = [];
foreach(static::$all_permissions as $permission => $bitmask){
if(($value & $bitmask) == $bitmask) {
$permissions[$permission] = $permission;
@@ -332,10 +416,17 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
return false;
}
+ /**
+ * @param $entity
+ * @return bool
+ */
public function owns($entity) {
return !empty($entity->user_id) && $entity->user_id == $this->id;
}
+ /**
+ * @return bool|mixed
+ */
public function filterId() {
return $this->hasPermission('view_all') ? false : $this->id;
}
diff --git a/app/Models/UserAccount.php b/app/Models/UserAccount.php
index a1cd15f89b2d..63200eb25f07 100644
--- a/app/Models/UserAccount.php
+++ b/app/Models/UserAccount.php
@@ -2,10 +2,20 @@
use Eloquent;
+/**
+ * Class UserAccount
+ */
class UserAccount extends Eloquent
{
+ /**
+ * @var bool
+ */
public $timestamps = false;
+ /**
+ * @param $userId
+ * @return bool
+ */
public function hasUserId($userId)
{
if (!$userId) {
@@ -21,6 +31,9 @@ class UserAccount extends Eloquent
return false;
}
+ /**
+ * @param $userId
+ */
public function setUserId($userId)
{
if (self::hasUserId($userId)) {
@@ -36,6 +49,9 @@ class UserAccount extends Eloquent
}
}
+ /**
+ * @param $userId
+ */
public function removeUserId($userId)
{
if (!$userId || !self::hasUserId($userId)) {
diff --git a/app/Models/Vendor.php b/app/Models/Vendor.php
index d537b1ca9d00..6a387e924605 100644
--- a/app/Models/Vendor.php
+++ b/app/Models/Vendor.php
@@ -2,20 +2,31 @@
use Utils;
use DB;
-use Carbon;
use App\Events\VendorWasCreated;
use App\Events\VendorWasUpdated;
use App\Events\VendorWasDeleted;
use Laracasts\Presenter\PresentableTrait;
use Illuminate\Database\Eloquent\SoftDeletes;
+/**
+ * Class Vendor
+ */
class Vendor extends EntityModel
{
use PresentableTrait;
use SoftDeletes;
+ /**
+ * @var string
+ */
protected $presenter = 'App\Ninja\Presenters\VendorPresenter';
+ /**
+ * @var array
+ */
protected $dates = ['deleted_at'];
+ /**
+ * @var array
+ */
protected $fillable = [
'name',
'id_number',
@@ -33,16 +44,46 @@ class Vendor extends EntityModel
'transaction_name',
];
+ /**
+ * @var string
+ */
public static $fieldName = 'name';
+ /**
+ * @var string
+ */
public static $fieldPhone = 'work_phone';
+ /**
+ * @var string
+ */
public static $fieldAddress1 = 'address1';
+ /**
+ * @var string
+ */
public static $fieldAddress2 = 'address2';
+ /**
+ * @var string
+ */
public static $fieldCity = 'city';
+ /**
+ * @var string
+ */
public static $fieldState = 'state';
+ /**
+ * @var string
+ */
public static $fieldPostalCode = 'postal_code';
+ /**
+ * @var string
+ */
public static $fieldNotes = 'notes';
+ /**
+ * @var string
+ */
public static $fieldCountry = 'country';
+ /**
+ * @return array
+ */
public static function getImportColumns()
{
return [
@@ -62,6 +103,9 @@ class Vendor extends EntityModel
];
}
+ /**
+ * @return array
+ */
public static function getImportMap()
{
return [
@@ -80,56 +124,91 @@ class Vendor extends EntityModel
];
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function account()
{
return $this->belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function payments()
{
return $this->hasMany('App\Models\Payment');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function vendor_contacts()
{
return $this->hasMany('App\Models\VendorContact');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function country()
{
return $this->belongsTo('App\Models\Country');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function currency()
{
return $this->belongsTo('App\Models\Currency');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function language()
{
return $this->belongsTo('App\Models\Language');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function size()
{
return $this->belongsTo('App\Models\Size');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+ */
public function industry()
{
return $this->belongsTo('App\Models\Industry');
}
+ /**
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ */
public function expenses()
{
return $this->hasMany('App\Models\Expense','vendor_id','id');
}
+ /**
+ * @param $data
+ * @param bool $isPrimary
+ * @return \Illuminate\Database\Eloquent\Model
+ */
public function addVendorContact($data, $isPrimary = false)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
@@ -146,32 +225,50 @@ class Vendor extends EntityModel
return $this->vendor_contacts()->save($contact);
}
+ /**
+ * @return string
+ */
public function getRoute()
{
return "/vendors/{$this->public_id}";
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->name;
}
+ /**
+ * @return mixed
+ */
public function getDisplayName()
{
return $this->getName();
}
+ /**
+ * @return string
+ */
public function getCityState()
{
$swap = $this->country && $this->country->swap_postal_code;
return Utils::cityStateZip($this->city, $this->state, $this->postal_code, $swap);
}
+ /**
+ * @return string
+ */
public function getEntityType()
{
return 'vendor';
}
+ /**
+ * @return bool
+ */
public function hasAddress()
{
$fields = [
@@ -192,6 +289,9 @@ class Vendor extends EntityModel
return false;
}
+ /**
+ * @return string
+ */
public function getDateCreated()
{
if ($this->created_at == '0000-00-00 00:00:00') {
@@ -201,6 +301,9 @@ class Vendor extends EntityModel
}
}
+ /**
+ * @return mixed
+ */
public function getCurrencyId()
{
if ($this->currency_id) {
@@ -214,6 +317,9 @@ class Vendor extends EntityModel
return $this->account->currency_id ?: DEFAULT_CURRENCY;
}
+ /**
+ * @return float|int
+ */
public function getTotalExpense()
{
return DB::table('expenses')
diff --git a/app/Models/VendorContact.php b/app/Models/VendorContact.php
index 6b2ad12c8025..abcf4f097fe9 100644
--- a/app/Models/VendorContact.php
+++ b/app/Models/VendorContact.php
@@ -1,15 +1,26 @@
belongsTo('App\Models\Account');
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->belongsTo('App\Models\User')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function vendor()
{
return $this->belongsTo('App\Models\Vendor')->withTrashed();
}
+ /**
+ * @return mixed
+ */
public function getPersonType()
{
return PERSON_VENDOR_CONTACT;
}
+ /**
+ * @return mixed|string
+ */
public function getName()
{
return $this->getDisplayName();
}
+ /**
+ * @return mixed|string
+ */
public function getDisplayName()
{
if ($this->getFullName()) {
@@ -57,6 +98,9 @@ class VendorContact extends EntityModel
}
}
+ /**
+ * @return string
+ */
public function getFullName()
{
if ($this->first_name || $this->last_name) {
diff --git a/app/Ninja/Datatables/AccountGatewayDatatable.php b/app/Ninja/Datatables/AccountGatewayDatatable.php
index 5d873b91de6b..5c7a84d3ea1c 100644
--- a/app/Ninja/Datatables/AccountGatewayDatatable.php
+++ b/app/Ninja/Datatables/AccountGatewayDatatable.php
@@ -1,10 +1,6 @@
state)?$config->state:null;
$linkText = $model->name;
$url = $endpoint.'account/'.$wepayAccountId;
- $html = link_to($url, $linkText, array('target'=>'_blank'))->toHtml();
+ $html = link_to($url, $linkText, ['target'=>'_blank'])->toHtml();
try {
if ($wepayState == 'action_required') {
@@ -84,10 +80,10 @@ class AccountGatewayDatatable extends EntityDatatable
function ($model) {
$accountGateway = AccountGateway::find($model->id);
$endpoint = WEPAY_ENVIRONMENT == WEPAY_STAGE ? 'https://stage.wepay.com/' : 'https://www.wepay.com/';
- return array(
+ return [
'url' => $endpoint.'account/'.$accountGateway->getConfig()->accountId,
'attributes' => 'target="_blank"'
- );
+ ];
},
function($model) {
return !$model->deleted_at && $model->gateway_id == GATEWAY_WEPAY;
diff --git a/app/Ninja/Datatables/ActivityDatatable.php b/app/Ninja/Datatables/ActivityDatatable.php
index 5f74bbbe54fb..cb87c26ae680 100644
--- a/app/Ninja/Datatables/ActivityDatatable.php
+++ b/app/Ninja/Datatables/ActivityDatatable.php
@@ -1,8 +1,6 @@
public_id}");
}
@@ -108,7 +108,7 @@ class InvoiceDatatable extends EntityDatatable
}
],
[
- trans("texts.mark_sent"),
+ trans('texts.mark_sent'),
function ($model) {
return "javascript:markEntity({$model->public_id})";
},
@@ -126,7 +126,7 @@ class InvoiceDatatable extends EntityDatatable
}
],
[
- trans("texts.view_quote"),
+ trans('texts.view_quote'),
function ($model) {
return URL::to("quotes/{$model->quote_id}/edit");
},
@@ -135,7 +135,7 @@ class InvoiceDatatable extends EntityDatatable
}
],
[
- trans("texts.view_invoice"),
+ trans('texts.view_invoice'),
function ($model) {
return URL::to("invoices/{$model->quote_invoice_id}/edit");
},
@@ -144,7 +144,7 @@ class InvoiceDatatable extends EntityDatatable
}
],
[
- trans("texts.convert_to_invoice"),
+ trans('texts.convert_to_invoice'),
function ($model) {
return "javascript:convertEntity({$model->public_id})";
},
@@ -161,13 +161,13 @@ class InvoiceDatatable extends EntityDatatable
// check if invoice is overdue
if (Utils::parseFloat($model->balance) && $model->due_date && $model->due_date != '0000-00-00') {
- if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime("now")) {
+ if (\DateTime::createFromFormat('Y-m-d', $model->due_date) < new \DateTime('now')) {
$label = $entityType == ENTITY_INVOICE ? trans('texts.overdue') : trans('texts.expired');
- return "" . $label . "
";
+ return '' . $label . '
';
}
}
- $label = trans("texts.status_" . strtolower($model->invoice_status_name));
+ $label = trans('texts.status_' . strtolower($model->invoice_status_name));
$class = 'default';
switch ($model->invoice_status_id) {
case INVOICE_STATUS_SENT:
diff --git a/app/Ninja/Datatables/PaymentDatatable.php b/app/Ninja/Datatables/PaymentDatatable.php
index 6c9cbb0cba2e..20f2cd025892 100644
--- a/app/Ninja/Datatables/PaymentDatatable.php
+++ b/app/Ninja/Datatables/PaymentDatatable.php
@@ -3,18 +3,17 @@
use Utils;
use URL;
use Auth;
-
use App\Models\PaymentMethod;
class PaymentDatatable extends EntityDatatable
{
public $entityType = ENTITY_PAYMENT;
- protected static $refundableGateways = array(
+ protected static $refundableGateways = [
GATEWAY_STRIPE,
GATEWAY_BRAINTREE,
GATEWAY_WEPAY,
- );
+ ];
public function columns()
{
@@ -56,7 +55,7 @@ class PaymentDatatable extends EntityDatatable
'source',
function ($model) {
$code = str_replace(' ', '', strtolower($model->payment_type));
- $card_type = trans("texts.card_" . $code);
+ $card_type = trans('texts.card_' . $code);
if ($model->payment_type_id != PAYMENT_TYPE_ACH) {
if($model->last4) {
$expiration = Utils::fromSqlDate($model->expiration, false)->format('m/y');
@@ -137,7 +136,7 @@ class PaymentDatatable extends EntityDatatable
private function getStatusLabel($model)
{
- $label = trans("texts.status_" . strtolower($model->payment_status_name));
+ $label = trans('texts.status_' . strtolower($model->payment_status_name));
$class = 'default';
switch ($model->payment_status_id) {
case PAYMENT_STATUS_PENDING:
diff --git a/app/Ninja/Datatables/TaskDatatable.php b/app/Ninja/Datatables/TaskDatatable.php
index 6f460b418e86..6cf71ce1a874 100644
--- a/app/Ninja/Datatables/TaskDatatable.php
+++ b/app/Ninja/Datatables/TaskDatatable.php
@@ -3,7 +3,6 @@
use Utils;
use URL;
use Auth;
-
use App\Models\Task;
class TaskDatatable extends EntityDatatable
diff --git a/app/Ninja/Datatables/TaxRateDatatable.php b/app/Ninja/Datatables/TaxRateDatatable.php
index d6cb0cb54f03..3e16aba9ee19 100644
--- a/app/Ninja/Datatables/TaxRateDatatable.php
+++ b/app/Ninja/Datatables/TaxRateDatatable.php
@@ -1,8 +1,6 @@
maps = $maps;
}
+ /**
+ * @param $name
+ * @return bool
+ */
protected function hasClient($name)
{
$name = trim(strtolower($name));
return isset($this->maps[ENTITY_CLIENT][$name]);
}
+ /**
+ * @param $key
+ * @return bool
+ */
protected function hasProduct($key)
{
$key = trim(strtolower($key));
return isset($this->maps[ENTITY_PRODUCT][$key]);
}
+ /**
+ * @param $data
+ * @param $field
+ * @return string
+ */
protected function getString($data, $field)
{
return (isset($data->$field) && $data->$field) ? $data->$field : '';
}
+ /**
+ * @param $data
+ * @param $field
+ * @return int
+ */
protected function getNumber($data, $field)
{
return (isset($data->$field) && $data->$field) ? $data->$field : 0;
}
+ /**
+ * @param $name
+ * @return null
+ */
protected function getClientId($name)
{
$name = strtolower($name);
return isset($this->maps[ENTITY_CLIENT][$name]) ? $this->maps[ENTITY_CLIENT][$name] : null;
}
+ /**
+ * @param $name
+ * @return null
+ */
protected function getProductId($name)
{
$name = strtolower($name);
return isset($this->maps[ENTITY_PRODUCT][$name]) ? $this->maps[ENTITY_PRODUCT][$name] : null;
}
+ /**
+ * @param $name
+ * @return null
+ */
protected function getCountryId($name)
{
$name = strtolower($name);
return isset($this->maps['countries'][$name]) ? $this->maps['countries'][$name] : null;
}
+ /**
+ * @param $name
+ * @return null
+ */
protected function getCountryIdBy2($name)
{
$name = strtolower($name);
return isset($this->maps['countries2'][$name]) ? $this->maps['countries2'][$name] : null;
}
+ /**
+ * @param $name
+ * @return mixed
+ */
protected function getFirstName($name)
{
$name = Utils::splitName($name);
return $name[0];
}
+ /**
+ * @param $date
+ * @param string $format
+ * @return null
+ */
protected function getDate($date, $format = 'Y-m-d')
{
if ( ! $date instanceof DateTime) {
@@ -74,30 +127,50 @@ class BaseTransformer extends TransformerAbstract
return $date ? $date->format('Y-m-d') : null;
}
+ /**
+ * @param $name
+ * @return mixed
+ */
protected function getLastName($name)
{
$name = Utils::splitName($name);
return $name[1];
}
+ /**
+ * @param $number
+ * @return string
+ */
protected function getInvoiceNumber($number)
{
$number = strtolower($number);
return str_pad($number, 4, '0', STR_PAD_LEFT);
}
+ /**
+ * @param $invoiceNumber
+ * @return null
+ */
protected function getInvoiceId($invoiceNumber)
{
$invoiceNumber = $this->getInvoiceNumber($invoiceNumber);
return isset($this->maps[ENTITY_INVOICE][$invoiceNumber]) ? $this->maps[ENTITY_INVOICE][$invoiceNumber] : null;
}
+ /**
+ * @param $invoiceNumber
+ * @return bool
+ */
protected function hasInvoice($invoiceNumber)
{
$invoiceNumber = $this->getInvoiceNumber($invoiceNumber);
return isset($this->maps[ENTITY_INVOICE][$invoiceNumber]);
}
+ /**
+ * @param $invoiceNumber
+ * @return null
+ */
protected function getInvoiceClientId($invoiceNumber)
{
$invoiceNumber = $this->getInvoiceNumber($invoiceNumber);
@@ -105,6 +178,10 @@ class BaseTransformer extends TransformerAbstract
}
+ /**
+ * @param $name
+ * @return null
+ */
protected function getVendorId($name)
{
$name = strtolower($name);
diff --git a/app/Ninja/Import/CSV/ClientTransformer.php b/app/Ninja/Import/CSV/ClientTransformer.php
index b480d5e88f4e..edab637b4367 100644
--- a/app/Ninja/Import/CSV/ClientTransformer.php
+++ b/app/Ninja/Import/CSV/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if (isset($data->name) && $this->hasClient($data->name)) {
diff --git a/app/Ninja/Import/CSV/InvoiceTransformer.php b/app/Ninja/Import/CSV/InvoiceTransformer.php
index e58bfe335ed2..6095388fdde0 100644
--- a/app/Ninja/Import/CSV/InvoiceTransformer.php
+++ b/app/Ninja/Import/CSV/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->name)) {
diff --git a/app/Ninja/Import/CSV/PaymentTransformer.php b/app/Ninja/Import/CSV/PaymentTransformer.php
index 7acd3d88f839..c8a1a82955e4 100644
--- a/app/Ninja/Import/CSV/PaymentTransformer.php
+++ b/app/Ninja/Import/CSV/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/CSV/ProductTransformer.php b/app/Ninja/Import/CSV/ProductTransformer.php
index 248d3ed09cba..e6c581b7272b 100644
--- a/app/Ninja/Import/CSV/ProductTransformer.php
+++ b/app/Ninja/Import/CSV/ProductTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ProductTransformer
+ */
class ProductTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if (empty($data->product_key) || $this->hasProduct($data->product_key)) {
diff --git a/app/Ninja/Import/CSV/VendorTransformer.php b/app/Ninja/Import/CSV/VendorTransformer.php
index 464274e5a4fa..d589dd8db28c 100644
--- a/app/Ninja/Import/CSV/VendorTransformer.php
+++ b/app/Ninja/Import/CSV/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if (isset($data->name) && $this->hasVendor($data->name)) {
diff --git a/app/Ninja/Import/FreshBooks/ClientTransformer.php b/app/Ninja/Import/FreshBooks/ClientTransformer.php
index d71be4befdd9..2d5e6b64ed08 100644
--- a/app/Ninja/Import/FreshBooks/ClientTransformer.php
+++ b/app/Ninja/Import/FreshBooks/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->organization)) {
diff --git a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php
index 06c4af967491..ef5e11571d06 100644
--- a/app/Ninja/Import/FreshBooks/InvoiceTransformer.php
+++ b/app/Ninja/Import/FreshBooks/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->organization)) {
diff --git a/app/Ninja/Import/FreshBooks/PaymentTransformer.php b/app/Ninja/Import/FreshBooks/PaymentTransformer.php
index eaf371f91eda..3cd829f1ea9c 100644
--- a/app/Ninja/Import/FreshBooks/PaymentTransformer.php
+++ b/app/Ninja/Import/FreshBooks/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/FreshBooks/TaskTransformer.php b/app/Ninja/Import/FreshBooks/TaskTransformer.php
index 8c1363edcfec..09e409596009 100644
--- a/app/Ninja/Import/FreshBooks/TaskTransformer.php
+++ b/app/Ninja/Import/FreshBooks/TaskTransformer.php
@@ -1,7 +1,6 @@
hasVendor($data->organization)) {
diff --git a/app/Ninja/Import/Harvest/ClientTransformer.php b/app/Ninja/Import/Harvest/ClientTransformer.php
index fb8200ec3ae0..20a298709bd6 100644
--- a/app/Ninja/Import/Harvest/ClientTransformer.php
+++ b/app/Ninja/Import/Harvest/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->client_name)) {
diff --git a/app/Ninja/Import/Harvest/ContactTransformer.php b/app/Ninja/Import/Harvest/ContactTransformer.php
index 6baf883c95c2..2e5b667e506f 100644
--- a/app/Ninja/Import/Harvest/ContactTransformer.php
+++ b/app/Ninja/Import/Harvest/ContactTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ContactTransformer
+ */
class ContactTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->hasClient($data->client)) {
diff --git a/app/Ninja/Import/Harvest/InvoiceTransformer.php b/app/Ninja/Import/Harvest/InvoiceTransformer.php
index 850eeede594c..ae47e7a7eb83 100644
--- a/app/Ninja/Import/Harvest/InvoiceTransformer.php
+++ b/app/Ninja/Import/Harvest/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->client)) {
diff --git a/app/Ninja/Import/Harvest/PaymentTransformer.php b/app/Ninja/Import/Harvest/PaymentTransformer.php
index 0efd442886cc..b8b98e0dc837 100644
--- a/app/Ninja/Import/Harvest/PaymentTransformer.php
+++ b/app/Ninja/Import/Harvest/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Harvest/VendorContactTransformer.php b/app/Ninja/Import/Harvest/VendorContactTransformer.php
index 3aa0b0b36aa2..7f3533fd785c 100644
--- a/app/Ninja/Import/Harvest/VendorContactTransformer.php
+++ b/app/Ninja/Import/Harvest/VendorContactTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorContactTransformer
+ */
class VendorContactTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->hasVendor($data->vendor)) {
diff --git a/app/Ninja/Import/Harvest/VendorTransformer.php b/app/Ninja/Import/Harvest/VendorTransformer.php
index efab1e6b66ad..0bc3ab12cd00 100644
--- a/app/Ninja/Import/Harvest/VendorTransformer.php
+++ b/app/Ninja/Import/Harvest/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->vendor_name)) {
diff --git a/app/Ninja/Import/Hiveage/ClientTransformer.php b/app/Ninja/Import/Hiveage/ClientTransformer.php
index 515eb8353562..577872e0b6c0 100644
--- a/app/Ninja/Import/Hiveage/ClientTransformer.php
+++ b/app/Ninja/Import/Hiveage/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->name)) {
diff --git a/app/Ninja/Import/Hiveage/InvoiceTransformer.php b/app/Ninja/Import/Hiveage/InvoiceTransformer.php
index e9054f1b8791..eab836eed2ac 100644
--- a/app/Ninja/Import/Hiveage/InvoiceTransformer.php
+++ b/app/Ninja/Import/Hiveage/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->client)) {
diff --git a/app/Ninja/Import/Hiveage/PaymentTransformer.php b/app/Ninja/Import/Hiveage/PaymentTransformer.php
index e7e4befb5714..fe091a5eff56 100644
--- a/app/Ninja/Import/Hiveage/PaymentTransformer.php
+++ b/app/Ninja/Import/Hiveage/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Hiveage/VendorTransformer.php b/app/Ninja/Import/Hiveage/VendorTransformer.php
index dec1b62d1ccb..a52ad461e3e2 100644
--- a/app/Ninja/Import/Hiveage/VendorTransformer.php
+++ b/app/Ninja/Import/Hiveage/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->name)) {
diff --git a/app/Ninja/Import/Invoiceable/ClientTransformer.php b/app/Ninja/Import/Invoiceable/ClientTransformer.php
index 7e462ceef9b0..2dade2f71d3a 100644
--- a/app/Ninja/Import/Invoiceable/ClientTransformer.php
+++ b/app/Ninja/Import/Invoiceable/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->client_name)) {
diff --git a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php
index f6697a7e90c2..23644d81ffe6 100644
--- a/app/Ninja/Import/Invoiceable/InvoiceTransformer.php
+++ b/app/Ninja/Import/Invoiceable/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->client_name)) {
diff --git a/app/Ninja/Import/Invoiceable/PaymentTransformer.php b/app/Ninja/Import/Invoiceable/PaymentTransformer.php
index ea2310c01ada..6ad823f0370f 100644
--- a/app/Ninja/Import/Invoiceable/PaymentTransformer.php
+++ b/app/Ninja/Import/Invoiceable/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Invoiceable/VendorTransformer.php b/app/Ninja/Import/Invoiceable/VendorTransformer.php
index 1ec4a2876884..5125c3dfea28 100644
--- a/app/Ninja/Import/Invoiceable/VendorTransformer.php
+++ b/app/Ninja/Import/Invoiceable/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->vendor_name)) {
diff --git a/app/Ninja/Import/Nutcache/ClientTransformer.php b/app/Ninja/Import/Nutcache/ClientTransformer.php
index 74705a597a24..835049212a9e 100644
--- a/app/Ninja/Import/Nutcache/ClientTransformer.php
+++ b/app/Ninja/Import/Nutcache/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->name)) {
diff --git a/app/Ninja/Import/Nutcache/InvoiceTransformer.php b/app/Ninja/Import/Nutcache/InvoiceTransformer.php
index a3e3bc91372d..227a4f587837 100644
--- a/app/Ninja/Import/Nutcache/InvoiceTransformer.php
+++ b/app/Ninja/Import/Nutcache/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->client)) {
diff --git a/app/Ninja/Import/Nutcache/PaymentTransformer.php b/app/Ninja/Import/Nutcache/PaymentTransformer.php
index 9434e274fc05..fcdf139e6d13 100644
--- a/app/Ninja/Import/Nutcache/PaymentTransformer.php
+++ b/app/Ninja/Import/Nutcache/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Nutcache/TaskTransformer.php b/app/Ninja/Import/Nutcache/TaskTransformer.php
index 8c1363edcfec..09e409596009 100644
--- a/app/Ninja/Import/Nutcache/TaskTransformer.php
+++ b/app/Ninja/Import/Nutcache/TaskTransformer.php
@@ -1,7 +1,6 @@
hasVendor($data->name)) {
diff --git a/app/Ninja/Import/Ronin/ClientTransformer.php b/app/Ninja/Import/Ronin/ClientTransformer.php
index f79523830e99..4015a305a458 100644
--- a/app/Ninja/Import/Ronin/ClientTransformer.php
+++ b/app/Ninja/Import/Ronin/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->company)) {
diff --git a/app/Ninja/Import/Ronin/InvoiceTransformer.php b/app/Ninja/Import/Ronin/InvoiceTransformer.php
index 5a4ff6ce2aba..4f3ed7081790 100644
--- a/app/Ninja/Import/Ronin/InvoiceTransformer.php
+++ b/app/Ninja/Import/Ronin/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->client)) {
diff --git a/app/Ninja/Import/Ronin/PaymentTransformer.php b/app/Ninja/Import/Ronin/PaymentTransformer.php
index b797d3f672f3..b8f7cf0562fa 100644
--- a/app/Ninja/Import/Ronin/PaymentTransformer.php
+++ b/app/Ninja/Import/Ronin/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Ronin/VendorTransformer.php b/app/Ninja/Import/Ronin/VendorTransformer.php
index 817de03d6647..7a606226c20d 100644
--- a/app/Ninja/Import/Ronin/VendorTransformer.php
+++ b/app/Ninja/Import/Ronin/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->company)) {
diff --git a/app/Ninja/Import/Wave/ClientTransformer.php b/app/Ninja/Import/Wave/ClientTransformer.php
index f76ba9c48a26..4a4178336ea2 100644
--- a/app/Ninja/Import/Wave/ClientTransformer.php
+++ b/app/Ninja/Import/Wave/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->customer_name)) {
diff --git a/app/Ninja/Import/Wave/InvoiceTransformer.php b/app/Ninja/Import/Wave/InvoiceTransformer.php
index b10585aa72bd..0ae418ebaa1a 100644
--- a/app/Ninja/Import/Wave/InvoiceTransformer.php
+++ b/app/Ninja/Import/Wave/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->customer)) {
diff --git a/app/Ninja/Import/Wave/PaymentTransformer.php b/app/Ninja/Import/Wave/PaymentTransformer.php
index e809f0d3b408..dbfbf6741e60 100644
--- a/app/Ninja/Import/Wave/PaymentTransformer.php
+++ b/app/Ninja/Import/Wave/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getInvoiceClientId($data->invoice_num)) {
diff --git a/app/Ninja/Import/Wave/VendorTransformer.php b/app/Ninja/Import/Wave/VendorTransformer.php
index f2fe2f43e375..a63a12407e59 100644
--- a/app/Ninja/Import/Wave/VendorTransformer.php
+++ b/app/Ninja/Import/Wave/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->customer_name)) {
diff --git a/app/Ninja/Import/Zoho/ClientTransformer.php b/app/Ninja/Import/Zoho/ClientTransformer.php
index 689bd1cf1a26..4c2f7ef9ed6f 100644
--- a/app/Ninja/Import/Zoho/ClientTransformer.php
+++ b/app/Ninja/Import/Zoho/ClientTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class ClientTransformer
+ */
class ClientTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasClient($data->customer_name)) {
diff --git a/app/Ninja/Import/Zoho/InvoiceTransformer.php b/app/Ninja/Import/Zoho/InvoiceTransformer.php
index f6fc3c44a7a1..9db0bc4ceb1a 100644
--- a/app/Ninja/Import/Zoho/InvoiceTransformer.php
+++ b/app/Ninja/Import/Zoho/InvoiceTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class InvoiceTransformer
+ */
class InvoiceTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ( ! $this->getClientId($data->customer_name)) {
diff --git a/app/Ninja/Import/Zoho/PaymentTransformer.php b/app/Ninja/Import/Zoho/PaymentTransformer.php
index 0f9ad8bad891..c9684bebb455 100644
--- a/app/Ninja/Import/Zoho/PaymentTransformer.php
+++ b/app/Ninja/Import/Zoho/PaymentTransformer.php
@@ -3,8 +3,15 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+/**
+ * Class PaymentTransformer
+ */
class PaymentTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return Item
+ */
public function transform($data)
{
return new Item($data, function ($data) {
diff --git a/app/Ninja/Import/Zoho/VendorTransformer.php b/app/Ninja/Import/Zoho/VendorTransformer.php
index 811a9f7ff2d9..58633a538ebb 100644
--- a/app/Ninja/Import/Zoho/VendorTransformer.php
+++ b/app/Ninja/Import/Zoho/VendorTransformer.php
@@ -2,9 +2,17 @@
use App\Ninja\Import\BaseTransformer;
use League\Fractal\Resource\Item;
+
// vendor
+/**
+ * Class VendorTransformer
+ */
class VendorTransformer extends BaseTransformer
{
+ /**
+ * @param $data
+ * @return bool|Item
+ */
public function transform($data)
{
if ($this->hasVendor($data->customer_name)) {
diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php
index 5f8be4eb4530..61610187e9b6 100644
--- a/app/Ninja/Mailers/ContactMailer.php
+++ b/app/Ninja/Mailers/ContactMailer.php
@@ -1,18 +1,20 @@
templateService = $templateService;
}
+ /**
+ * @param Invoice $invoice
+ * @param bool $reminder
+ * @param bool $pdfString
+ * @return bool|null|string
+ */
public function sendInvoice(Invoice $invoice, $reminder = false, $pdfString = false)
{
$invoice->load('invitations', 'client.language', 'account');
@@ -64,7 +81,7 @@ class ContactMailer extends Mailer
$pdfString = $invoice->getPDFString();
}
- $documentStrings = array();
+ $documentStrings = [];
if ($account->document_email_attachment && $invoice->hasDocuments()) {
$documents = $invoice->documents;
@@ -80,10 +97,10 @@ class ContactMailer extends Mailer
$size += $document->size;
if($size > $maxSize)break;
- $documentStrings[] = array(
+ $documentStrings[] = [
'name' => $document->name,
'data' => $document->getRaw(),
- );
+ ];
}
}
@@ -107,8 +124,26 @@ class ContactMailer extends Mailer
return $response;
}
- private function sendInvitation($invitation, $invoice, $body, $subject, $pdfString, $documentStrings)
+ /**
+ * @param Invitation $invitation
+ * @param Invoice $invoice
+ * @param $body
+ * @param $subject
+ * @param $pdfString
+ * @param $documentStrings
+ * @return bool|string
+ * @throws \Laracasts\Presenter\Exceptions\PresenterException
+ */
+ private function sendInvitation(
+ Invitation$invitation,
+ Invoice $invoice,
+ $body,
+ $subject,
+ $pdfString,
+ $documentStrings
+ )
{
+
$client = $invoice->client;
$account = $invoice->account;
@@ -180,13 +215,17 @@ class ContactMailer extends Mailer
}
}
+ /**
+ * @param int $length
+ * @return string
+ */
protected function generatePassword($length = 9)
{
- $sets = array(
+ $sets = [
'abcdefghjkmnpqrstuvwxyz',
'ABCDEFGHJKMNPQRSTUVWXYZ',
'23456789',
- );
+ ];
$all = '';
$password = '';
foreach($sets as $set)
@@ -202,6 +241,9 @@ class ContactMailer extends Mailer
return $password;
}
+ /**
+ * @param Payment $payment
+ */
public function sendPaymentConfirmation(Payment $payment)
{
$account = $payment->account;
@@ -258,6 +300,13 @@ class ContactMailer extends Mailer
$account->loadLocalizationSettings();
}
+ /**
+ * @param $name
+ * @param $email
+ * @param $amount
+ * @param $license
+ * @param $productId
+ */
public function sendLicensePaymentConfirmation($name, $email, $amount, $license, $productId)
{
$view = 'license_confirmation';
diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php
index d655e4945e31..8e5b213367fb 100644
--- a/app/Ninja/Mailers/Mailer.php
+++ b/app/Ninja/Mailers/Mailer.php
@@ -2,11 +2,22 @@
use Exception;
use Mail;
-use Utils;
use App\Models\Invoice;
+/**
+ * Class Mailer
+ */
class Mailer
{
+ /**
+ * @param $toEmail
+ * @param $fromEmail
+ * @param $fromName
+ * @param $subject
+ * @param $view
+ * @param array $data
+ * @return bool|string
+ */
public function sendTo($toEmail, $fromEmail, $fromName, $subject, $view, $data = [])
{
// check the username is set
@@ -59,6 +70,11 @@ class Mailer
}
}
+ /**
+ * @param $response
+ * @param $data
+ * @return bool
+ */
private function handleSuccess($response, $data)
{
if (isset($data['invitation'])) {
@@ -78,6 +94,10 @@ class Mailer
return true;
}
+ /**
+ * @param $exception
+ * @return string
+ */
private function handleFailure($exception)
{
if (isset($_ENV['POSTMARK_API_TOKEN']) && method_exists($exception, 'getResponse')) {
@@ -87,8 +107,6 @@ class Mailer
} else {
$emailError = $exception->getMessage();
}
-
- //Utils::logError("Email Error: $emailError");
if (isset($data['invitation'])) {
$invitation = $data['invitation'];
diff --git a/app/Ninja/Mailers/UserMailer.php b/app/Ninja/Mailers/UserMailer.php
index 6f09c20d9f5a..492a551a9e02 100644
--- a/app/Ninja/Mailers/UserMailer.php
+++ b/app/Ninja/Mailers/UserMailer.php
@@ -1,6 +1,5 @@
email) {
@@ -34,7 +37,18 @@ class UserMailer extends Mailer
$this->sendTo($user->email, $fromEmail, $fromName, $subject, $view, $data);
}
- public function sendNotification(User $user, Invoice $invoice, $notificationType, Payment $payment = null)
+ /**
+ * @param User $user
+ * @param Invoice $invoice
+ * @param $notificationType
+ * @param Payment|null $payment
+ */
+ public function sendNotification(
+ User $user,
+ Invoice $invoice,
+ $notificationType,
+ Payment $payment = null
+ )
{
if (! $user->email || $user->cannot('view', $invoice)) {
return;
@@ -69,6 +83,9 @@ class UserMailer extends Mailer
$this->sendTo($user->email, CONTACT_EMAIL, CONTACT_NAME, $subject, $view, $data);
}
+ /**
+ * @param Invitation $invitation
+ */
public function sendEmailBounced(Invitation $invitation)
{
$user = $invitation->user;
diff --git a/app/Ninja/Notifications/PushFactory.php b/app/Ninja/Notifications/PushFactory.php
index 723ff824debe..e2f34c46be2d 100644
--- a/app/Ninja/Notifications/PushFactory.php
+++ b/app/Ninja/Notifications/PushFactory.php
@@ -3,25 +3,16 @@
namespace App\Ninja\Notifications;
use Davibennun\LaravelPushNotification\Facades\PushNotification;
-use Illuminate\Http\Request;
/**
* Class PushFactory
- * @package App\Ninja\Notifications
*/
class PushFactory
{
/**
* PushFactory constructor.
- *
- * @param $this->certificate - Development or production.
- *
- * Static variables defined in routes.php
- *
- * IOS_PUSH_CERTIFICATE
*/
-
public function __construct()
{
$this->certificate = IOS_PUSH_CERTIFICATE;
@@ -58,7 +49,6 @@ class PushFactory
* @param $message - user specific message
*
* @return void
- *
*/
public function message($token, $message)
@@ -91,5 +81,4 @@ class PushFactory
return $feedback->getFeedback();
}
-
}
diff --git a/app/Ninja/PaymentDrivers/BasePaymentDriver.php b/app/Ninja/PaymentDrivers/BasePaymentDriver.php
index 54f2f36a2a8a..b809f5985c81 100644
--- a/app/Ninja/PaymentDrivers/BasePaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/BasePaymentDriver.php
@@ -764,7 +764,7 @@ class BasePaymentDriver
// PayPal doesn't allow being run in an iframe so we need to open in new tab
if ($gatewayType === GATEWAY_TYPE_PAYPAL) {
- $url .= "#braintree_paypal";
+ $url .= '#braintree_paypal';
if ($account->iframe_url) {
return 'javascript:window.open("' . $url . '", "_blank")';
@@ -775,7 +775,7 @@ class BasePaymentDriver
}
protected function parseCardType($cardName) {
- $cardTypes = array(
+ $cardTypes = [
'visa' => PAYMENT_TYPE_VISA,
'americanexpress' => PAYMENT_TYPE_AMERICAN_EXPRESS,
'amex' => PAYMENT_TYPE_AMERICAN_EXPRESS,
@@ -790,9 +790,9 @@ class BasePaymentDriver
'maestro' => PAYMENT_TYPE_MAESTRO,
'solo' => PAYMENT_TYPE_SOLO,
'switch' => PAYMENT_TYPE_SWITCH
- );
+ ];
- $cardName = strtolower(str_replace(array(' ', '-', '_'), '', $cardName));
+ $cardName = strtolower(str_replace([' ', '-', '_'], '', $cardName));
if (empty($cardTypes[$cardName]) && 1 == preg_match('/^('.implode('|', array_keys($cardTypes)).')/', $cardName, $matches)) {
// Some gateways return extra stuff after the card name
diff --git a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
index 240a7dc9dc56..ad11a8c1287b 100644
--- a/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/PayPalExpressPaymentDriver.php
@@ -1,6 +1,5 @@
false,
'headers' => ['content-type' => 'application/x-www-form-urlencoded'],
- 'body' => http_build_query(array(
+ 'body' => http_build_query([
'client_id' => $clientId,
'secret' => $secret,
'public_token' => $publicToken,
'account_id' => $accountId,
- ))
+ ])
]
);
return json_decode($response->getBody(), true);
@@ -328,17 +328,17 @@ class StripePaymentDriver extends BasePaymentDriver
throw new Exception('Missing event type');
}
- $supportedEvents = array(
+ $supportedEvents = [
'charge.failed',
'charge.succeeded',
'charge.refunded',
'customer.source.updated',
'customer.source.deleted',
'customer.bank_account.deleted',
- );
+ ];
if (!in_array($eventType, $supportedEvents)) {
- return array('message' => 'Ignoring event');
+ return ['message' => 'Ignoring event'];
}
// Fetch the event directly from Stripe for security
diff --git a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
index 0405237270f4..c8865e74d103 100644
--- a/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
+++ b/app/Ninja/PaymentDrivers/WePayPaymentDriver.php
@@ -88,33 +88,33 @@ class WePayPaymentDriver extends BasePaymentDriver
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
// Persist bank details
- $this->tokenResponse = $wepay->request('/payment_bank/persist', array(
+ $this->tokenResponse = $wepay->request('/payment_bank/persist', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'payment_bank_id' => $token,
- ));
+ ]);
} else {
// Authorize credit card
- $tokenResponse = $wepay->request('credit_card/authorize', array(
+ $tokenResponse = $wepay->request('credit_card/authorize', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => $token,
- ));
+ ]);
// Update the callback uri and get the card details
- $tokenResponse = $wepay->request('credit_card/modify', array(
+ $tokenResponse = $wepay->request('credit_card/modify', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => $token,
'auto_update' => WEPAY_AUTO_UPDATE,
'callback_uri' => $this->accountGateway->getWebhookUrl(),
- ));
+ ]);
- $this->tokenResponse = $wepay->request('credit_card', array(
+ $this->tokenResponse = $wepay->request('credit_card', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => $token,
- ));
+ ]);
}
return parent::createToken();
@@ -240,11 +240,11 @@ class WePayPaymentDriver extends BasePaymentDriver
}
$wepay = Utils::setupWePay($accountGateway);
- $source = $wepay->request('credit_card', array(
+ $source = $wepay->request('credit_card', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => intval($objectId),
- ));
+ ]);
if ($source->state == 'deleted') {
$paymentMethod->delete();
@@ -260,9 +260,9 @@ class WePayPaymentDriver extends BasePaymentDriver
}
$wepay = Utils::setupWePay($accountGateway);
- $wepayAccount = $wepay->request('account', array(
+ $wepayAccount = $wepay->request('account', [
'account_id' => intval($objectId),
- ));
+ ]);
if ($wepayAccount->state == 'deleted') {
$accountGateway->delete();
@@ -272,7 +272,7 @@ class WePayPaymentDriver extends BasePaymentDriver
$accountGateway->save();
}
- return array('message' => 'Processed successfully');
+ return ['message' => 'Processed successfully'];
} elseif ($objectType == 'checkout') {
$payment = Payment::scope(false, $accountId)->where('transaction_reference', '=', $objectId)->first();
@@ -281,9 +281,9 @@ class WePayPaymentDriver extends BasePaymentDriver
}
$wepay = Utils::setupWePay($accountGateway);
- $checkout = $wepay->request('checkout', array(
+ $checkout = $wepay->request('checkout', [
'checkout_id' => intval($objectId),
- ));
+ ]);
if ($checkout->state == 'refunded') {
$payment->recordRefund();
diff --git a/app/Ninja/Presenters/AccountPresenter.php b/app/Ninja/Presenters/AccountPresenter.php
index dc9cacbb8aa7..cd829fd4f44d 100644
--- a/app/Ninja/Presenters/AccountPresenter.php
+++ b/app/Ninja/Presenters/AccountPresenter.php
@@ -3,18 +3,31 @@
use Utils;
use Laracasts\Presenter\Presenter;
-class AccountPresenter extends Presenter {
+/**
+ * Class AccountPresenter
+ */
+class AccountPresenter extends Presenter
+{
+ /**
+ * @return mixed
+ */
public function name()
{
return $this->entity->name ?: trans('texts.untitled_account');
}
+ /**
+ * @return string
+ */
public function website()
{
return Utils::addHttp($this->entity->website);
}
+ /**
+ * @return mixed
+ */
public function currencyCode()
{
$currencyId = $this->entity->getCurrencyId();
diff --git a/app/Ninja/Presenters/ClientPresenter.php b/app/Ninja/Presenters/ClientPresenter.php
index 22ed376be6c6..44efc207017b 100644
--- a/app/Ninja/Presenters/ClientPresenter.php
+++ b/app/Ninja/Presenters/ClientPresenter.php
@@ -1,7 +1,5 @@
entity->client ? $this->entity->client->getDisplayName() : '';
}
+ /**
+ * @return \DateTime|string
+ */
public function credit_date()
{
return Utils::fromSqlDate($this->entity->credit_date);
diff --git a/app/Ninja/Presenters/EntityPresenter.php b/app/Ninja/Presenters/EntityPresenter.php
index b1e16acbd620..7a8255ccb70a 100644
--- a/app/Ninja/Presenters/EntityPresenter.php
+++ b/app/Ninja/Presenters/EntityPresenter.php
@@ -3,8 +3,12 @@
use URL;
use Laracasts\Presenter\Presenter;
-class EntityPresenter extends Presenter {
+class EntityPresenter extends Presenter
+{
+ /**
+ * @return string
+ */
public function url()
{
$type = $this->entity->getEntityType();
@@ -14,6 +18,9 @@ class EntityPresenter extends Presenter {
return URL::to($link);
}
+ /**
+ * @return mixed
+ */
public function link()
{
$name = $this->entity->getDisplayName();
@@ -21,5 +28,4 @@ class EntityPresenter extends Presenter {
return link_to($link, $name)->toHtml();
}
-
}
diff --git a/app/Ninja/Presenters/ExpensePresenter.php b/app/Ninja/Presenters/ExpensePresenter.php
index 275d4e657b09..3de07736257f 100644
--- a/app/Ninja/Presenters/ExpensePresenter.php
+++ b/app/Ninja/Presenters/ExpensePresenter.php
@@ -2,19 +2,31 @@
use Utils;
-class ExpensePresenter extends EntityPresenter {
+/**
+ * Class ExpensePresenter
+ */
+class ExpensePresenter extends EntityPresenter
+{
- // Expenses
+ /**
+ * @return string
+ */
public function vendor()
{
return $this->entity->vendor ? $this->entity->vendor->getDisplayName() : '';
}
+ /**
+ * @return \DateTime|string
+ */
public function expense_date()
{
return Utils::fromSqlDate($this->entity->expense_date);
}
+ /**
+ * @return int
+ */
public function invoiced_amount()
{
return $this->entity->invoice_id ? $this->entity->convertedAmount() : 0;
diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php
index 282f5506cd83..836b25704f87 100644
--- a/app/Ninja/Presenters/InvoicePresenter.php
+++ b/app/Ninja/Presenters/InvoicePresenter.php
@@ -1,6 +1,5 @@
entity->client ? $this->entity->client->getDisplayName() : '';
}
+ /**
+ * @return mixed
+ */
public function user()
{
return $this->entity->user->getDisplayName();
}
+ /**
+ * @param $account
+ * @return mixed
+ */
public function times($account)
{
$parts = json_decode($this->entity->time_log) ?: [];
@@ -34,6 +47,9 @@ class TaskPresenter extends EntityPresenter {
return implode("\n", $times);
}
+ /**
+ * @return string
+ */
public function status()
{
$class = $text = '';
@@ -51,5 +67,4 @@ class TaskPresenter extends EntityPresenter {
return "{$text}";
}
-
}
diff --git a/app/Ninja/Presenters/VendorPresenter.php b/app/Ninja/Presenters/VendorPresenter.php
index 2dd535cac6cd..afc02f90659f 100644
--- a/app/Ninja/Presenters/VendorPresenter.php
+++ b/app/Ninja/Presenters/VendorPresenter.php
@@ -1,10 +1,12 @@
entity->country ? $this->entity->country->name : '';
}
-
}
diff --git a/app/Ninja/Repositories/AccountGatewayRepository.php b/app/Ninja/Repositories/AccountGatewayRepository.php
index 286c8416a21a..c59b0d77abab 100644
--- a/app/Ninja/Repositories/AccountGatewayRepository.php
+++ b/app/Ninja/Repositories/AccountGatewayRepository.php
@@ -1,10 +1,6 @@
qty = 1;
$pending_monthly_item->cost = 0;
- $pending_monthly_item->notes = trans("texts.plan_pending_monthly", array('date', Utils::dateToString($term_end)));
+ $pending_monthly_item->notes = trans('texts.plan_pending_monthly', ['date', Utils::dateToString($term_end)]);
// Don't change this without updating the text in PaymentService->createPayment()
$pending_monthly_item->product_key = 'Pending Monthly';
diff --git a/app/Ninja/Repositories/BankAccountRepository.php b/app/Ninja/Repositories/BankAccountRepository.php
index f36499b8a529..3a4186d2997b 100644
--- a/app/Ninja/Repositories/BankAccountRepository.php
+++ b/app/Ninja/Repositories/BankAccountRepository.php
@@ -2,11 +2,8 @@
use DB;
use Crypt;
-use Utils;
-use Session;
use App\Models\BankAccount;
use App\Models\BankSubaccount;
-use App\Ninja\Repositories\BaseRepository;
class BankAccountRepository extends BaseRepository
{
diff --git a/app/Ninja/Repositories/BaseRepository.php b/app/Ninja/Repositories/BaseRepository.php
index f674c406549e..49f296ef1b84 100644
--- a/app/Ninja/Repositories/BaseRepository.php
+++ b/app/Ninja/Repositories/BaseRepository.php
@@ -1,23 +1,40 @@
getClassName();
return new $className();
}
+ /**
+ * @param $entity
+ * @param $type
+ * @return string
+ */
private function getEventClass($entity, $type)
{
return 'App\Events\\' . ucfirst($entity->getEntityType()) . 'Was' . $type;
}
+ /**
+ * @param $entity
+ */
public function archive($entity)
{
if ($entity->trashed()) {
@@ -33,6 +50,9 @@ class BaseRepository
}
}
+ /**
+ * @param $entity
+ */
public function restore($entity)
{
if ( ! $entity->trashed()) {
@@ -55,6 +75,9 @@ class BaseRepository
}
}
+ /**
+ * @param $entity
+ */
public function delete($entity)
{
if ($entity->is_deleted) {
@@ -73,11 +96,19 @@ class BaseRepository
}
}
+ /**
+ * @param $ids
+ * @return mixed
+ */
public function findByPublicIds($ids)
{
return $this->getInstance()->scope($ids)->get();
}
+ /**
+ * @param $ids
+ * @return mixed
+ */
public function findByPublicIdsWithTrashed($ids)
{
return $this->getInstance()->scope($ids)->withTrashed()->get();
diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php
index cf2ad12daf39..31ca425253c3 100644
--- a/app/Ninja/Repositories/ClientRepository.php
+++ b/app/Ninja/Repositories/ClientRepository.php
@@ -2,10 +2,8 @@
use DB;
use Cache;
-use App\Ninja\Repositories\BaseRepository;
use App\Models\Client;
use App\Models\Contact;
-use App\Models\Activity;
use App\Events\ClientWasCreated;
use App\Events\ClientWasUpdated;
diff --git a/app/Ninja/Repositories/ContactRepository.php b/app/Ninja/Repositories/ContactRepository.php
index 50d15af2b21e..6f157c1c40b8 100644
--- a/app/Ninja/Repositories/ContactRepository.php
+++ b/app/Ninja/Repositories/ContactRepository.php
@@ -1,6 +1,5 @@
join('accounts', 'accounts.id', '=', 'clients.account_id')
->leftjoin('clients', 'clients.id', '=', 'clients.client_id')
- /*->leftJoin('expenses', 'expenses.id', '=', 'clients.expense_id')
- ->leftJoin('invoices', 'invoices.id', '=', 'clients.invoice_id')*/
->where('documents.account_id', '=', $accountid)
- /*->where('vendors.deleted_at', '=', null)
- ->where('clients.deleted_at', '=', null)*/
->select(
'documents.account_id',
'documents.path',
@@ -101,20 +94,20 @@ class DocumentRepository extends BaseRepository
}
// This is an image; check if we need to create a preview
- if(in_array($documentType, array('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 = array();
- if(in_array($documentType, array('gif','bmp','tiff','psd'))){
+ $imgManagerConfig = [];
+ if(in_array($documentType, ['gif','bmp','tiff','psd'])){
// Needs to be converted
$makePreview = true;
} else if($width > DOCUMENT_PREVIEW_SIZE || $height > DOCUMENT_PREVIEW_SIZE){
$makePreview = true;
}
- if(in_array($documentType,array('bmp','tiff','psd'))){
+ if(in_array($documentType,['bmp','tiff','psd'])){
if(!class_exists('Imagick')){
// Cant't read this
$makePreview = false;
@@ -125,7 +118,7 @@ class DocumentRepository extends BaseRepository
if($makePreview){
$previewType = 'jpeg';
- if(in_array($documentType, array('png','gif','tiff','psd'))){
+ if(in_array($documentType, ['png','gif','tiff','psd'])){
// Has transparency
$previewType = 'png';
}
@@ -197,7 +190,7 @@ class DocumentRepository extends BaseRepository
->where('invoices.is_deleted', '=', false)
->where('clients.deleted_at', '=', null)
->where('invoices.is_recurring', '=', false)
- // This needs to be a setting to also hide the activity on the dashboard page
+ // TODO: This needs to be a setting to also hide the activity on the dashboard page
//->where('invoices.invoice_status_id', '>=', INVOICE_STATUS_SENT)
->select(
'invitations.invitation_key',
diff --git a/app/Ninja/Repositories/ExpenseRepository.php b/app/Ninja/Repositories/ExpenseRepository.php
index 23b164b41bcf..027a390f3ab8 100644
--- a/app/Ninja/Repositories/ExpenseRepository.php
+++ b/app/Ninja/Repositories/ExpenseRepository.php
@@ -6,8 +6,6 @@ use Auth;
use App\Models\Expense;
use App\Models\Vendor;
use App\Models\Document;
-use App\Ninja\Repositories\BaseRepository;
-use Session;
class ExpenseRepository extends BaseRepository
{
@@ -146,7 +144,7 @@ class ExpenseRepository extends BaseRepository
$expense->save();
// Documents
- $document_ids = !empty($input['document_ids'])?array_map('intval', $input['document_ids']):array();;
+ $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) {
diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php
index e929c551f5c7..699cb1db8d71 100644
--- a/app/Ninja/Repositories/InvoiceRepository.php
+++ b/app/Ninja/Repositories/InvoiceRepository.php
@@ -1,8 +1,8 @@
make();
}
- public function save($data, $invoice = null)
+ /**
+ * @param array $data
+ * @param Invoice|null $invoice
+ * @return Invoice|mixed
+ */
+ public function save(array $data, Invoice $invoice = null)
{
+ /** @var Account $account */
$account = \Auth::user()->account;
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
@@ -477,7 +482,7 @@ class InvoiceRepository extends BaseRepository
$invoice->invoice_items()->forceDelete();
}
- $document_ids = !empty($data['document_ids'])?array_map('intval', $data['document_ids']):array();;
+ $document_ids = !empty($data['document_ids'])?array_map('intval', $data['document_ids']):[];;
foreach ($document_ids as $document_id){
$document = Document::scope($document_id)->first();
if($document && Auth::user()->can('edit', $document)){
@@ -581,7 +586,12 @@ class InvoiceRepository extends BaseRepository
return $invoice;
}
- public function cloneInvoice($invoice, $quotePublicId = null)
+ /**
+ * @param Invoice $invoice
+ * @param null $quotePublicId
+ * @return mixed
+ */
+ public function cloneInvoice(Invoice $invoice, $quotePublicId = null)
{
$invoice->load('invitations', 'invoice_items');
$account = $invoice->account;
@@ -683,13 +693,21 @@ class InvoiceRepository extends BaseRepository
return $clone;
}
- public function markSent($invoice)
+ /**
+ * @param Invoice $invoice
+ */
+ public function markSent(Invoice $invoice)
{
$invoice->markInvitationsSent();
}
+ /**
+ * @param $invitationKey
+ * @return Invitation|bool
+ */
public function findInvoiceByInvitation($invitationKey)
{
+ /** @var \App\Models\Invitation $invitation */
$invitation = Invitation::where('invitation_key', '=', $invitationKey)->first();
if (!$invitation) {
@@ -711,6 +729,10 @@ class InvoiceRepository extends BaseRepository
return $invitation;
}
+ /**
+ * @param $clientId
+ * @return mixed
+ */
public function findOpenInvoices($clientId)
{
return Invoice::scope()
@@ -724,7 +746,11 @@ class InvoiceRepository extends BaseRepository
->get();
}
- public function createRecurringInvoice($recurInvoice)
+ /**
+ * @param Invoice $recurInvoice
+ * @return mixed
+ */
+ public function createRecurringInvoice(Invoice $recurInvoice)
{
$recurInvoice->load('account.timezone', 'invoice_items', 'client', 'user');
@@ -811,7 +837,11 @@ class InvoiceRepository extends BaseRepository
return $invoice;
}
- public function findNeedingReminding($account)
+ /**
+ * @param Account $account
+ * @return mixed
+ */
+ public function findNeedingReminding(Account $account)
{
$dates = [];
diff --git a/app/Ninja/Repositories/PaymentRepository.php b/app/Ninja/Repositories/PaymentRepository.php
index 498f0d1d6912..f75f9a186755 100644
--- a/app/Ninja/Repositories/PaymentRepository.php
+++ b/app/Ninja/Repositories/PaymentRepository.php
@@ -5,8 +5,6 @@ use Utils;
use App\Models\Payment;
use App\Models\Credit;
use App\Models\Invoice;
-use App\Models\Client;
-use App\Ninja\Repositories\BaseRepository;
class PaymentRepository extends BaseRepository
{
diff --git a/app/Ninja/Repositories/PaymentTermRepository.php b/app/Ninja/Repositories/PaymentTermRepository.php
index e631e9f1627a..bde31c20a81d 100644
--- a/app/Ninja/Repositories/PaymentTermRepository.php
+++ b/app/Ninja/Repositories/PaymentTermRepository.php
@@ -1,9 +1,6 @@
$data) : $data;
}
+ /**
+ * @param string $resourceKey
+ * @param array $data
+ * @return array
+ */
public function item($resourceKey, array $data)
{
return $data;
- //return ($resourceKey && $resourceKey !== 'data') ? array($resourceKey => $data) : $data;
}
}
diff --git a/app/Ninja/Transformers/AccountTokenTransformer.php b/app/Ninja/Transformers/AccountTokenTransformer.php
index e6ca7e8bfda7..22d1407be571 100644
--- a/app/Ninja/Transformers/AccountTokenTransformer.php
+++ b/app/Ninja/Transformers/AccountTokenTransformer.php
@@ -1,12 +1,18 @@
serializer);
return $this->includeCollection($account->expenseCategories, $transformer, ENTITY_EXPENSE_CATEGORIES);
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeUsers(Account $account)
{
$transformer = new UserTransformer($account, $this->serializer);
return $this->includeCollection($account->users, $transformer, 'users');
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeClients(Account $account)
{
$transformer = new ClientTransformer($account, $this->serializer);
return $this->includeCollection($account->clients, $transformer, 'clients');
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeInvoices(Account $account)
{
$transformer = new InvoiceTransformer($account, $this->serializer);
return $this->includeCollection($account->invoices, $transformer, 'invoices');
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeProducts(Account $account)
{
$transformer = new ProductTransformer($account, $this->serializer);
return $this->includeCollection($account->products, $transformer, 'products');
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeTaxRates(Account $account)
{
$transformer = new TaxRateTransformer($account, $this->serializer);
return $this->includeCollection($account->tax_rates, $transformer, 'taxRates');
}
+ /**
+ * @param Account $account
+ * @return \League\Fractal\Resource\Collection
+ */
public function includePayments(Account $account)
{
$transformer = new PaymentTransformer($account, $this->serializer);
return $this->includeCollection($account->payments, $transformer, 'payments');
}
+ /**
+ * @param Account $account
+ * @return array
+ * @throws \Laracasts\Presenter\Exceptions\PresenterException
+ */
public function transform(Account $account)
{
return [
diff --git a/app/Ninja/Transformers/ClientTransformer.php b/app/Ninja/Transformers/ClientTransformer.php
index ea282f74ceca..67239fa9b28d 100644
--- a/app/Ninja/Transformers/ClientTransformer.php
+++ b/app/Ninja/Transformers/ClientTransformer.php
@@ -1,9 +1,6 @@
account, $this->serializer);
return $this->includeCollection($client->contacts, $transformer, ENTITY_CONTACT);
}
+ /**
+ * @param Client $client
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeInvoices(Client $client)
{
$transformer = new InvoiceTransformer($this->account, $this->serializer, $client);
return $this->includeCollection($client->invoices, $transformer, ENTITY_INVOICE);
}
+ /**
+ * @param Client $client
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeCredits(Client $client)
{
$transformer = new CreditTransformer($this->account, $this->serializer);
return $this->includeCollection($client->credits, $transformer, ENTITY_CREDIT);
}
+ /**
+ * @param Client $client
+ * @return \League\Fractal\Resource\Collection
+ */
public function includeExpenses(Client $client)
{
$transformer = new ExpenseTransformer($this->account, $this->serializer);
@@ -75,6 +90,10 @@ class ClientTransformer extends EntityTransformer
}
+ /**
+ * @param Client $client
+ * @return array
+ */
public function transform(Client $client)
{
return array_merge($this->getDefaults($client), [
diff --git a/app/Ninja/Transformers/ContactTransformer.php b/app/Ninja/Transformers/ContactTransformer.php
index 68172e156c60..fa0126011690 100644
--- a/app/Ninja/Transformers/ContactTransformer.php
+++ b/app/Ninja/Transformers/ContactTransformer.php
@@ -1,11 +1,16 @@
getDefaults($contact), [
diff --git a/app/Ninja/Transformers/CreditTransformer.php b/app/Ninja/Transformers/CreditTransformer.php
index 39ce5ff1d8f3..9fb303ded2a5 100644
--- a/app/Ninja/Transformers/CreditTransformer.php
+++ b/app/Ninja/Transformers/CreditTransformer.php
@@ -1,11 +1,16 @@
getDefaults($credit), [
diff --git a/app/Ninja/Transformers/DocumentTransformer.php b/app/Ninja/Transformers/DocumentTransformer.php
index 4130bbd6c459..0ab10d12d45a 100644
--- a/app/Ninja/Transformers/DocumentTransformer.php
+++ b/app/Ninja/Transformers/DocumentTransformer.php
@@ -1,11 +1,16 @@
getDefaults($document), [
diff --git a/app/Ninja/Transformers/EntityTransformer.php b/app/Ninja/Transformers/EntityTransformer.php
index 691e6ff67f20..9fd53235b8c3 100644
--- a/app/Ninja/Transformers/EntityTransformer.php
+++ b/app/Ninja/Transformers/EntityTransformer.php
@@ -2,7 +2,6 @@
use Auth;
use App\Models\Account;
-use App\Models\Client;
use League\Fractal\TransformerAbstract;
class EntityTransformer extends TransformerAbstract
diff --git a/app/Ninja/Transformers/ExpenseCategoryTransformer.php b/app/Ninja/Transformers/ExpenseCategoryTransformer.php
index 6ad6e743a376..7d79f30b1013 100644
--- a/app/Ninja/Transformers/ExpenseCategoryTransformer.php
+++ b/app/Ninja/Transformers/ExpenseCategoryTransformer.php
@@ -1,7 +1,6 @@
hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Policies/BankAccountPolicy.php b/app/Policies/BankAccountPolicy.php
index fa5eeff84856..33ca0a22fe9c 100644
--- a/app/Policies/BankAccountPolicy.php
+++ b/app/Policies/BankAccountPolicy.php
@@ -2,12 +2,27 @@
namespace App\Policies;
-class BankAccountPolicy extends EntityPolicy {
- public static function edit($user, $item) {
+use App\Models\User;
+
+/**
+ * Class BankAccountPolicy
+ */
+class BankAccountPolicy extends EntityPolicy
+{
+ /**
+ * @param User $user
+ * @param $item
+ * @return bool
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Policies/DocumentPolicy.php b/app/Policies/DocumentPolicy.php
index 955801f19498..e9d67dd34154 100644
--- a/app/Policies/DocumentPolicy.php
+++ b/app/Policies/DocumentPolicy.php
@@ -2,19 +2,43 @@
namespace App\Policies;
-class DocumentPolicy extends EntityPolicy {
- public static function create($user){
+use App\Models\Document;
+use App\Models\User;
+
+/**
+ * Class DocumentPolicy
+ */
+class DocumentPolicy extends EntityPolicy
+{
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user)
+ {
return !empty($user);
}
-
- public static function view($user, $document) {
- if($user->hasPermission('view_all'))return true;
- if($document->expense){
- if($document->expense->invoice)return $user->can('view', $document->expense->invoice);
- return $user->can('view', $document->expense);
- }
- if($document->invoice)return $user->can('view', $document->invoice);
-
- return $user->owns($item);
+
+ /**
+ * @param User $user
+ * @param Document $document
+ * @return bool
+ */
+ public static function view(User $user, Document $document)
+ {
+ if ($user->hasPermission('view_all')) {
+ return true;
+ }
+ if ($document->expense) {
+ if ($document->expense->invoice) {
+ return $user->can('view', $document->expense->invoice);
+ }
+ return $user->can('view', $document->expense);
+ }
+ if ($document->invoice) {
+ return $user->can('view', $document->invoice);
+ }
+
+ return $user->owns($item);
}
}
\ No newline at end of file
diff --git a/app/Policies/EntityPolicy.php b/app/Policies/EntityPolicy.php
index 4c5e8ded9d07..4b71e459f9e4 100644
--- a/app/Policies/EntityPolicy.php
+++ b/app/Policies/EntityPolicy.php
@@ -2,32 +2,60 @@
namespace App\Policies;
-use App\Models\User;
-use App\Models\EntityModel;
+use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
+/**
+ * Class EntityPolicy
+ */
class EntityPolicy
{
use HandlesAuthorization;
-
- public static function create($user) {
+
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('create_all');
}
-
- public static function edit($user, $item) {
+
+ /**
+ * @param User $user
+ * @param $item
+ *
+ * @return bool
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('edit_all') || $user->owns($item);
}
-
- public static function view($user, $item) {
+
+ /**
+ * @param User $user
+ * @param $item
+ *
+ * @return bool
+ */
+ public static function view(User $user, $item) {
return $user->hasPermission('view_all') || $user->owns($item);
}
-
- public static function viewByOwner($user, $ownerUserId) {
+
+ /**
+ * @param User $user
+ * @param $ownerUserId
+ * @return bool
+ */
+ public static function viewByOwner(User$user, $ownerUserId) {
return $user->hasPermission('view_all') || $user->id == $ownerUserId;
}
-
- public static function editByOwner($user, $ownerUserId) {
+
+ /**
+ * @param User $user
+ * @param $ownerUserId
+ * @return bool
+ */
+ public static function editByOwner(User $user, $ownerUserId) {
return $user->hasPermission('edit_all') || $user->id == $ownerUserId;
}
}
\ No newline at end of file
diff --git a/app/Policies/GenericEntityPolicy.php b/app/Policies/GenericEntityPolicy.php
index ad0e76a6baa4..264867a262d5 100644
--- a/app/Policies/GenericEntityPolicy.php
+++ b/app/Policies/GenericEntityPolicy.php
@@ -2,37 +2,57 @@
namespace App\Policies;
+
use App\Models\User;
use Utils;
-
use Illuminate\Auth\Access\HandlesAuthorization;
+/**
+ * Class GenericEntityPolicy
+ */
class GenericEntityPolicy
{
use HandlesAuthorization;
-
- public static function editByOwner($user, $itemType, $ownerUserId) {
+
+ /**
+ * @param User $user
+ * @param $itemType
+ * @param $ownerUserId
+ * @return bool|mixed
+ */
+ public static function editByOwner(User $user, $itemType, $ownerUserId) {
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'editByOwner')) {
- return call_user_func(array("App\\Policies\\{$itemType}Policy", 'editByOwner'), $user, $ownerUserId);
+ return call_user_func(["App\\Policies\\{$itemType}Policy", 'editByOwner'], $user, $ownerUserId);
}
return false;
}
-
- public static function viewByOwner($user, $itemType, $ownerUserId) {
+
+ /**
+ * @param User $user
+ * @param $itemType
+ * @param $ownerUserId
+ * @return bool|mixed
+ */
+ public static function viewByOwner(User $user, $itemType, $ownerUserId) {
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'viewByOwner')) {
- return call_user_func(array("App\\Policies\\{$itemType}Policy", 'viewByOwner'), $user, $ownerUserId);
+ return call_user_func(["App\\Policies\\{$itemType}Policy", 'viewByOwner'], $user, $ownerUserId);
}
return false;
}
-
- public static function create($user, $itemType) {
+
+ /**
+ * @param User $user
+ * @param $itemType
+ * @return bool|mixed
+ */
+ public static function create(User $user, $itemType) {
$itemType = Utils::getEntityName($itemType);
if (method_exists("App\\Policies\\{$itemType}Policy", 'create')) {
- return call_user_func(array("App\\Policies\\{$itemType}Policy", 'create'), $user);
+ return call_user_func(["App\\Policies\\{$itemType}Policy", 'create'], $user);
}
return false;
diff --git a/app/Policies/PaymentTermPolicy.php b/app/Policies/PaymentTermPolicy.php
index 7acf8bb9ab44..36d1ae210a58 100644
--- a/app/Policies/PaymentTermPolicy.php
+++ b/app/Policies/PaymentTermPolicy.php
@@ -2,12 +2,28 @@
namespace App\Policies;
-class PaymentTermPolicy extends EntityPolicy {
- public static function edit($user, $item) {
+use App\Models\User;
+
+/**
+ * Class PaymentTermPolicy
+ */
+class PaymentTermPolicy extends EntityPolicy
+{
+
+ /**
+ * @param User $user
+ * @param $item
+ * @return mixed
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Policies/ProductPolicy.php b/app/Policies/ProductPolicy.php
index 897fe7404a03..10f8b13eee0e 100644
--- a/app/Policies/ProductPolicy.php
+++ b/app/Policies/ProductPolicy.php
@@ -2,12 +2,28 @@
namespace App\Policies;
-class ProductPolicy extends EntityPolicy {
- public static function edit($user, $item) {
+use App\Models\User;
+
+/**
+ * Class ProductPolicy
+ */
+class ProductPolicy extends EntityPolicy
+{
+
+ /**
+ * @param User $user
+ * @param $item
+ * @return mixed
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ * @return mixed
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Policies/TaxRatePolicy.php b/app/Policies/TaxRatePolicy.php
index 4de8e6ac7ec6..0ce64eca7911 100644
--- a/app/Policies/TaxRatePolicy.php
+++ b/app/Policies/TaxRatePolicy.php
@@ -2,12 +2,24 @@
namespace App\Policies;
-class TaxRatePolicy extends EntityPolicy {
- public static function edit($user, $item) {
+use App\Models\User;
+
+class TaxRatePolicy extends EntityPolicy
+{
+ /**
+ * @param User $user
+ * @param $item
+ * @return bool
+ */
+ public static function edit(User $user, $item) {
return $user->hasPermission('admin');
}
- public static function create($user) {
+ /**
+ * @param User $user
+ * @return bool
+ */
+ public static function create(User $user) {
return $user->hasPermission('admin');
}
}
\ No newline at end of file
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 79e0f5dc032d..f7089370d4fd 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -1,19 +1,18 @@
';
- $items[] = ''.trans("texts.recurring_invoices").'';
- if($user->can('create', ENTITY_INVOICE))$items[] = ''.trans("texts.new_recurring_invoice").'';
+ $items[] = ''.trans('texts.recurring_invoices').'';
+ if($user->can('create', ENTITY_INVOICE))$items[] = ''.trans('texts.new_recurring_invoice').'';
if ($user->hasFeature(FEATURE_QUOTES)) {
$items[] = '';
- $items[] = ''.trans("texts.quotes").'';
- if($user->can('create', ENTITY_INVOICE))$items[] = ''.trans("texts.new_quote").'';
+ $items[] = ''.trans('texts.quotes').'';
+ if($user->can('create', ENTITY_INVOICE))$items[] = ''.trans('texts.new_quote').'';
}
} else if ($type == ENTITY_CLIENT) {
if(!empty($items))$items[] = '';
- $items[] = ''.trans("texts.credits").'';
- if($user->can('create', ENTITY_CREDIT))$items[] = ''.trans("texts.new_credit").'';
+ $items[] = ''.trans('texts.credits').'';
+ if($user->can('create', ENTITY_CREDIT))$items[] = ''.trans('texts.new_credit').'';
} else if ($type == ENTITY_EXPENSE) {
if(!empty($items))$items[] = '';
- $items[] = ''.trans("texts.vendors").'';
- if($user->can('create', ENTITY_VENDOR))$items[] = ''.trans("texts.new_vendor").'';
+ $items[] = ''.trans('texts.vendors').'';
+ if($user->can('create', ENTITY_VENDOR))$items[] = ''.trans('texts.new_vendor').'';
}
if(!empty($items)){
@@ -159,7 +158,7 @@ class AppServiceProvider extends ServiceProvider {
});
Form::macro('human_filesize', function($bytes, $decimals = 1) {
- $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
+ $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
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor];
diff --git a/app/Providers/BusServiceProvider.php b/app/Providers/BusServiceProvider.php
index f0d9be6fe2bd..d0833ff18c82 100644
--- a/app/Providers/BusServiceProvider.php
+++ b/app/Providers/BusServiceProvider.php
@@ -3,32 +3,30 @@
use Illuminate\Bus\Dispatcher;
use Illuminate\Support\ServiceProvider;
-class BusServiceProvider extends ServiceProvider {
-
- /**
- * Bootstrap any application services.
- *
- * @param \Illuminate\Bus\Dispatcher $dispatcher
- * @return void
- */
- public function boot(Dispatcher $dispatcher)
- {
- $dispatcher->mapUsing(function($command)
- {
- return Dispatcher::simpleMapping(
- $command, 'App\Commands', 'App\Handlers\Commands'
- );
- });
- }
-
- /**
- * Register any application services.
- *
- * @return void
- */
- public function register()
- {
- //
- }
+/**
+ * Class BusServiceProvider
+ */
+class BusServiceProvider extends ServiceProvider
+{
+ /**
+ * Bootstrap any application services.
+ *
+ * @param \Illuminate\Bus\Dispatcher $dispatcher
+ * @return void
+ */
+ public function boot(Dispatcher $dispatcher)
+ {
+ $dispatcher->mapUsing(function ($command) {
+ return Dispatcher::simpleMapping(
+ $command, 'App\Commands', 'App\Handlers\Commands'
+ );
+ });
+ }
+ /**
+ * Register any application services.
+ */
+ public function register()
+ {
+ }
}
diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php
index 11d3c8005903..6bc0e304dd0c 100644
--- a/app/Providers/RouteServiceProvider.php
+++ b/app/Providers/RouteServiceProvider.php
@@ -1,46 +1,45 @@
group(['namespace' => $this->namespace], function($router)
- {
- require app_path('Http/routes.php');
- });
- }
+ /**
+ * Define your route model bindings, pattern filters, etc.
+ *
+ * @param \Illuminate\Routing\Router $router
+ * @return void
+ */
+ public function boot(Router $router)
+ {
+ parent::boot($router);
+ }
+ /**
+ * Define the routes for the application.
+ *
+ * @param \Illuminate\Routing\Router $router
+ * @return void
+ */
+ public function map(Router $router)
+ {
+ $router->group(['namespace' => $this->namespace], function ($router) {
+ require app_path('Http/routes.php');
+ });
+ }
}
diff --git a/app/Services/AccountGatewayService.php b/app/Services/AccountGatewayService.php
index 00e3f672e602..758ac8d12e84 100644
--- a/app/Services/AccountGatewayService.php
+++ b/app/Services/AccountGatewayService.php
@@ -1,31 +1,51 @@
accountGatewayRepo = $accountGatewayRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return AccountGatewayRepository
+ */
protected function getRepo()
{
return $this->accountGatewayRepo;
}
+ /**
+ * @param $accountId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($accountId)
{
$query = $this->accountGatewayRepo->find($accountId);
return $this->datatableService->createDatatable(new AccountGatewayDatatable(false), $query);
}
-
}
diff --git a/app/Services/ActivityService.php b/app/Services/ActivityService.php
index 6b06fce73a8b..f3a1ec15aa21 100644
--- a/app/Services/ActivityService.php
+++ b/app/Services/ActivityService.php
@@ -1,22 +1,40 @@
activityRepo = $activityRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @param null $clientPublicId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($clientPublicId = null)
{
$clientId = Client::getPrivateId($clientPublicId);
@@ -25,5 +43,4 @@ class ActivityService extends BaseService
return $this->datatableService->createDatatable(new ActivityDatatable(false), $query);
}
-
}
diff --git a/app/Services/AuthService.php b/app/Services/AuthService.php
index 9b62b1e7008a..d3a550208021 100644
--- a/app/Services/AuthService.php
+++ b/app/Services/AuthService.php
@@ -7,12 +7,20 @@ use Input;
use Socialite;
use App\Ninja\Repositories\AccountRepository;
use App\Events\UserLoggedIn;
-use App\Events\UserSignedUp;
+/**
+ * Class AuthService
+ */
class AuthService
{
+ /**
+ * @var AccountRepository
+ */
private $accountRepo;
+ /**
+ * @var array
+ */
public static $providers = [
1 => SOCIAL_GOOGLE,
2 => SOCIAL_FACEBOOK,
@@ -20,6 +28,11 @@ class AuthService
4 => SOCIAL_LINKEDIN
];
+ /**
+ * AuthService constructor.
+ *
+ * @param AccountRepository $repo
+ */
public function __construct(AccountRepository $repo)
{
$this->accountRepo = $repo;
@@ -27,11 +40,13 @@ class AuthService
public static function getProviders()
{
- $providers = [];
-
-
}
+ /**
+ * @param $provider
+ * @param $hasCode
+ * @return \Illuminate\Http\RedirectResponse
+ */
public function execute($provider, $hasCode)
{
if (!$hasCode) {
@@ -75,16 +90,28 @@ class AuthService
return redirect()->to($redirectTo);
}
+ /**
+ * @param $provider
+ * @return mixed
+ */
private function getAuthorization($provider)
{
return Socialite::driver($provider)->redirect();
}
+ /**
+ * @param $provider
+ * @return mixed
+ */
public static function getProviderId($provider)
{
return array_search(strtolower($provider), array_map('strtolower', AuthService::$providers));
}
+ /**
+ * @param $providerId
+ * @return mixed|string
+ */
public static function getProviderName($providerId)
{
return $providerId ? AuthService::$providers[$providerId] : '';
diff --git a/app/Services/BankAccountService.php b/app/Services/BankAccountService.php
index 9291a36342c3..cae345fdac5f 100644
--- a/app/Services/BankAccountService.php
+++ b/app/Services/BankAccountService.php
@@ -2,12 +2,10 @@
use stdClass;
use Utils;
-use URL;
use Hash;
use App\Models\BankSubaccount;
use App\Models\Vendor;
use App\Models\Expense;
-use App\Services\BaseService;
use App\Ninja\Repositories\BankAccountRepository;
use App\Ninja\Repositories\ExpenseRepository;
use App\Ninja\Repositories\VendorRepository;
@@ -15,13 +13,39 @@ use App\Ninja\Datatables\BankAccountDatatable;
use App\Libraries\Finance;
use App\Libraries\Login;
+/**
+ * Class BankAccountService
+ */
class BankAccountService extends BaseService
{
+ /**
+ * @var BankAccountRepository
+ */
protected $bankAccountRepo;
+
+ /**
+ * @var ExpenseRepository
+ */
protected $expenseRepo;
+
+ /**
+ * @var VendorRepository
+ */
protected $vendorRepo;
+
+ /**
+ * @var DatatableService
+ */
protected $datatableService;
+ /**
+ * BankAccountService constructor.
+ *
+ * @param BankAccountRepository $bankAccountRepo
+ * @param ExpenseRepository $expenseRepo
+ * @param VendorRepository $vendorRepo
+ * @param DatatableService $datatableService
+ */
public function __construct(BankAccountRepository $bankAccountRepo, ExpenseRepository $expenseRepo, VendorRepository $vendorRepo, DatatableService $datatableService)
{
$this->bankAccountRepo = $bankAccountRepo;
@@ -30,11 +54,18 @@ class BankAccountService extends BaseService
$this->datatableService = $datatableService;
}
+ /**
+ * @return BankAccountRepository
+ */
protected function getRepo()
{
return $this->bankAccountRepo;
}
+ /**
+ * @param null $bankId
+ * @return array
+ */
private function getExpenses($bankId = null)
{
$expenses = Expense::scope()
@@ -50,6 +81,13 @@ class BankAccountService extends BaseService
return $expenses;
}
+ /**
+ * @param $bankId
+ * @param $username
+ * @param $password
+ * @param bool $includeTransactions
+ * @return array|bool
+ */
public function loadBankAccounts($bankId, $username, $password, $includeTransactions = true)
{
if (! $bankId || ! $username || ! $password) {
@@ -90,6 +128,14 @@ class BankAccountService extends BaseService
}
}
+ /**
+ * @param $account
+ * @param $bankAccounts
+ * @param $expenses
+ * @param $includeTransactions
+ * @param $vendorMap
+ * @return bool|stdClass
+ */
private function parseBankAccount($account, $bankAccounts, $expenses, $includeTransactions, $vendorMap)
{
$obj = new stdClass();
@@ -119,6 +165,13 @@ class BankAccountService extends BaseService
return $obj;
}
+ /**
+ * @param $account
+ * @param $data
+ * @param $expenses
+ * @param $vendorMap
+ * @return mixed
+ */
private function parseTransactions($account, $data, $expenses, $vendorMap)
{
$ofxParser = new \OfxParser\Parser();
@@ -153,11 +206,19 @@ class BankAccountService extends BaseService
return $account;
}
+ /**
+ * @param $value
+ * @return string
+ */
private function prepareValue($value)
{
return ucwords(strtolower(trim($value)));
}
+ /**
+ * @param $data
+ * @return mixed
+ */
public function parseOFX($data)
{
$account = new stdClass;
@@ -167,6 +228,9 @@ class BankAccountService extends BaseService
return $this->parseTransactions($account, $data, $expenses, $vendorMap);
}
+ /**
+ * @return array
+ */
private function createVendorMap()
{
$vendorMap = [];
diff --git a/app/Services/BaseService.php b/app/Services/BaseService.php
index e6dad06334bd..5eda427119bd 100644
--- a/app/Services/BaseService.php
+++ b/app/Services/BaseService.php
@@ -2,17 +2,27 @@
use Auth;
use Illuminate\Foundation\Bus\DispatchesJobs;
-use App\Services\DatatableService;
+/**
+ * Class BaseService
+ */
class BaseService
{
use DispatchesJobs;
+ /**
+ * @return null
+ */
protected function getRepo()
{
return null;
}
+ /**
+ * @param $ids
+ * @param $action
+ * @return int
+ */
public function bulk($ids, $action)
{
if ( ! $ids ) {
@@ -29,5 +39,4 @@ class BaseService
return count($entities);
}
-
}
diff --git a/app/Services/ClientService.php b/app/Services/ClientService.php
index 065258d05abb..2e3ceedafab9 100644
--- a/app/Services/ClientService.php
+++ b/app/Services/ClientService.php
@@ -1,24 +1,31 @@
clientRepo = $clientRepo;
@@ -26,11 +33,19 @@ class ClientService extends BaseService
$this->datatableService = $datatableService;
}
+ /**
+ * @return ClientRepository
+ */
protected function getRepo()
{
return $this->clientRepo;
}
+ /**
+ * @param $data
+ * @param null $client
+ * @return mixed|null
+ */
public function save($data, $client = null)
{
if (Auth::user()->account->isNinjaAccount() && isset($data['plan'])) {
@@ -40,6 +55,11 @@ class ClientService extends BaseService
return $this->clientRepo->save($data, $client);
}
+ /**
+ * @param $search
+ * @param $userId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($search, $userId)
{
$datatable = new ClientDatatable();
@@ -48,5 +68,4 @@ class ClientService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/CreditService.php b/app/Services/CreditService.php
index a1e1a5db40ab..b355d5f78ccc 100644
--- a/app/Services/CreditService.php
+++ b/app/Services/CreditService.php
@@ -1,35 +1,59 @@
creditRepo = $creditRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return CreditRepository
+ */
protected function getRepo()
{
return $this->creditRepo;
}
+ /**
+ * @param $data
+ * @return mixed|null
+ */
public function save($data)
{
return $this->creditRepo->save($data);
}
+ /**
+ * @param $clientPublicId
+ * @param $search
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($clientPublicId, $search)
{
// we don't support bulk edit and hide the client on the individual client page
diff --git a/app/Services/DatatableService.php b/app/Services/DatatableService.php
index 5126bd48d6a9..5b2750d91e59 100644
--- a/app/Services/DatatableService.php
+++ b/app/Services/DatatableService.php
@@ -1,17 +1,25 @@
isBulkEdit) {
$table->addColumn('checkbox', function ($model) {
@@ -33,11 +41,6 @@ class DatatableService
if ($visible) {
$table->addColumn($field, $value);
$orderColumns[] = $field;
- /*
- if ($calculateOrderColumns) {
- $orderColumns[] = $field;
- }
- */
}
}
@@ -48,8 +51,11 @@ class DatatableService
return $table->orderColumns($orderColumns)->make();
}
- //private function createDropdown($entityType, $table, $actions)
- private function createDropdown(EntityDatatable $datatable, $table)
+ /**
+ * @param EntityDatatable $datatable
+ * @param Table $table
+ */
+ private function createDropdown(EntityDatatable $datatable, Table $table)
{
$table->addColumn('dropdown', function ($model) use ($datatable) {
$hasAction = false;
@@ -79,7 +85,7 @@ class DatatableService
list($value, $url, $visible) = $action;
if ($visible($model)) {
if($value == '--divider--'){
- $dropdown_contents .= "";
+ $dropdown_contents .= '';
$lastIsDivider = true;
}
else {
@@ -96,7 +102,7 @@ class DatatableService
}
}
} elseif ( ! $lastIsDivider) {
- $dropdown_contents .= "";
+ $dropdown_contents .= '';
$lastIsDivider = true;
}
}
@@ -106,21 +112,21 @@ class DatatableService
}
if ( $can_edit && ! $lastIsDivider) {
- $dropdown_contents .= "";
+ $dropdown_contents .= '';
}
if (($datatable->entityType != ENTITY_USER || $model->public_id) && $can_edit) {
$dropdown_contents .= "public_id})\">"
- . trans("texts.archive_{$datatable->entityType}") . "";
+ . trans("texts.archive_{$datatable->entityType}") . '';
}
} else if($can_edit) {
$dropdown_contents .= "public_id})\">"
- . trans("texts.restore_{$datatable->entityType}") . "";
+ . trans("texts.restore_{$datatable->entityType}") . '';
}
if (property_exists($model, 'is_deleted') && !$model->is_deleted && $can_edit) {
$dropdown_contents .= "public_id})\">"
- . trans("texts.delete_{$datatable->entityType}") . "";
+ . trans("texts.delete_{$datatable->entityType}") . '';
}
if (!empty($dropdown_contents)) {
diff --git a/app/Services/EmailService.php b/app/Services/EmailService.php
index 47e130810496..c148dbdede1c 100644
--- a/app/Services/EmailService.php
+++ b/app/Services/EmailService.php
@@ -4,19 +4,34 @@ use Carbon;
use App\Models\Invitation;
use App\Ninja\Mailers\UserMailer;
-class EmailService {
-
+/**
+ * Class EmailService
+ */
+class EmailService
+{
+ /**
+ * @var UserMailer
+ */
protected $userMailer;
+ /**
+ * EmailService constructor.
+ *
+ * @param UserMailer $userMailer
+ */
public function __construct(UserMailer $userMailer)
{
$this->userMailer = $userMailer;
}
+ /**
+ * @param $messageId
+ * @return bool
+ */
public function markOpened($messageId)
{
- $invitation = Invitation::whereMessageId($messageId)
- ->first();
+ /** @var \App\Models\Invitation $invitation */
+ $invitation = Invitation::whereMessageId($messageId)->first();
if (!$invitation) {
return false;
@@ -28,8 +43,14 @@ class EmailService {
return true;
}
+ /**
+ * @param $messageId
+ * @param $error
+ * @return bool
+ */
public function markBounced($messageId, $error)
{
+ /** @var \App\Models\Invitation $invitation */
$invitation = Invitation::with('user', 'invoice', 'contact')
->whereMessageId($messageId)
->first();
diff --git a/app/Services/ExpenseService.php b/app/Services/ExpenseService.php
index a16bff7dd3f1..78cf275d9749 100644
--- a/app/Services/ExpenseService.php
+++ b/app/Services/ExpenseService.php
@@ -1,34 +1,52 @@
expenseRepo = $expenseRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return ExpenseRepository
+ */
protected function getRepo()
{
return $this->expenseRepo;
}
+ /**
+ * @param $data
+ * @param null $expense
+ * @return mixed|null
+ */
public function save($data, $expense = null)
{
if (isset($data['client_id']) && $data['client_id']) {
@@ -42,6 +60,10 @@ class ExpenseService extends BaseService
return $this->expenseRepo->save($data, $expense);
}
+ /**
+ * @param $search
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($search)
{
$query = $this->expenseRepo->find($search);
@@ -53,6 +75,10 @@ class ExpenseService extends BaseService
return $this->datatableService->createDatatable(new ExpenseDatatable(), $query);
}
+ /**
+ * @param $vendorPublicId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatableVendor($vendorPublicId)
{
$datatable = new ExpenseDatatable(false, true);
@@ -65,41 +91,4 @@ class ExpenseService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
-
- protected function getDatatableColumnsVendor($entityType, $hideClient)
- {
- return [
- [
- 'expense_date',
- function ($model) {
- return Utils::dateToString($model->expense_date);
- }
- ],
- [
- 'amount',
- function ($model) {
- return Utils::formatMoney($model->amount, false, false);
- }
- ],
- [
- 'public_notes',
- function ($model) {
- return $model->public_notes != null ? $model->public_notes : '';
- }
- ],
- [
- 'invoice_id',
- function ($model) {
- return '';
- }
- ],
- ];
- }
-
- protected function getDatatableActionsVendor($entityType)
- {
- return [];
- }
-
}
diff --git a/app/Services/ImportService.php b/app/Services/ImportService.php
index 147a63cdeb08..4f089768715c 100644
--- a/app/Services/ImportService.php
+++ b/app/Services/ImportService.php
@@ -1,5 +1,6 @@
productRepo = $productRepo;
}
+ /**
+ * @param $file
+ * @return array
+ * @throws Exception
+ */
public function importJSON($file)
{
$this->init();
@@ -121,6 +175,10 @@ class ImportService
return $this->results;
}
+ /**
+ * @param $array
+ * @return mixed
+ */
public function removeIdFields($array)
{
foreach ($array as $key => $val) {
@@ -133,6 +191,11 @@ class ImportService
return $array;
}
+ /**
+ * @param $source
+ * @param $files
+ * @return array
+ */
public function importFiles($source, $files)
{
$results = [];
@@ -146,6 +209,12 @@ class ImportService
return $results;
}
+ /**
+ * @param $source
+ * @param $entityType
+ * @param $file
+ * @return array
+ */
private function execute($source, $entityType, $file)
{
$results = [
@@ -154,7 +223,7 @@ class ImportService
];
// Convert the data
- $row_list = array();
+ $row_list = [];
Excel::load($file, function ($reader) use ($source, $entityType, &$row_list, &$results) {
$this->checkData($entityType, count($reader->all()));
@@ -165,7 +234,7 @@ class ImportService
if ($data_index !== false) {
if ($data_index !== true) {
// Wasn't merged with another row
- $row_list[] = array('row' => $row, 'data_index' => $data_index);
+ $row_list[] = ['row' => $row, 'data_index' => $data_index];
}
} else {
$results[RESULT_FAILURE][] = $row;
@@ -186,6 +255,12 @@ class ImportService
return $results;
}
+ /**
+ * @param $source
+ * @param $entityType
+ * @param $row
+ * @return bool|mixed
+ */
private function transformRow($source, $entityType, $row)
{
$transformer = $this->getTransformer($source, $entityType, $this->maps);
@@ -226,6 +301,13 @@ class ImportService
return key($this->processedRows);
}
+ /**
+ * @param $source
+ * @param $entityType
+ * @param $row
+ * @param $data_index
+ * @return mixed
+ */
private function saveData($source, $entityType, $row, $data_index)
{
$data = $this->processedRows[$data_index];
@@ -243,6 +325,11 @@ class ImportService
return $entity;
}
+ /**
+ * @param $entityType
+ * @param $count
+ * @throws Exception
+ */
private function checkData($entityType, $count)
{
if ($entityType === ENTITY_CLIENT) {
@@ -250,6 +337,10 @@ class ImportService
}
}
+ /**
+ * @param $count
+ * @throws Exception
+ */
private function checkClientCount($count)
{
$totalClients = $count + Client::scope()->withTrashed()->count();
@@ -258,11 +349,22 @@ class ImportService
}
}
+ /**
+ * @param $source
+ * @param $entityType
+ * @return string
+ */
public static function getTransformerClassName($source, $entityType)
{
return 'App\\Ninja\\Import\\'.$source.'\\'.ucwords($entityType).'Transformer';
}
+ /**
+ * @param $source
+ * @param $entityType
+ * @param $maps
+ * @return mixed
+ */
public static function getTransformer($source, $entityType, $maps)
{
$className = self::getTransformerClassName($source, $entityType);
@@ -270,6 +372,12 @@ class ImportService
return new $className($maps);
}
+ /**
+ * @param $source
+ * @param $data
+ * @param $clientId
+ * @param $invoiceId
+ */
private function createPayment($source, $data, $clientId, $invoiceId)
{
$paymentTransformer = $this->getTransformer($source, ENTITY_PAYMENT, $this->maps);
@@ -283,29 +391,13 @@ class ImportService
}
}
+ /**
+ * @param $data
+ * @param $entityType
+ * @return bool|string
+ */
private function validate($data, $entityType)
{
- /*
- // Harvest's contacts are listed separately
- if ($entityType === ENTITY_CLIENT && $source != IMPORT_HARVEST) {
- $rules = [
- 'contacts' => 'valid_contacts',
- ];
- }
- if ($entityType === ENTITY_INVOICE) {
- $rules = [
- 'client.contacts' => 'valid_contacts',
- 'invoice_items' => 'valid_invoice_items',
- 'invoice_number' => 'required|unique:invoices,invoice_number,,id,account_id,'.Auth::user()->account_id,
- 'discount' => 'positive',
- ];
- }
- if ($entityType === ENTITY_PRODUCT) {
- $rules = [
- 'product_key' => 'required',
- ];
- }
- */
$requestClass = 'App\\Http\\Requests\\Create' . ucwords($entityType) . 'Request';
$request = new $requestClass();
$request->setUserResolver(function() { return Auth::user(); });
@@ -320,12 +412,17 @@ class ImportService
}
}
- public function mapCSV($files)
+ /**
+ * @param array $files
+ * @return array
+ * @throws Exception
+ */
+ public function mapCSV(array $files)
{
$data = [];
foreach ($files as $entityType => $filename) {
- $class = "App\\Models\\" . ucwords($entityType);
+ $class = 'App\\Models\\' . ucwords($entityType);
$columns = $class::getImportColumns();
$map = $class::getImportMap();
@@ -348,6 +445,13 @@ class ImportService
return $data;
}
+ /**
+ * @param $entityType
+ * @param $filename
+ * @param $columns
+ * @param $map
+ * @return array
+ */
public function mapFile($entityType, $filename, $columns, $map)
{
require_once app_path().'/Includes/parsecsv.lib.php';
@@ -359,7 +463,7 @@ class ImportService
$headers = false;
$hasHeaders = false;
- $mapped = array();
+ $mapped = [];
if (count($csv->data) > 0) {
$headers = $csv->data[0];
@@ -385,18 +489,23 @@ class ImportService
}
}
- $data = array(
+ $data = [
'entityType' => $entityType,
'data' => $csv->data,
'headers' => $headers,
'hasHeaders' => $hasHeaders,
'columns' => $columns,
'mapped' => $mapped,
- );
+ ];
return $data;
}
+ /**
+ * @param $column
+ * @param $pattern
+ * @return bool
+ */
private function checkForMatch($column, $pattern)
{
if (strpos($column, 'sec') === 0) {
@@ -430,7 +539,12 @@ class ImportService
return false;
}
- public function importCSV($maps, $headers)
+ /**
+ * @param array $maps
+ * @param $headers
+ * @return array
+ */
+ public function importCSV(array $maps, $headers)
{
$results = [];
@@ -441,6 +555,12 @@ class ImportService
return $results;
}
+ /**
+ * @param $entityType
+ * @param $map
+ * @param $hasHeaders
+ * @return array
+ */
private function executeCSV($entityType, $map, $hasHeaders)
{
$results = [
@@ -454,7 +574,7 @@ class ImportService
$this->initMaps();
// Convert the data
- $row_list = array();
+ $row_list = [];
foreach ($data as $row) {
if ($hasHeaders) {
$hasHeaders = false;
@@ -467,7 +587,7 @@ class ImportService
if ($data_index !== false) {
if ($data_index !== true) {
// Wasn't merged with another row
- $row_list[] = array('row' => $row, 'data_index' => $data_index);
+ $row_list[] = ['row' => $row, 'data_index' => $data_index];
}
} else {
$results[RESULT_FAILURE][] = $row;
@@ -490,10 +610,16 @@ class ImportService
return $results;
}
+ /**
+ * @param $entityType
+ * @param $data
+ * @param $map
+ * @return stdClass
+ */
private function convertToObject($entityType, $data, $map)
{
$obj = new stdClass();
- $class = "App\\Models\\" . ucwords($entityType);
+ $class = 'App\\Models\\' . ucwords($entityType);
$columns = $class::getImportColumns();
foreach ($columns as $column) {
@@ -515,11 +641,18 @@ class ImportService
return $obj;
}
+ /**
+ * @param $entity
+ */
private function addSuccess($entity)
{
$this->results[$entity->getEntityType()][RESULT_SUCCESS][] = $entity;
}
+ /**
+ * @param $entityType
+ * @param $data
+ */
private function addFailure($entityType, $data)
{
$this->results[$entityType][RESULT_FAILURE][] = $data;
@@ -580,7 +713,10 @@ class ImportService
}
}
- private function addInvoiceToMaps($invoice)
+ /**
+ * @param Invoice $invoice
+ */
+ private function addInvoiceToMaps(Invoice $invoice)
{
if ($number = strtolower(trim($invoice->invoice_number))) {
$this->maps['invoice'][$number] = $invoice->id;
@@ -589,7 +725,10 @@ class ImportService
}
}
- private function addClientToMaps($client)
+ /**
+ * @param Client $client
+ */
+ private function addClientToMaps(Client $client)
{
if ($name = strtolower(trim($client->name))) {
$this->maps['client'][$name] = $client->id;
@@ -597,7 +736,10 @@ class ImportService
}
}
- private function addProductToMaps($product)
+ /**
+ * @param Product $product
+ */
+ private function addProductToMaps(Product $product)
{
if ($key = strtolower(trim($product->product_key))) {
$this->maps['product'][$key] = $product->id;
diff --git a/app/Services/InvoiceService.php b/app/Services/InvoiceService.php
index d5a2ab7f1218..13c6f2e76708 100644
--- a/app/Services/InvoiceService.php
+++ b/app/Services/InvoiceService.php
@@ -1,37 +1,64 @@
clientRepo = $clientRepo;
$this->invoiceRepo = $invoiceRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return InvoiceRepository
+ */
protected function getRepo()
{
return $this->invoiceRepo;
}
- public function save($data, $invoice = null)
+ /**
+ * @param array $data
+ * @param Invoice|null $invoice
+ * @return \App\Models\Invoice|Invoice|mixed
+ */
+ public function save(array $data, Invoice $invoice = null)
{
if (isset($data['client'])) {
$canSaveClient = false;
@@ -81,7 +108,12 @@ class InvoiceService extends BaseService
return $invoice;
}
- public function convertQuote($quote, $invitation = null)
+ /**
+ * @param $quote
+ * @param Invitation|null $invitation
+ * @return mixed
+ */
+ public function convertQuote($quote, Invitation $invitation = null)
{
$invoice = $this->invoiceRepo->cloneInvoice($quote, $quote->id);
if (!$invitation) {
@@ -95,7 +127,12 @@ class InvoiceService extends BaseService
}
}
- public function approveQuote($quote, $invitation = null)
+ /**
+ * @param $quote
+ * @param Invitation|null $invitation
+ * @return mixed|null
+ */
+ public function approveQuote($quote, Invitation $invitation = null)
{
$account = $quote->account;
diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php
index 0ada659acd27..107fec533dd0 100644
--- a/app/Services/PaymentService.php
+++ b/app/Services/PaymentService.php
@@ -1,51 +1,71 @@
datatableService = $datatableService;
$this->paymentRepo = $paymentRepo;
$this->accountRepo = $accountRepo;
}
+ /**
+ * @return PaymentRepository
+ */
protected function getRepo()
{
return $this->paymentRepo;
}
- public function autoBillInvoice($invoice)
+ /**
+ * @param Invoice $invoice
+ * @return bool
+ */
+ public function autoBillInvoice(Invoice $invoice)
{
+ /** @var \App\Models\Client $client */
$client = $invoice->client;
+
+ /** @var \App\Models\Account $account */
$account = $client->account;
+
+ /** @var \App\Models\Invitation $invitation */
$invitation = $invoice->invitations->first();
if ( ! $invitation) {
@@ -95,14 +115,7 @@ class PaymentService extends BaseService
}
}
-
return $paymentDriver->completeOnsitePurchase(false, $paymentMethod);
-
- /*
- if ($accountGateway->gateway_id == GATEWAY_WEPAY) {
- $details['transaction_id'] = 'autobill_'.$invoice->id;
- }
- */
}
public function getDatatable($clientPublicId, $search)
@@ -118,7 +131,7 @@ class PaymentService extends BaseService
}
- public function bulk($ids, $action, $params = array())
+ public function bulk($ids, $action, $params = [])
{
if ($action == 'refund') {
if ( ! $ids ) {
diff --git a/app/Services/PaymentTermService.php b/app/Services/PaymentTermService.php
index 08e2a84caf4b..c3d49a236005 100644
--- a/app/Services/PaymentTermService.php
+++ b/app/Services/PaymentTermService.php
@@ -1,8 +1,6 @@
paymentTermRepo = $paymentTermRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return PaymentTermRepository
+ */
protected function getRepo()
{
return $this->paymentTermRepo;
}
+ /**
+ * @param int $accountId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($accountId = 0)
{
$query = $this->paymentTermRepo->find();
diff --git a/app/Services/ProductService.php b/app/Services/ProductService.php
index fc7fc6cceed4..220ac08a60a9 100644
--- a/app/Services/ProductService.php
+++ b/app/Services/ProductService.php
@@ -1,36 +1,44 @@
datatableService = $datatableService;
$this->productRepo = $productRepo;
}
+ /**
+ * @return ProductRepository
+ */
protected function getRepo()
{
return $this->productRepo;
}
- /*
- public function save()
- {
- return null;
- }
- */
-
+ /**
+ * @param $accountId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($accountId)
{
$datatable = new ProductDatatable(false);
@@ -38,5 +46,4 @@ class ProductService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/PushService.php b/app/Services/PushService.php
index 2edd86af4be8..017426814bd8 100644
--- a/app/Services/PushService.php
+++ b/app/Services/PushService.php
@@ -2,28 +2,18 @@
namespace App\Services;
-use Illuminate\Http\Request;
+use App\Models\Account;
+use App\Models\Invoice;
use App\Ninja\Notifications\PushFactory;
+
/**
* Class PushService
- * @package App\Ninja\Notifications
*/
-
-
-/**
- * $account->devices Definition
- *
- * @param string token (push notification device token)
- * @param string email (user email address - required for use as key)
- * @param string device (ios, gcm etc etc)
- * @param bool notify_sent
- * @param bool notify_paid
- * @param bool notify_approved
- * @param bool notify_viewed
- */
-
class PushService
{
+ /**
+ * @var PushFactory
+ */
protected $pushFactory;
/**
@@ -35,11 +25,10 @@ class PushService
}
/**
- * @param $invoice - Invoice object
- * @param $type - Type of notification, ie. Quote APPROVED, Invoice PAID, Invoice/Quote SENT, Invoice/Quote VIEWED
+ * @param Invoice $invoice
+ * @param $type
*/
-
- public function sendNotification($invoice, $type)
+ public function sendNotification(Invoice $invoice, $type)
{
if (! IOS_PUSH_CERTIFICATE) {
return;
@@ -57,35 +46,32 @@ class PushService
if(($device["notify_{$type}"] == TRUE) && ($device['device'] == 'ios'))
$this->pushMessage($invoice, $device['token'], $type);
}
-
-
}
-
/**
* pushMessage function
*
* method to dispatch iOS notifications
*
- * @param $invoice
+ * @param Invoice $invoice
* @param $token
* @param $type
*/
- private function pushMessage($invoice, $token, $type)
+ private function pushMessage(Invoice $invoice, $token, $type)
{
$this->pushFactory->message($token, $this->messageType($invoice, $type));
}
-
/**
* checkDeviceExists function
*
* Returns a boolean if this account has devices registered for PUSH notifications
*
- * @param $account
+ * @param Account $account
+ *
* @return bool
*/
- private function checkDeviceExists($account)
+ private function checkDeviceExists(Account $account)
{
$devices = json_decode($account->devices, TRUE);
@@ -100,11 +86,12 @@ class PushService
*
* method which formats an appropriate message depending on message type
*
- * @param $invoice
+ * @param Invoice $invoice
* @param $type
+ *
* @return string
*/
- private function messageType($invoice, $type)
+ private function messageType(Invoice $invoice, $type)
{
switch($type)
{
@@ -127,49 +114,44 @@ class PushService
}
/**
- * @param $invoice
+ * @param Invoice $invoice
* @return string
*/
- private function entitySentMessage($invoice)
+ private function entitySentMessage(Invoice $invoice)
{
if($invoice->isType(INVOICE_TYPE_QUOTE))
- return trans("texts.notification_quote_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
+ return trans('texts.notification_quote_sent_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
else
- return trans("texts.notification_invoice_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
-
+ return trans('texts.notification_invoice_sent_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
- * @param $invoice
+ * @param Invoice $invoice
* @return string
*/
- private function invoicePaidMessage($invoice)
+ private function invoicePaidMessage(Invoice $invoice)
{
- return trans("texts.notification_invoice_paid_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
+ return trans('texts.notification_invoice_paid_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
- * @param $invoice
+ * @param Invoice $invoice
* @return string
*/
- private function quoteApprovedMessage($invoice)
+ private function quoteApprovedMessage(Invoice $invoice)
{
- return trans("texts.notification_quote_approved_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
+ return trans('texts.notification_quote_approved_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
}
/**
- * @param $invoice
+ * @param Invoice $invoice
* @return string
*/
- private function entityViewedMessage($invoice)
+ private function entityViewedMessage(Invoice $invoice)
{
if($invoice->isType(INVOICE_TYPE_QUOTE))
- return trans("texts.notification_quote_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
+ return trans('texts.notification_quote_viewed_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
else
- return trans("texts.notification_invoice_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
-
+ 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 bc6daa1f0178..659870f60bf4 100644
--- a/app/Services/RecurringInvoiceService.php
+++ b/app/Services/RecurringInvoiceService.php
@@ -1,9 +1,7 @@
taskRepo = $taskRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return TaskRepository
+ */
protected function getRepo()
{
return $this->taskRepo;
}
- /*
- public function save()
- {
- return null;
- }
- */
-
+ /**
+ * @param $clientPublicId
+ * @param $search
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($clientPublicId, $search)
{
$datatable = new TaskDatatable( ! $clientPublicId, $clientPublicId);
@@ -44,5 +49,4 @@ class TaskService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/TaxRateService.php b/app/Services/TaxRateService.php
index 330477149462..7b1613282766 100644
--- a/app/Services/TaxRateService.php
+++ b/app/Services/TaxRateService.php
@@ -1,27 +1,47 @@
taxRateRepo = $taxRateRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return TaxRateRepository
+ */
protected function getRepo()
{
return $this->taxRateRepo;
}
+ /**
+ * @param $accountId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($accountId)
{
$datatable = new TaxRateDatatable(false);
@@ -29,5 +49,4 @@ class TaxRateService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php
index 564eb76da6dd..d6a3f12ea270 100644
--- a/app/Services/TemplateService.php
+++ b/app/Services/TemplateService.php
@@ -7,11 +7,22 @@ use App\Models\Gateway;
class TemplateService
{
- public function processVariables($template, $data)
+ /**
+ * @param $template
+ * @param array $data
+ * @return mixed|string
+ */
+ public function processVariables($template, array $data)
{
+ /** @var \App\Models\Account $account */
$account = $data['account'];
+
+ /** @var \App\Models\Client $client */
$client = $data['client'];
+
+ /** @var \App\Models\Invitation $invitation */
$invitation = $data['invitation'];
+
$invoice = $invitation->invoice;
$passwordHTML = isset($data['password'])?''.trans('texts.password').': '.$data['password'].'
':false;
$documentsHTML = '';
diff --git a/app/Services/TokenService.php b/app/Services/TokenService.php
index 5d5b29e3de6c..c09023590199 100644
--- a/app/Services/TokenService.php
+++ b/app/Services/TokenService.php
@@ -1,26 +1,47 @@
tokenRepo = $tokenRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return TokenRepository
+ */
protected function getRepo()
{
return $this->tokenRepo;
}
+ /**
+ * @param $userId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($userId)
{
$datatable = new TokenDatatable(false);
@@ -28,5 +49,4 @@ class TokenService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/UserService.php b/app/Services/UserService.php
index 3aa7a60c8851..f01764510ab8 100644
--- a/app/Services/UserService.php
+++ b/app/Services/UserService.php
@@ -1,26 +1,47 @@
userRepo = $userRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return UserRepository
+ */
protected function getRepo()
{
return $this->userRepo;
}
+ /**
+ * @param $accountId
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($accountId)
{
$datatable = new UserDatatable(false);
@@ -28,5 +49,4 @@ class UserService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}
diff --git a/app/Services/VendorService.php b/app/Services/VendorService.php
index 0940be420cb4..51f81d33d655 100644
--- a/app/Services/VendorService.php
+++ b/app/Services/VendorService.php
@@ -1,33 +1,59 @@
vendorRepo = $vendorRepo;
$this->ninjaRepo = $ninjaRepo;
$this->datatableService = $datatableService;
}
+ /**
+ * @return VendorRepository
+ */
protected function getRepo()
{
return $this->vendorRepo;
}
- public function save($data, $vendor = null)
+ /**
+ * @param array $data
+ * @param Vendor|null $vendor
+ * @return mixed|null
+ */
+ public function save(array $data, Vendor $vendor = null)
{
if (Auth::user()->account->isNinjaAccount() && isset($data['plan'])) {
$this->ninjaRepo->updatePlanDetails($data['public_id'], $data);
@@ -36,6 +62,10 @@ class VendorService extends BaseService
return $this->vendorRepo->save($data, $vendor);
}
+ /**
+ * @param $search
+ * @return \Illuminate\Http\JsonResponse
+ */
public function getDatatable($search)
{
$datatable = new VendorDatatable();
@@ -47,5 +77,4 @@ class VendorService extends BaseService
return $this->datatableService->createDatatable($datatable, $query);
}
-
}