1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Code Refactoring

- Removed unused uses
- Type hinting for method parameters
- Removed commented code
- Introduced comments for classes and methods
- Short array syntax
This commit is contained in:
Holger Lösken 2016-07-03 18:11:58 +02:00
parent 5f433f2ed9
commit eb049d8ee6
340 changed files with 6586 additions and 2129 deletions

View File

@ -1,22 +1,47 @@
<?php namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\AccountRepository;
use App\Services\PaymentService;
use App\Models\Invoice;
/**
* Class ChargeRenewalInvoices
*/
class ChargeRenewalInvoices extends Command
{
/**
* @var string
*/
protected $name = 'ninja:charge-renewals';
/**
* @var string
*/
protected $description = 'Charge renewal invoices';
/**
* @var Mailer
*/
protected $mailer;
/**
* @var AccountRepository
*/
protected $accountRepo;
/**
* @var PaymentService
*/
protected $paymentService;
/**
* ChargeRenewalInvoices constructor.
* @param Mailer $mailer
* @param AccountRepository $repo
* @param PaymentService $paymentService
*/
public function __construct(Mailer $mailer, AccountRepository $repo, PaymentService $paymentService)
{
parent::__construct();
@ -47,17 +72,19 @@ class ChargeRenewalInvoices 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 [];
}
}

View File

@ -1,11 +1,9 @@
<?php namespace App\Console\Commands;
use DB;
use DateTime;
use Carbon;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/*
@ -38,9 +36,19 @@ Options:
*/
/**
* Class CheckData
*/
class CheckData extends Command {
/**
* @var string
*/
protected $name = 'ninja:check-data';
/**
* @var string
*/
protected $description = 'Check/fix data';
public function fire()
@ -101,7 +109,7 @@ class CheckData extends Command {
}
$records = $records->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],
];
}
}

View File

@ -1,28 +1,43 @@
<?php namespace App\Console\Commands;
use stdClass;
use Auth;
use DB;
use Utils;
use Artisan;
use Illuminate\Console\Command;
use Faker\Factory;
use App\Models\User;
use App\Ninja\Repositories\ClientRepository;
use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Repositories\PaymentRepository;
use App\Ninja\Repositories\VendorRepository;
use App\Ninja\Repositories\ExpenseRepository;
/**
* Class CreateTestData
*/
class CreateTestData extends Command
{
//protected $name = 'ninja:create-test-data';
/**
* @var string
*/
protected $description = 'Create Test Data';
/**
* @var string
*/
protected $signature = 'ninja:create-test-data {count=1}';
/**
* @var
*/
protected $token;
/**
* CreateTestData constructor.
* @param ClientRepository $clientRepo
* @param InvoiceRepository $invoiceRepo
* @param PaymentRepository $paymentRepo
* @param VendorRepository $vendorRepo
* @param ExpenseRepository $expenseRepo
*/
public function __construct(
ClientRepository $clientRepo,
InvoiceRepository $invoiceRepo,
@ -41,6 +56,9 @@ class CreateTestData extends Command
$this->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 [];
}
}

View File

@ -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 [];
}
}

View File

@ -3,6 +3,9 @@
use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
/**
* Class Inspire
*/
class Inspire extends Command {
/**

View File

@ -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 [];
}
}

View File

@ -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 [];
}
}

View File

@ -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');
}
}

View File

@ -1,26 +1,48 @@
<?php namespace App\Console\Commands;
use DateTime;
use Carbon;
use Utils;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\InvoiceRepository;
use App\Services\PaymentService;
use App\Models\Invoice;
use App\Models\InvoiceItem;
use App\Models\Invitation;
/**
* Class SendRecurringInvoices
*/
class SendRecurringInvoices extends Command
{
/**
* @var string
*/
protected $name = 'ninja:send-invoices';
/**
* @var string
*/
protected $description = 'Send recurring invoices';
/**
* @var Mailer
*/
protected $mailer;
/**
* @var InvoiceRepository
*/
protected $invoiceRepo;
/**
* @var PaymentService
*/
protected $paymentService;
/**
* SendRecurringInvoices constructor.
* @param Mailer $mailer
* @param InvoiceRepository $invoiceRepo
* @param PaymentService $paymentService
*/
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, PaymentService $paymentService)
{
parent::__construct();
@ -36,7 +58,7 @@ class SendRecurringInvoices extends Command
$today = new DateTime();
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client', 'user')
->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 [];
}
}

View File

@ -1,23 +1,47 @@
<?php namespace App\Console\Commands;
use DB;
use DateTime;
use App\Models\Invoice;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use App\Models\Account;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\accountRepository;
use App\Ninja\Repositories\AccountRepository;
use App\Ninja\Repositories\InvoiceRepository;
/**
* Class SendReminders
*/
class SendReminders extends Command
{
/**
* @var string
*/
protected $name = 'ninja:send-reminders';
/**
* @var string
*/
protected $description = 'Send reminder emails';
/**
* @var Mailer
*/
protected $mailer;
/**
* @var InvoiceRepository
*/
protected $invoiceRepo;
/**
* @var accountRepository
*/
protected $accountRepo;
/**
* SendReminders constructor.
* @param Mailer $mailer
* @param InvoiceRepository $invoiceRepo
* @param accountRepository $accountRepo
*/
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, AccountRepository $accountRepo)
{
parent::__construct();
@ -29,20 +53,21 @@ class SendReminders extends Command
public function fire()
{
$this->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 [];
}
}

View File

@ -1,21 +1,41 @@
<?php namespace App\Console\Commands;
use DB;
use DateTime;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use App\Models\Company;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\AccountRepository;
/**
* Class SendRenewalInvoices
*/
class SendRenewalInvoices extends Command
{
/**
* @var string
*/
protected $name = 'ninja:send-renewals';
/**
* @var string
*/
protected $description = 'Send renewal invoices';
/**
* @var Mailer
*/
protected $mailer;
/**
* @var AccountRepository
*/
protected $accountRepo;
/**
* SendRenewalInvoices constructor.
*
* @param Mailer $mailer
* @param AccountRepository $repo
*/
public function __construct(Mailer $mailer, AccountRepository $repo)
{
parent::__construct();
@ -23,12 +43,10 @@ class SendRenewalInvoices extends Command
$this->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 [];
}
}

View File

@ -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);
*/
}
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
/**
* Class ClientWasArchived
*/
class ClientWasArchived extends Event
{
use SerializesModels;
/**
* @var Client
*/
public $client;
/**
* Create a new event instance.
*
* @return void
* @param Client $client
*/
public function __construct($client)
public function __construct(Client $client)
{
$this->client = $client;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
/**
* Class ClientWasCreated
*/
class ClientWasCreated extends Event
{
use SerializesModels;
/**
* @var Client
*/
public $client;
/**
* Create a new event instance.
*
* @return void
* @param Client $client
*/
public function __construct($client)
public function __construct(Client $client)
{
$this->client = $client;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
/**
* Class ClientWasDeleted
*/
class ClientWasDeleted extends Event
{
use SerializesModels;
/**
* @var Client
*/
public $client;
/**
* Create a new event instance.
*
* @return void
* @param Client $client
*/
public function __construct($client)
public function __construct(Client $client)
{
$this->client = $client;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
/**
* Class ClientWasRestored
*/
class ClientWasRestored extends Event
{
use SerializesModels;
/**
* @var Client
*/
public $client;
/**
* Create a new event instance.
*
* @return void
* @param Client $client
*/
public function __construct($client)
public function __construct(Client $client)
{
$this->client = $client;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
/**
* Class ClientWasUpdated
*/
class ClientWasUpdated extends Event
{
use SerializesModels;
/**
* @var Client
*/
public $client;
/**
* Create a new event instance.
*
* @return void
* @param Client $client
*/
public function __construct($client)
public function __construct(Client $client)
{
$this->client = $client;
}

View File

@ -1,23 +1,30 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Client;
use Illuminate\Queue\SerializesModels;
class CreditWasArchived extends Event {
/**
* Class CreditWasArchived
*/
class CreditWasArchived extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Client
*/
public $credit;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($credit)
{
$this->credit = $credit;
}
/**
* Create a new event instance.
*
* @param Client $credit
*/
public function __construct(Client $credit)
{
$this->credit = $credit;
}
}

View File

@ -1,21 +1,24 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Credit;
use Illuminate\Queue\SerializesModels;
class CreditWasCreated extends Event {
class CreditWasCreated extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Credit
*/
public $credit;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($credit)
/**
* Create a new event instance.
*
* @param Credit $credit
*/
public function __construct(Credit $credit)
{
$this->credit = $credit;
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Credit;
use Illuminate\Queue\SerializesModels;
/**
* Class CreditWasDeleted
*/
class CreditWasDeleted extends Event {
use SerializesModels;
/**
* @var Credit
*/
public $credit;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($credit)
/**
* Create a new event instance.
*
* @param Credit $credit
*/
public function __construct(Credit $credit)
{
$this->credit = $credit;
}

View File

@ -1,21 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Credit;
use Illuminate\Queue\SerializesModels;
/**
* Class CreditWasRestored
*/
class CreditWasRestored extends Event {
use SerializesModels;
/**
* @var Credit
*/
public $credit;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($credit)
/**
* Create a new event instance.
*
* @param Credit $credit
*/
public function __construct(Credit $credit)
{
$this->credit = $credit;
}

View File

@ -1,7 +1,5 @@
<?php namespace App\Events;
abstract class Event {
//
abstract class Event
{
}

View File

@ -1,22 +1,28 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Expense;
use Illuminate\Queue\SerializesModels;
/**
* Class ExpenseWasArchived
*/
class ExpenseWasArchived extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Expense
*/
public $expense;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($expense)
{
$this->expense = $expense;
}
/**
* Create a new event instance.
*
* @param Expense $expense
*/
public function __construct(Expense $expense)
{
$this->expense = $expense;
}
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Expense;
use Illuminate\Queue\SerializesModels;
/**
* Class ExpenseWasCreated
*/
class ExpenseWasCreated extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Expense
*/
public $expense;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($expense)
/**
* Create a new event instance.
*
* @param Expense $expense
*/
public function __construct(Expense $expense)
{
$this->expense = $expense;
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Expense;
use Illuminate\Queue\SerializesModels;
class ExpenseWasDeleted extends Event {
// Expenses
use SerializesModels;
/**
* Class ExpenseWasDeleted
*/
class ExpenseWasDeleted extends Event
{
use SerializesModels;
/**
* @var Expense
*/
public $expense;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($expense)
/**
* Create a new event instance.
*
* @param Expense $expense
*/
public function __construct(Expense $expense)
{
$this->expense = $expense;
}

View File

@ -1,21 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Expense;
use Illuminate\Queue\SerializesModels;
class ExpenseWasRestored extends Event {
// Expenses
use SerializesModels;
/**
* Class ExpenseWasRestored
*/
class ExpenseWasRestored extends Event
{
use SerializesModels;
/**
* @var Expense
*/
public $expense;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($expense)
/**
* Create a new event instance.
*
* @param Expense $expense
*/
public function __construct(Expense $expense)
{
$this->expense = $expense;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Expense;
use Illuminate\Queue\SerializesModels;
/**
* Class ExpenseWasUpdated
*/
class ExpenseWasUpdated extends Event
{
use SerializesModels;
/**
* @var Expense
*/
public $expense;
/**
* Create a new event instance.
*
* @return void
* @param Expense $expense
*/
public function __construct($expense)
public function __construct(Expense $expense)
{
$this->expense = $expense;
}

View File

@ -1,21 +1,28 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invitation;
use Illuminate\Queue\SerializesModels;
class InvoiceInvitationWasEmailed extends Event {
/**
* Class InvoiceInvitationWasEmailed
*/
class InvoiceInvitationWasEmailed extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invitation
*/
public $invitation;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invitation)
/**
* Create a new event instance.
*
* @param Invitation $invitation
*/
public function __construct(Invitation $invitation)
{
$this->invitation = $invitation;
}

View File

@ -1,25 +1,35 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invitation;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
/**
* Class InvoiceInvitationWasViewed
*/
class InvoiceInvitationWasViewed extends Event {
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* @var Invitation
*/
public $invitation;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice, $invitation)
/**
* Create a new event instance.
*
* @param Invoice $invoice
* @param Invitation $invitation
*/
public function __construct(Invoice $invoice, Invitation $invitation)
{
$this->invoice = $invoice;
$this->invitation = $invitation;
}
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasArchived extends Event {
/**
* Class InvoiceWasArchived
*/
class InvoiceWasArchived extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice)
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasCreated extends Event {
/**
* Class InvoiceWasCreated
*/
class InvoiceWasCreated extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice)
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}

View File

@ -1,22 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasDeleted extends Event {
/**
* Class InvoiceWasDeleted
*/
class InvoiceWasDeleted extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice)
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}
}

View File

@ -1,22 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasEmailed extends Event {
/**
* Class InvoiceWasEmailed
*/
class InvoiceWasEmailed extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice)
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}
}

View File

@ -1,22 +1,30 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasRestored extends Event {
use SerializesModels;
/**
* Class InvoiceWasRestored
*/
class InvoiceWasRestored extends Event
{
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
public $fromDeleted;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice, $fromDeleted)
/**
* Create a new event instance.
*
* @param Invoice $invoice
* @param $fromDeleted
*/
public function __construct(Invoice $invoice, $fromDeleted)
{
$this->invoice = $invoice;
$this->fromDeleted = $fromDeleted;

View File

@ -1,22 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class InvoiceWasUpdated extends Event {
/**
* Class InvoiceWasUpdated
*/
class InvoiceWasUpdated extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Invoice
*/
public $invoice;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invoice)
{
$this->invoice = $invoice;
}
/**
* Create a new event instance.
*
* @param Invoice $invoice
*/
public function __construct(Invoice $invoice)
{
$this->invoice = $invoice;
}
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentCompleted extends Event {
/**
* Class PaymentCompleted
*/
class PaymentCompleted extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
* @param Payment $payment
*/
public function __construct($payment)
public function __construct(Payment $payment)
{
$this->payment = $payment;
}

View File

@ -1,23 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentFailed extends Event {
/**
* Class PaymentFailed
*/
class PaymentFailed extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
* @param Payment $payment
*/
public function __construct($payment)
public function __construct(Payment $payment)
{
$this->payment = $payment;
}
}

View File

@ -1,22 +1,28 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasArchived extends Event {
/**
* Class PaymentWasArchived
*/
class PaymentWasArchived extends Event
{
use SerializesModels;
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($payment)
{
$this->payment = $payment;
}
/**
* Create a new event instance.
*
* @param Payment $payment
*/
public function __construct(Payment $payment)
{
$this->payment = $payment;
}
}

View File

@ -1,22 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasCreated extends Event {
/**
* Class PaymentWasCreated
*/
class PaymentWasCreated extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($payment)
/**
* Create a new event instance.
*
* @param Payment $payment
*/
public function __construct(Payment $payment)
{
$this->payment = $payment;
}
}

View File

@ -1,22 +1,29 @@
<?php namespace App\Events;
<?php
use App\Events\Event;
namespace App\Events;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasDeleted extends Event {
/**
* Class PaymentWasDeleted.
*/
class PaymentWasDeleted extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($payment)
/**
* Create a new event instance.
*
* @param Payment $payment
*/
public function __construct(Payment $payment)
{
$this->payment = $payment;
}
}

View File

@ -1,25 +1,31 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasRefunded extends Event {
use SerializesModels;
/**
* Class PaymentWasRefunded
*/
class PaymentWasRefunded extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
public $refundAmount;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($payment, $refundAmount)
/**
* Create a new event instance.
*
* @param Payment $payment
* @param $refundAmount
*/
public function __construct(Payment $payment, $refundAmount)
{
$this->payment = $payment;
$this->refundAmount = $refundAmount;
}
}

View File

@ -1,25 +1,30 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasRestored extends Event {
use SerializesModels;
/**
* Class PaymentWasRestored
*/
class PaymentWasRestored extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
public $fromDeleted;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($payment, $fromDeleted)
/**
* Create a new event instance.
*
* @param Payment $payment
* @param $fromDeleted
*/
public function __construct(Payment $payment, $fromDeleted)
{
$this->payment = $payment;
$this->fromDeleted = $fromDeleted;
}
}

View File

@ -1,22 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Payment;
use Illuminate\Queue\SerializesModels;
class PaymentWasVoided extends Event {
/**
* Class PaymentWasVoided
*/
class PaymentWasVoided extends Event
{
use SerializesModels;
/**
* @var Payment
*/
public $payment;
/**
* Create a new event instance.
*
* @return void
* @param Payment $payment
*/
public function __construct($payment)
public function __construct(Payment $payment)
{
$this->payment = $payment;
}
}

View File

@ -1,27 +1,37 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invitation;
use App\Models\Invoice;
use Illuminate\Queue\SerializesModels;
class QuoteInvitationWasApproved extends Event {
use SerializesModels;
class QuoteInvitationWasApproved extends Event
{
use SerializesModels;
public $quote;
/**
* @var Invoice
*/
public $invoice;
/**
* @var Invitation
*/
public $invitation;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($quote, $invoice, $invitation)
/**
* Create a new event instance.
*
* @param $quote
* @param Invoice $invoice
* @param Invitation $invitation
*/
public function __construct($quote, Invoice $invoice, Invitation $invitation)
{
$this->quote = $quote;
$this->invoice = $invoice;
$this->invitation = $invitation;
}
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invitation;
use Illuminate\Queue\SerializesModels;
class QuoteInvitationWasEmailed extends Event {
use SerializesModels;
/**
* Class QuoteInvitationWasEmailed
*/
class QuoteInvitationWasEmailed extends Event
{
use SerializesModels;
/**
* @var Invitation
*/
public $invitation;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($invitation)
/**
* Create a new event instance.
*
* @param Invitation $invitation
*/
public function __construct(Invitation $invitation)
{
$this->invitation = $invitation;
}

View File

@ -1,25 +1,31 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Invitation;
use Illuminate\Queue\SerializesModels;
class QuoteInvitationWasViewed extends Event {
/**
* Class QuoteInvitationWasViewed
*/
class QuoteInvitationWasViewed extends Event
{
use SerializesModels;
public $quote;
/**
* @var Invitation
*/
public $invitation;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($quote, $invitation)
/**
* Create a new event instance.
*
* @param $quote
* @param Invitation $invitation
*/
public function __construct($quote, Invitation $invitation)
{
$this->quote = $quote;
$this->invitation = $invitation;
}
}

View File

@ -1,22 +1,20 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasArchived extends Event {
use SerializesModels;
class QuoteWasArchived extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($quote)
{
$this->quote = $quote;
}
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,22 +1,22 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasCreated extends Event {
use SerializesModels;
/**
* Class QuoteWasCreated
*/
class QuoteWasCreated extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,22 +1,22 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasDeleted extends Event {
use SerializesModels;
/**
* Class QuoteWasDeleted
*/
class QuoteWasDeleted extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,22 +1,22 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasEmailed extends Event {
use SerializesModels;
/**
* Class QuoteWasEmailed
*/
class QuoteWasEmailed extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,22 +1,22 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasRestored extends Event {
use SerializesModels;
/**
* Class QuoteWasRestored
*/
class QuoteWasRestored extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,22 +1,23 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class QuoteWasUpdated extends Event {
use SerializesModels;
/**
* Class QuoteWasUpdated
*/
class QuoteWasUpdated extends Event
{
use SerializesModels;
public $quote;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($quote)
{
$this->quote = $quote;
}
/**
* Create a new event instance.
*
* @param $quote
*/
public function __construct($quote)
{
$this->quote = $quote;
}
}

View File

@ -1,21 +1,18 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class UserLoggedIn extends Event {
use SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Class UserLoggedIn
*/
class UserLoggedIn extends Event
{
use SerializesModels;
/**
* UserLoggedIn constructor.
*/
public function __construct()
{
}
}

View File

@ -1,23 +1,24 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\User;
use Illuminate\Queue\SerializesModels;
class UserSettingsChanged extends Event {
use SerializesModels;
class UserSettingsChanged extends Event
{
use SerializesModels;
/**
* @var User
*/
public $user;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($user = false)
{
/**
* Create a new event instance.
*
* @param User $user
*/
public function __construct(User $user = false)
{
$this->user = $user;
}
}
}

View File

@ -1,21 +1,18 @@
<?php namespace App\Events;
use App\Events\Event;
use Illuminate\Queue\SerializesModels;
class UserSignedUp extends Event {
use SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Class UserSignedUp
*/
class UserSignedUp extends Event
{
use SerializesModels;
/**
* Create a new event instance.
*/
public function __construct()
{
}
}

View File

@ -1,21 +1,27 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Vendor;
use Illuminate\Queue\SerializesModels;
/**
* Class VendorWasArchived
*/
class VendorWasArchived extends Event
{
// vendor
use SerializesModels;
/**
* @var Vendor
*/
public $vendor;
/**
* Create a new event instance.
*
* @return void
* @param Vendor $vendor
*/
public function __construct($vendor)
public function __construct(Vendor $vendor)
{
$this->vendor = $vendor;
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Vendor;
use Illuminate\Queue\SerializesModels;
/**
* Class VendorWasCreated
*/
class VendorWasCreated extends Event
{
// vendor
use SerializesModels;
/**
* @var Vendor
*/
public $vendor;
/**
* Create a new event instance.
*
* @return void
* @param Vendor $vendor
*/
public function __construct($vendor)
public function __construct(Vendor $vendor)
{
$this->vendor = $vendor;
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Vendor;
use Illuminate\Queue\SerializesModels;
/**
* Class VendorWasDeleted
*/
class VendorWasDeleted extends Event
{
// vendor
use SerializesModels;
/**
* @var Vendor
*/
public $vendor;
/**
* Create a new event instance.
*
* @return void
* @param Vendor $vendor
*/
public function __construct($vendor)
public function __construct(Vendor $vendor)
{
$this->vendor = $vendor;
}

View File

@ -1,21 +1,26 @@
<?php namespace App\Events;
use App\Events\Event;
use App\Models\Vendor;
use Illuminate\Queue\SerializesModels;
/**
* Class VendorWasRestored
*/
class VendorWasRestored extends Event
{
// vendor
use SerializesModels;
/**
* @var Vendor
*/
public $vendor;
/**
* Create a new event instance.
*
* @return void
* @param Vendor $vendor
*/
public function __construct($vendor)
public function __construct(Vendor $vendor)
{
$this->vendor = $vendor;
}

View File

@ -1,20 +1,26 @@
<?php namespace App\Events;
// vendor
use App\Events\Event;
use App\Models\Vendor;
use Illuminate\Queue\SerializesModels;
/**
* Class VendorWasUpdated
*/
class VendorWasUpdated extends Event
{
use SerializesModels;
/**
* @var Vendor
*/
public $vendor;
/**
* Create a new event instance.
*
* @return void
* @param Vendor $vendor
*/
public function __construct($vendor)
public function __construct(Vendor $vendor)
{
$this->vendor = $vendor;
}

View File

@ -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

View File

@ -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();

View File

@ -1,6 +1,7 @@
<?php namespace App\Http\Controllers;
use App\Models\AccountGateway;
use App\Services\TemplateService;
use Auth;
use File;
use Image;
@ -33,21 +34,55 @@ use App\Events\UserSignedUp;
use App\Events\UserSettingsChanged;
use App\Services\AuthService;
use App\Services\PaymentService;
use App\Http\Requests\UpdateAccountRequest;
/**
* Class AccountController
*/
class AccountController extends BaseController
{
/**
* @var AccountRepository
*/
protected $accountRepo;
/**
* @var UserMailer
*/
protected $userMailer;
/**
* @var ContactMailer
*/
protected $contactMailer;
/**
* @var ReferralRepository
*/
protected $referralRepository;
/**
* @var PaymentService
*/
protected $paymentService;
public function __construct(AccountRepository $accountRepo, UserMailer $userMailer, ContactMailer $contactMailer, ReferralRepository $referralRepository, PaymentService $paymentService)
/**
* AccountController constructor.
*
* @param AccountRepository $accountRepo
* @param UserMailer $userMailer
* @param ContactMailer $contactMailer
* @param ReferralRepository $referralRepository
* @param PaymentService $paymentService
*/
public function __construct(
AccountRepository $accountRepo,
UserMailer $userMailer,
ContactMailer $contactMailer,
ReferralRepository $referralRepository,
PaymentService $paymentService
)
{
//parent::__construct();
$this->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();

View File

@ -1,8 +1,6 @@
<?php namespace App\Http\Controllers;
use Auth;
use Datatable;
use DB;
use Input;
use Redirect;
use Session;
@ -15,8 +13,6 @@ use WePay;
use App\Models\Gateway;
use App\Models\Account;
use App\Models\AccountGateway;
use App\Ninja\Repositories\AccountRepository;
use App\Services\AccountGatewayService;
class AccountGatewayController extends BaseController
@ -173,7 +169,7 @@ class AccountGatewayController extends BaseController
$gatewayId = Input::get('primary_gateway_id') ?: Input::get('secondary_gateway_id');
$gateway = Gateway::findOrFail($gatewayId);
$rules = array();
$rules = [];
$fields = $gateway->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;

View File

@ -1,12 +1,5 @@
<?php namespace App\Http\Controllers;
use Auth;
use DB;
use Datatable;
use Utils;
use View;
use App\Models\Client;
use App\Models\Activity;
use App\Services\ActivityService;
class ActivityController extends BaseController

View File

@ -11,10 +11,8 @@ use Utils;
use View;
use Event;
use Session;
use Cookie;
use Response;
use Redirect;
use App\Models\User;
use App\Models\Account;
use App\Models\Industry;
use App\Ninja\Mailers\Mailer;
@ -114,18 +112,18 @@ class AppController extends BaseController
// Write Config Settings
$fp = fopen(base_path()."/.env", 'w');
$fp = fopen(base_path().'/.env', 'w');
fwrite($fp, $config);
fclose($fp);
// == DB Migrate & Seed == //
// Artisan::call('migrate:rollback', array('--force' => 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 <code>sudo chown www-data:www-data /path/to/ninja/.env</code>');
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

View File

@ -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();
}

View File

@ -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');
}
}

View File

@ -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;

View File

@ -1,13 +1,10 @@
<?php namespace App\Http\Controllers;
use Session;
use Utils;
use Auth;
use Log;
use Input;
use Response;
use Request;
use League\Fractal;
use League\Fractal\Manager;
use League\Fractal\Resource\Item;
use League\Fractal\Resource\Collection;
@ -15,7 +12,6 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Models\EntityModel;
use App\Ninja\Serializers\ArraySerializer;
use League\Fractal\Serializer\JsonApiSerializer;
use Illuminate\Pagination\LengthAwarePaginator;
/**
* @SWG\Swagger(

View File

@ -1,11 +1,7 @@
<?php namespace App\Http\Controllers;
use App\Http\Middleware\PermissionsRequired;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Input;
use Auth;
use Utils;
class BaseController extends Controller
{

View File

@ -1,15 +1,10 @@
<?php namespace App\Http\Controllers;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Utils;
use Response;
use Input;
use Auth;
use App\Models\Client;
use App\Ninja\Repositories\ClientRepository;
use App\Http\Requests\CreateClientRequest;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\ClientTransformer;
use App\Http\Requests\UpdateClientRequest;
class ClientApiController extends BaseAPIController

View File

@ -1,31 +1,35 @@
<?php namespace App\Http\Controllers\ClientAuth;
use Auth;
use Event;
use Utils;
use Session;
use Illuminate\Http\Request;
use App\Models\User;
use App\Events\UserLoggedIn;
use App\Http\Controllers\Controller;
use App\Ninja\Repositories\AccountRepository;
use App\Services\AuthService;
use App\Models\Contact;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AuthController extends Controller {
class AuthController extends Controller
{
use AuthenticatesUsers;
protected $guard = 'client';
/**
* @var string
*/
protected $guard = 'client';
/**
* @var string
*/
protected $redirectTo = '/client/dashboard';
use AuthenticatesUsers;
/**
* @return mixed
*/
public function showLoginForm()
{
$data = [];
public function showLoginForm()
{
$data = array();
$contactKey = session('contact_key');
if($contactKey){
if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->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');

View File

@ -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.
*

View File

@ -1,33 +1,21 @@
<?php namespace App\Http\Controllers;
use Auth;
use Datatable;
use Utils;
use View;
use URL;
use Validator;
use Input;
use Session;
use Redirect;
use Cache;
use App\Models\Activity;
use App\Models\Client;
use App\Models\Account;
use App\Models\Contact;
use App\Models\Invoice;
use App\Models\Size;
use App\Models\PaymentTerm;
use App\Models\Industry;
use App\Models\Currency;
use App\Models\Payment;
use App\Models\Credit;
use App\Models\Expense;
use App\Models\Country;
use App\Models\Task;
use App\Ninja\Repositories\ClientRepository;
use App\Services\ClientService;
use App\Http\Requests\ClientRequest;
use App\Http\Requests\CreateClientRequest;
use App\Http\Requests\UpdateClientRequest;
@ -53,7 +41,7 @@ class ClientController extends BaseController
*/
public function index()
{
return View::make('list', array(
return View::make('list', [
'entityType' => 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 = [

View File

@ -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');

View File

@ -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;
}

View File

@ -1,13 +1,11 @@
<?php namespace App\Http\Controllers;
use Datatable;
use Input;
use Redirect;
use Session;
use URL;
use Utils;
use View;
use Validator;
use App\Models\Client;
use App\Services\CreditService;
use App\Ninja\Repositories\CreditRepository;
@ -35,7 +33,7 @@ class CreditController extends BaseController
*/
public function index()
{
return View::make('list', array(
return View::make('list', [
'entityType' => 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);
}

View File

@ -2,8 +2,6 @@
use Auth;
use DB;
use View;
use App\Models\Activity;
class DashboardApiController extends BaseAPIController
{

View File

@ -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');

View File

@ -1,17 +1,30 @@
<?php namespace App\Http\Controllers;
use App\Models\Document;
use App\Ninja\Repositories\DocumentRepository;
use App\Http\Requests\DocumentRequest;
use App\Http\Requests\CreateDocumentRequest;
/**
* Class DocumentAPIController
*/
class DocumentAPIController extends BaseAPIController
{
/**
* @var DocumentRepository
*/
protected $documentRepo;
/**
* @var string
*/
protected $entityType = ENTITY_DOCUMENT;
/**
* DocumentAPIController constructor.
*
* @param DocumentRepository $documentRepo
*/
public function __construct(DocumentRepository $documentRepo)
{
parent::__construct();
@ -19,6 +32,9 @@ class DocumentAPIController extends BaseAPIController
$this->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
}
}

View File

@ -1,17 +1,10 @@
<?php namespace App\Http\Controllers;
use Datatable;
use Input;
use Redirect;
use Session;
use URL;
use Utils;
use View;
use Validator;
use Response;
use App\Models\Document;
use App\Ninja\Repositories\DocumentRepository;
use App\Http\Requests\DocumentRequest;
use App\Http\Requests\CreateDocumentRequest;
use App\Http\Requests\UpdateDocumentRequest;
@ -64,7 +57,7 @@ class DocumentController extends BaseController
$document = $request->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();

View File

@ -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
{

View File

@ -1,13 +1,9 @@
<?php namespace App\Http\Controllers;
use Debugbar;
use DB;
use Auth;
use Datatable;
use Utils;
use View;
use URL;
use Validator;
use Input;
use Session;
use Redirect;
@ -17,7 +13,6 @@ use App\Models\Expense;
use App\Models\Client;
use App\Services\ExpenseService;
use App\Ninja\Repositories\ExpenseRepository;
use App\Http\Requests\ExpenseRequest;
use App\Http\Requests\CreateExpenseRequest;
use App\Http\Requests\UpdateExpenseRequest;
@ -44,7 +39,7 @@ class ExpenseController extends BaseController
*/
public function index()
{
return View::make('list', array(
return View::make('list', [
'entityType' => 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());

View File

@ -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;

View File

@ -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;

View File

@ -7,7 +7,6 @@ use Input;
use Session;
use Redirect;
use App\Services\ImportService;
use App\Http\Controllers\BaseController;
class ImportController extends BaseController
{

View File

@ -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')));

View File

@ -1,7 +1,6 @@
<?php namespace App\Http\Controllers;
use Auth;
use Illuminate\Support\Facades\Request;
use Utils;
use Response;
use Input;
@ -10,13 +9,10 @@ use App\Models\Invoice;
use App\Models\Client;
use App\Models\Contact;
use App\Models\Product;
use App\Models\Invitation;
use App\Ninja\Repositories\ClientRepository;
use App\Ninja\Repositories\PaymentRepository;
use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\InvoiceTransformer;
use App\Http\Requests\InvoiceRequest;
use App\Http\Requests\CreateInvoiceAPIRequest;
use App\Http\Requests\UpdateInvoiceAPIRequest;

View File

@ -8,10 +8,7 @@ use Input;
use Cache;
use Redirect;
use DB;
use Event;
use URL;
use Datatable;
use Request;
use DropdownButton;
use App\Models\Invoice;
use App\Models\Client;
@ -28,7 +25,6 @@ use App\Ninja\Repositories\DocumentRepository;
use App\Services\InvoiceService;
use App\Services\PaymentService;
use App\Services\RecurringInvoiceService;
use App\Http\Requests\InvoiceRequest;
use App\Http\Requests\CreateInvoiceRequest;
use App\Http\Requests\UpdateInvoiceRequest;
@ -139,23 +135,23 @@ class InvoiceController extends BaseController
$actions = [
['url' => '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 .= '<li>'.strip_tags($line).'</li>';
@ -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 .= '<li>'.strip_tags($line).'</li>';
@ -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,

View File

@ -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');

View File

@ -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);

View File

@ -1,17 +1,11 @@
<?php namespace App\Http\Controllers;
use App\Ninja\Mailers\ContactMailer;
use Auth;
use Illuminate\Http\Request;
use Input;
use Utils;
use Response;
use App\Models\Payment;
use App\Models\Invoice;
use App\Ninja\Repositories\PaymentRepository;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\PaymentTransformer;
use App\Ninja\Transformers\InvoiceTransformer;
use App\Http\Requests\UpdatePaymentRequest;
use App\Http\Requests\CreatePaymentAPIRequest;

View File

@ -4,7 +4,6 @@ use Input;
use Session;
use Utils;
use View;
use Omnipay;
use Cache;
use App\Models\Invoice;
use App\Models\Client;
@ -17,18 +16,50 @@ use App\Http\Requests\UpdatePaymentRequest;
class PaymentController extends BaseController
{
/**
* @var string
*/
protected $entityType = ENTITY_PAYMENT;
public function __construct(PaymentRepository $paymentRepo, ContactMailer $contactMailer, PaymentService $paymentService)
/**
* @var PaymentRepository
*/
protected $paymentRepo;
/**
* @var ContactMailer
*/
protected $contactMailer;
/**
* @var PaymentService
*/
protected $paymentService;
/**
* PaymentController constructor.
*
* @param PaymentRepository $paymentRepo
* @param ContactMailer $contactMailer
* @param PaymentService $paymentService
*/
public function __construct(
PaymentRepository $paymentRepo,
ContactMailer $contactMailer,
PaymentService $paymentService
)
{
$this->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');
}
}

View File

@ -1,25 +1,25 @@
<?php namespace App\Http\Controllers;
use Auth;
use Str;
use DB;
use Datatable;
use Utils;
use URL;
use View;
use Input;
use Session;
use Redirect;
use App\Models\PaymentTerm;
use App\Ninja\Repositories\VendorRepository;
use App\Services\PaymentService;
use App\Services\PaymentTermService;
class PaymentTermController extends BaseController
{
/**
* @var PaymentTermService
*/
protected $paymentTermService;
/**
* PaymentTermController constructor.
* @param PaymentTermService $paymentTermService
*/
public function __construct(PaymentTermService $paymentTermService)
{
//parent::__construct();
@ -27,16 +27,26 @@ class PaymentTermController extends BaseController
$this->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');

View File

@ -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
}
}

View File

@ -1,24 +1,30 @@
<?php namespace App\Http\Controllers;
use Auth;
use Str;
use DB;
use Datatable;
use Utils;
use URL;
use View;
use Input;
use Session;
use Redirect;
use App\Models\Product;
use App\Models\TaxRate;
use App\Services\ProductService;
/**
* Class ProductController
*/
class ProductController extends BaseController
{
/**
* @var ProductService
*/
protected $productService;
/**
* ProductController constructor.
*
* @param ProductService $productService
*/
public function __construct(ProductService $productService)
{
//parent::__construct();
@ -26,16 +32,26 @@ class ProductController extends BaseController
$this->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');

View File

@ -1,13 +1,8 @@
<?php namespace App\Http\Controllers;
use Auth;
use Input;
use Utils;
use Response;
use App\Models\Invoice;
use App\Ninja\Repositories\InvoiceRepository;
use App\Http\Controllers\BaseAPIController;
use App\Ninja\Transformers\QuoteTransformer;
class QuoteApiController extends BaseAPIController
{

View File

@ -6,25 +6,18 @@ use Redirect;
use Utils;
use View;
use Cache;
use Event;
use Session;
use App\Models\Account;
use App\Models\Client;
use App\Models\Country;
use App\Models\Currency;
use App\Models\Industry;
use App\Models\InvoiceDesign;
use App\Models\PaymentTerm;
use App\Models\Product;
use App\Models\Size;
use App\Models\TaxRate;
use App\Models\Invitation;
use App\Models\Activity;
use App\Models\Invoice;
use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\InvoiceRepository;
use App\Ninja\Repositories\ClientRepository;
use App\Events\QuoteInvitationWasApproved;
use App\Services\InvoiceService;
use App\Http\Requests\InvoiceRequest;
@ -126,7 +119,7 @@ class QuoteController extends BaseController
return [
'entityType' => 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');
}
}

View File

@ -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 = [

Some files were not shown because too many files have changed in this diff Show More