Rollback to 2.6.5

This commit is contained in:
Hillel Coren 2016-07-21 15:35:23 +03:00
parent dc22611d2f
commit 498578cefc
236 changed files with 190789 additions and 2456 deletions

View File

@ -1,3 +1,3 @@
{ {
"directory": "resources/assets/bower" "directory": "./public/vendor"
} }

1
.gitignore vendored
View File

@ -8,7 +8,6 @@
/public/build /public/build
/public/packages /public/packages
/public/vendor /public/vendor
/resources/assets/bower
/storage /storage
/bootstrap/compiled.php /bootstrap/compiled.php
/bootstrap/environment.php /bootstrap/environment.php

View File

@ -7,9 +7,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed ### Changed
- Auto billing uses credits if they exist - Auto billing uses credits if they exist
- All assets (CSS, JS) are minfied now
## [2.6.4] - 2016-07-19 ## [2.6.4] - 2016-07-19

View File

@ -11,7 +11,7 @@ Thanks for your contributions!
* Make your changes and commit * Make your changes and commit
* Check if your branch is still in sync with the repositorys **`develop`** branch * Check if your branch is still in sync with the repositorys **`develop`** branch
* _Read:_ [Syncing a fork](https://help.github.com/articles/syncing-a-fork/) * _Read:_ [Syncing a fork](https://help.github.com/articles/syncing-a-fork/)
* _Also read:_ [How to rebase a pull request](https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request) * _Also read:_ [How to rebase a pull request](https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request)
* Push your branch and create a PR against the Invoice Ninja **`develop`** branch * Push your branch and create a PR against the Invoice Ninja **`develop`** branch
* Update the [Changelog](CHANGELOG.md) * Update the [Changelog](CHANGELOG.md)
@ -21,7 +21,7 @@ To make the contribution process nice and easy for anyone, please follow some ru
to give a more detailed explanation. to give a more detailed explanation.
* Only one feature/bugfix per issue. If you want to submit more, create multiple issues. * Only one feature/bugfix per issue. If you want to submit more, create multiple issues.
* Only one feature/bugfix per PR(pull request). Split more changes into multiple PRs. * Only one feature/bugfix per PR(pull request). Split more changes into multiple PRs.
#### Coding Style #### Coding Style
Try to follow the [PSR-2 guidlines](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) Try to follow the [PSR-2 guidlines](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
@ -29,7 +29,7 @@ _Example styling:_
```php ```php
/** /**
* Gets a preview of the email * Gets a preview of the email
* *
* @param TemplateService $templateService * @param TemplateService $templateService
* *
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response

187
Gruntfile.js Normal file
View File

@ -0,0 +1,187 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
dump_dir: (function() {
var out = {};
grunt.file.expand({ filter: 'isDirectory'}, 'public/fonts/invoice-fonts/*').forEach(function(path) {
var fontName = /[^/]*$/.exec(path)[0],
files = {},
license='';
// Add license text
grunt.file.expand({ filter: 'isFile'}, path+'/*.txt').forEach(function(path) {
var licenseText = grunt.file.read(path);
// Fix anything that could escape from the comment
licenseText = licenseText.replace(/\*\//g,'*\\/');
license += "/*\n"+licenseText+"\n*/";
});
// Create files list
files['public/js/vfs_fonts/'+fontName+'.js'] = [path+'/*.ttf'];
out[fontName] = {
options: {
pre: license+'window.ninjaFontVfs=window.ninjaFontVfs||{};window.ninjaFontVfs.'+fontName+'=',
rootPath: path+'/'
},
files: files
};
});
// Return the computed object
return out;
}()),
concat: {
options: {
process: function(src, filepath) {
var basepath = filepath.substring(7, filepath.lastIndexOf('/') + 1);
// Fix relative paths for css files
if(filepath.indexOf('.css', filepath.length - 4) !== -1) {
return src.replace(/(url\s*[\("']+)\s*([^'"\)]+)(['"\)]+;?)/gi, function(match, start, url, end, offset, string) {
if(url.indexOf('data:') === 0) {
// Skip data urls
return match;
} else if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
} else {
return start + basepath + url + end;
}
});
// Fix source maps locations
} else if(filepath.indexOf('.js', filepath.length - 4) !== -1) {
return src.replace(/(\/[*\/][#@]\s*sourceMappingURL=)([^\s]+)/gi, function(match, start, url, offset, string) {
if(url.indexOf('/') === 0) {
// Skip absolute urls
return match;
} else {
return start + basepath + url;
}
});
// Don't do anything for unknown file types
} else {
return src;
}
},
},
js: {
src: [
'public/vendor/jquery/dist/jquery.js',
'public/vendor/jquery-ui/jquery-ui.min.js',
'public/vendor/bootstrap/dist/js/bootstrap.min.js',
'public/vendor/datatables/media/js/jquery.dataTables.js',
'public/vendor/datatables-bootstrap3/BS3/assets/js/datatables.js',
'public/vendor/knockout.js/knockout.js',
'public/vendor/knockout-mapping/build/output/knockout.mapping-latest.js',
'public/vendor/knockout-sortable/build/knockout-sortable.min.js',
'public/vendor/underscore/underscore.js',
'public/vendor/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.de.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.da.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.pt-BR.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.nl.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.fr.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.it.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.lt.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.no.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.es.min.js',
'public/vendor/bootstrap-datepicker/dist/locales/bootstrap-datepicker.sv.min.js',
'public/vendor/dropzone/dist/min/dropzone.min.js',
'public/vendor/typeahead.js/dist/typeahead.jquery.min.js',
'public/vendor/accounting/accounting.min.js',
'public/vendor/spectrum/spectrum.js',
'public/vendor/jspdf/dist/jspdf.min.js',
'public/vendor/moment/min/moment.min.js',
'public/vendor/moment-timezone/builds/moment-timezone-with-data.min.js',
'public/vendor/stacktrace-js/dist/stacktrace-with-polyfills.min.js',
'public/vendor/fuse.js/src/fuse.min.js',
//'public/vendor/moment-duration-format/lib/moment-duration-format.js',
//'public/vendor/handsontable/dist/jquery.handsontable.full.min.js',
//'public/vendor/pdfmake/build/pdfmake.min.js',
//'public/vendor/pdfmake/build/vfs_fonts.js',
//'public/js/vfs_fonts.js',
'public/js/bootstrap-combobox.js',
'public/js/script.js',
'public/js/pdf.pdfmake.js',
],
dest: 'public/built.js',
nonull: true
},
js_public: {
src: [
/*
'public/js/simpleexpand.js',
'public/js/valign.js',
'public/js/bootstrap.min.js',
'public/js/simpleexpand.js',
*/
'public/vendor/bootstrap/dist/js/bootstrap.min.js',
'public/js/bootstrap-combobox.js',
],
dest: 'public/built.public.js',
nonull: true
},
css: {
src: [
'public/vendor/bootstrap/dist/css/bootstrap.min.css',
'public/vendor/datatables/media/css/jquery.dataTables.css',
'public/vendor/datatables-bootstrap3/BS3/assets/css/datatables.css',
'public/vendor/font-awesome/css/font-awesome.min.css',
'public/vendor/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css',
'public/vendor/dropzone/dist/min/dropzone.min.css',
'public/vendor/spectrum/spectrum.css',
'public/css/bootstrap-combobox.css',
'public/css/typeahead.js-bootstrap.css',
//'public/vendor/handsontable/dist/jquery.handsontable.full.css',
'public/css/style.css',
],
dest: 'public/css/built.css',
nonull: true,
options: {
process: false
}
},
css_public: {
src: [
'public/vendor/bootstrap/dist/css/bootstrap.min.css',
'public/vendor/font-awesome/css/font-awesome.min.css',
'public/css/bootstrap-combobox.css',
'public/vendor/datatables/media/css/jquery.dataTables.css',
'public/vendor/datatables-bootstrap3/BS3/assets/css/datatables.css',
'public/css/public.style.css',
],
dest: 'public/css/built.public.css',
nonull: true,
options: {
process: false
}
},
js_pdf: {
src: [
'public/js/pdf_viewer.js',
'public/js/compatibility.js',
'public/js/pdfmake.min.js',
'public/js/vfs.js',
],
dest: 'public/pdf.built.js',
nonull: true
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-dump-dir');
grunt.registerTask('default', ['dump_dir', 'concat']);
};

View File

@ -74,4 +74,4 @@ For information on how contribute to Invoice Ninja, please see our [contributing
## License ## License
Invoice Ninja is released under the Attribution Assurance License. Invoice Ninja is released under the Attribution Assurance License.
See [LICENSE](LICENSE) for details. See [LICENSE](LICENSE) for details.

View File

@ -1,10 +1,5 @@
<?php <?php namespace App\Commands;
namespace App\Commands;
/**
* Class Command
*/
abstract class Command abstract class Command
{ {

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Ninja\Mailers\ContactMailer as Mailer; use App\Ninja\Mailers\ContactMailer as Mailer;
@ -41,7 +39,6 @@ class ChargeRenewalInvoices extends Command
/** /**
* ChargeRenewalInvoices constructor. * ChargeRenewalInvoices constructor.
*
* @param Mailer $mailer * @param Mailer $mailer
* @param AccountRepository $repo * @param AccountRepository $repo
* @param PaymentService $paymentService * @param PaymentService $paymentService
@ -70,11 +67,8 @@ class ChargeRenewalInvoices extends Command
foreach ($invoices as $invoice) { foreach ($invoices as $invoice) {
// check if account has switched to free since the invoice was created // check if account has switched to free since the invoice was created
$account = Account::find($invoice->client->public_id); $account = Account::find($invoice->client->public_id);
if ( ! $account) {
continue;
}
$company = $account->company; $company = $account->company;
if ( ! $company->plan || $company->plan == PLAN_FREE) { if ( ! $company->plan || $company->plan == PLAN_FREE) {
continue; continue;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use DB; use DB;
use Carbon; use Carbon;
@ -176,6 +174,7 @@ class CheckData extends Command {
foreach ($clients as $client) { foreach ($clients as $client) {
$this->info("=== Client:{$client->id} Balance:{$client->balance} Actual Balance:{$client->actual_balance} ==="); $this->info("=== Client:{$client->id} Balance:{$client->balance} Actual Balance:{$client->actual_balance} ===");
$foundProblem = false;
$lastBalance = 0; $lastBalance = 0;
$lastAdjustment = 0; $lastAdjustment = 0;
$lastCreatedAt = null; $lastCreatedAt = null;
@ -183,16 +182,8 @@ class CheckData extends Command {
$activities = DB::table('activities') $activities = DB::table('activities')
->where('client_id', '=', $client->id) ->where('client_id', '=', $client->id)
->orderBy('activities.id') ->orderBy('activities.id')
->get( ->get(['activities.id', 'activities.created_at', 'activities.activity_type_id', 'activities.adjustment', 'activities.balance', 'activities.invoice_id']);
[ //$this->info(var_dump($activities));
'activities.id',
'activities.created_at',
'activities.activity_type_id',
'activities.adjustment',
'activities.balance',
'activities.invoice_id'
]
);
foreach ($activities as $activity) { foreach ($activities as $activity) {
@ -240,11 +231,13 @@ class CheckData extends Command {
// **Fix for allowing converting a recurring invoice to a normal one without updating the balance** // **Fix for allowing converting a recurring invoice to a normal one without updating the balance**
if ($noAdjustment && $invoice->invoice_type_id == INVOICE_TYPE_STANDARD && !$invoice->is_recurring) { if ($noAdjustment && $invoice->invoice_type_id == INVOICE_TYPE_STANDARD && !$invoice->is_recurring) {
$this->info("No adjustment for new invoice:{$activity->invoice_id} amount:{$invoice->amount} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}"); $this->info("No adjustment for new invoice:{$activity->invoice_id} amount:{$invoice->amount} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}");
$foundProblem = true;
$clientFix += $invoice->amount; $clientFix += $invoice->amount;
$activityFix = $invoice->amount; $activityFix = $invoice->amount;
// **Fix for updating balance when creating a quote or recurring invoice** // **Fix for updating balance when creating a quote or recurring invoice**
} elseif ($activity->adjustment != 0 && ($invoice->invoice_type_id == INVOICE_TYPE_QUOTE || $invoice->is_recurring)) { } elseif ($activity->adjustment != 0 && ($invoice->invoice_type_id == INVOICE_TYPE_QUOTE || $invoice->is_recurring)) {
$this->info("Incorrect adjustment for new invoice:{$activity->invoice_id} adjustment:{$activity->adjustment} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}"); $this->info("Incorrect adjustment for new invoice:{$activity->invoice_id} adjustment:{$activity->adjustment} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}");
$foundProblem = true;
$clientFix -= $activity->adjustment; $clientFix -= $activity->adjustment;
$activityFix = 0; $activityFix = 0;
} }
@ -252,6 +245,7 @@ class CheckData extends Command {
// **Fix for updating balance when deleting a recurring invoice** // **Fix for updating balance when deleting a recurring invoice**
if ($activity->adjustment != 0 && $invoice->is_recurring) { if ($activity->adjustment != 0 && $invoice->is_recurring) {
$this->info("Incorrect adjustment for deleted invoice adjustment:{$activity->adjustment}"); $this->info("Incorrect adjustment for deleted invoice adjustment:{$activity->adjustment}");
$foundProblem = true;
if ($activity->balance != $lastBalance) { if ($activity->balance != $lastBalance) {
$clientFix -= $activity->adjustment; $clientFix -= $activity->adjustment;
} }
@ -261,6 +255,7 @@ class CheckData extends Command {
// **Fix for updating balance when archiving an invoice** // **Fix for updating balance when archiving an invoice**
if ($activity->adjustment != 0 && !$invoice->is_recurring) { if ($activity->adjustment != 0 && !$invoice->is_recurring) {
$this->info("Incorrect adjustment for archiving invoice adjustment:{$activity->adjustment}"); $this->info("Incorrect adjustment for archiving invoice adjustment:{$activity->adjustment}");
$foundProblem = true;
$activityFix = 0; $activityFix = 0;
$clientFix += $activity->adjustment; $clientFix += $activity->adjustment;
} }
@ -268,10 +263,12 @@ class CheckData extends Command {
// **Fix for updating balance when updating recurring invoice** // **Fix for updating balance when updating recurring invoice**
if ($activity->adjustment != 0 && $invoice->is_recurring) { if ($activity->adjustment != 0 && $invoice->is_recurring) {
$this->info("Incorrect adjustment for updated recurring invoice adjustment:{$activity->adjustment}"); $this->info("Incorrect adjustment for updated recurring invoice adjustment:{$activity->adjustment}");
$foundProblem = true;
$clientFix -= $activity->adjustment; $clientFix -= $activity->adjustment;
$activityFix = 0; $activityFix = 0;
} else if ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) { } else if ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) {
$this->info("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}"); $this->info("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}");
$foundProblem = true;
$clientFix -= $activity->adjustment; $clientFix -= $activity->adjustment;
$activityFix = 0; $activityFix = 0;
} }
@ -279,6 +276,7 @@ class CheckData extends Command {
// **Fix for updating balance when updating a quote** // **Fix for updating balance when updating a quote**
if ($activity->balance != $lastBalance) { if ($activity->balance != $lastBalance) {
$this->info("Incorrect adjustment for updated quote adjustment:{$activity->adjustment}"); $this->info("Incorrect adjustment for updated quote adjustment:{$activity->adjustment}");
$foundProblem = true;
$clientFix += $lastBalance - $activity->balance; $clientFix += $lastBalance - $activity->balance;
$activityFix = 0; $activityFix = 0;
} }
@ -286,6 +284,7 @@ class CheckData extends Command {
// **Fix for deleting payment after deleting invoice** // **Fix for deleting payment after deleting invoice**
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) { if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
$this->info("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}"); $this->info("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
$foundProblem = true;
$activityFix = 0; $activityFix = 0;
$clientFix -= $activity->adjustment; $clientFix -= $activity->adjustment;
} }

View File

@ -1,8 +1,5 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use App\Models\Vendor;
use Auth; use Auth;
use Utils; use Utils;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -35,7 +32,6 @@ class CreateTestData extends Command
/** /**
* CreateTestData constructor. * CreateTestData constructor.
*
* @param ClientRepository $clientRepo * @param ClientRepository $clientRepo
* @param InvoiceRepository $invoiceRepo * @param InvoiceRepository $invoiceRepo
* @param PaymentRepository $paymentRepo * @param PaymentRepository $paymentRepo
@ -130,9 +126,9 @@ class CreateTestData extends Command
/** /**
* @param $client * @param $client
* @param Invoice $invoice * @param $invoice
*/ */
private function createPayment($client, Invoice $invoice) private function createPayment($client, $invoice)
{ {
$data = [ $data = [
'invoice_id' => $invoice->id, 'invoice_id' => $invoice->id,
@ -171,9 +167,9 @@ class CreateTestData extends Command
} }
/** /**
* @param Vendor $vendor * @param $vendor
*/ */
private function createExpense(Vendor $vendor) private function createExpense($vendor)
{ {
for ($i=0; $i<$this->count; $i++) { for ($i=0; $i<$this->count; $i++) {
$data = [ $data = [

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use File; use File;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@ -1,6 +1,4 @@
<?php <?php namespace InvoiceNinja\Console\Commands;
namespace InvoiceNinja\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring; use Illuminate\Foundation\Inspiring;
@ -8,30 +6,30 @@ use Illuminate\Foundation\Inspiring;
/** /**
* Class Inspire * Class Inspire
*/ */
class Inspire extends Command class Inspire extends Command {
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'inspire';
/** /**
* The console command description. * The console command name.
* *
* @var string * @var string
*/ */
protected $description = 'Display an inspiring quote'; protected $name = 'inspire';
/** /**
* Execute the console command. * The console command description.
* *
* @return mixed * @var string
*/ */
public function handle() protected $description = 'Display an inspiring quote';
{
$this->comment(PHP_EOL . Inspiring::quote() . PHP_EOL); /**
} * Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}
} }

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use DB; use DB;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use DateTime; use DateTime;
use App\Models\Document; use App\Models\Document;

View File

@ -1,6 +1,5 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use Utils; use Utils;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -10,6 +9,7 @@ use Illuminate\Console\Command;
*/ */
class ResetData extends Command class ResetData extends Command
{ {
/** /**
* @var string * @var string
*/ */

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use DateTime; use DateTime;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use App\Models\Invoice; use App\Models\Invoice;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use Utils; use Utils;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Console\Commands;
namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Services\BankAccountService; use App\Services\BankAccountService;

View File

@ -15,7 +15,6 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\SendRecurringInvoices', 'App\Console\Commands\SendRecurringInvoices',
'App\Console\Commands\RemoveOrphanedDocuments', 'App\Console\Commands\RemoveOrphanedDocuments',
'App\Console\Commands\ResetData', 'App\Console\Commands\ResetData',
'App\Console\Commands\ResetInvoiceSchemaCounter',
'App\Console\Commands\CheckData', 'App\Console\Commands\CheckData',
'App\Console\Commands\PruneData', 'App\Console\Commands\PruneData',
'App\Console\Commands\CreateTestData', 'App\Console\Commands\CreateTestData',
@ -53,10 +52,5 @@ class Kernel extends ConsoleKernel
->sendOutputTo($logFile) ->sendOutputTo($logFile)
->daily(); ->daily();
} }
// Reset the invoice schema counter at the turn of the year
$schedule
->command('ninja:reset-invoice-schema-counter')
->daily();
} }
} }

View File

@ -16,17 +16,17 @@ use Illuminate\Validation\ValidationException;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
/** /**
* A list of the exception types that should not be reported. * A list of the exception types that should not be reported.
* *
* @var array * @var array
*/ */
protected $dontReport = [ protected $dontReport = [
AuthorizationException::class, AuthorizationException::class,
HttpException::class, HttpException::class,
ModelNotFoundException::class, ModelNotFoundException::class,
ValidationException::class, ValidationException::class,
]; ];
/** /**
* Report or log an exception. * Report or log an exception.
@ -36,14 +36,14 @@ class Handler extends ExceptionHandler
* @param \Exception $e * @param \Exception $e
* @return bool|void * @return bool|void
*/ */
public function report(Exception $e) public function report(Exception $e)
{ {
// don't show these errors in the logs // don't show these errors in the logs
if ($e instanceof HttpResponseException) { if ($e instanceof HttpResponseException) {
return false; return false;
} }
if (Utils::isNinja() && !Utils::isTravis()) { if (Utils::isNinja() && ! Utils::isTravis()) {
Utils::logError(Utils::getErrorString($e)); Utils::logError(Utils::getErrorString($e));
return false; return false;
} else { } else {
@ -51,16 +51,15 @@ class Handler extends ExceptionHandler
} }
} }
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $e * @param \Exception $e
* * @return \Illuminate\Http\Response
* @return \Illuminate\Http\Response */
*/ public function render($request, Exception $e)
public function render($request, Exception $e) {
{
if ($e instanceof ModelNotFoundException) { if ($e instanceof ModelNotFoundException) {
return Redirect::to('/'); return Redirect::to('/');
} elseif ($e instanceof \Illuminate\Session\TokenMismatchException) { } elseif ($e instanceof \Illuminate\Session\TokenMismatchException) {
@ -68,27 +67,26 @@ class Handler extends ExceptionHandler
if ($request->path() != 'get_started') { if ($request->path() != 'get_started') {
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e // https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
return redirect() return redirect()
->back() ->back()
->withInput($request->except('password', '_token')) ->withInput($request->except('password', '_token'))
->with([ ->with([
'warning' => trans('texts.token_expired') 'warning' => trans('texts.token_expired')
]); ]);
} }
} }
// In production, except for maintenance mode, we'll show a custom error screen // In production, except for maintenance mode, we'll show a custom error screen
if (Utils::isNinjaProd() if (Utils::isNinjaProd()
&& !Utils::isDownForMaintenance() && !Utils::isDownForMaintenance()
&& !($e instanceof HttpResponseException) && !($e instanceof HttpResponseException)) {
) {
$data = [ $data = [
'error' => get_class($e), 'error' => get_class($e),
'hideHeader' => true, 'hideHeader' => true,
]; ];
return response()->view('error', $data); return response()->view('error', $data);
} else { } else {
return parent::render($request, $e); return parent::render($request, $e);
} }
} }
} }

View File

@ -1,83 +1,51 @@
<?php <?php namespace App\Handlers;
namespace App\Handlers;
use App\Models\Invoice;
use App\Models\Payment;
use App\Ninja\Mailers\UserMailer; use App\Ninja\Mailers\UserMailer;
use App\Ninja\Mailers\ContactMailer; use App\Ninja\Mailers\ContactMailer;
class InvoiceEventHandler class InvoiceEventHandler
{ {
/** protected $userMailer;
* @var UserMailer protected $contactMailer;
*/
protected $userMailer;
/** public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
* @var ContactMailer {
*/ $this->userMailer = $userMailer;
protected $contactMailer; $this->contactMailer = $contactMailer;
}
/** public function subscribe($events)
* InvoiceEventHandler constructor. {
* $events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
* @param UserMailer $userMailer $events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
* @param ContactMailer $contactMailer $events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
*/ }
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
{
$this->userMailer = $userMailer;
$this->contactMailer = $contactMailer;
}
/** public function onSent($invoice)
* @param $events {
*/ $this->sendNotifications($invoice, 'sent');
public function subscribe($events) }
{
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
}
/** public function onViewed($invoice)
* @param Invoice $invoice {
*/ $this->sendNotifications($invoice, 'viewed');
public function onSent(Invoice $invoice) }
{
$this->sendNotifications($invoice, 'sent');
}
/** public function onPaid($payment)
* @param Invoice $invoice {
*/ $this->contactMailer->sendPaymentConfirmation($payment);
public function onViewed(Invoice $invoice)
{
$this->sendNotifications($invoice, 'viewed');
}
/** $this->sendNotifications($payment->invoice, 'paid', $payment);
* @param Payment $payment }
*/
public function onPaid(Payment $payment)
{
$this->contactMailer->sendPaymentConfirmation($payment);
$this->sendNotifications($payment->invoice, 'paid', $payment); private function sendNotifications($invoice, $type, $payment = null)
} {
foreach ($invoice->account->users as $user)
/** {
* @param Invoice $invoice if ($user->{'notify_' . $type})
* @param $type {
* @param null $payment
*/
private function sendNotifications(Invoice $invoice, $type, $payment = null)
{
foreach ($invoice->account->users as $user) {
if ($user->{'notify_' . $type}) {
$this->userMailer->sendNotification($user, $invoice, $type, $payment); $this->userMailer->sendNotification($user, $invoice, $type, $payment);
} }
} }
} }
} }

View File

@ -1461,6 +1461,7 @@ class AccountController extends BaseController
return trans('texts.create_invoice_for_sample'); return trans('texts.create_invoice_for_sample');
} }
/** @var \App\Models\Account $account */
$account = Auth::user()->account; $account = Auth::user()->account;
$invitation = $invoice->invitations->first(); $invitation = $invoice->invitations->first();

View File

@ -62,7 +62,7 @@ class CreditController extends BaseController
'method' => 'POST', 'method' => 'POST',
'url' => 'credits', 'url' => 'credits',
'title' => trans('texts.new_credit'), 'title' => trans('texts.new_credit'),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
]; ];
return View::make('credits.edit', $data); return View::make('credits.edit', $data);

View File

@ -1,6 +1,5 @@
<?php namespace App\Http\Controllers; <?php namespace App\Http\Controllers;
use Utils;
use Redirect; use Redirect;
use View; use View;
use Response; use Response;
@ -96,10 +95,6 @@ class DocumentController extends BaseController
public function postUpload(CreateDocumentRequest $request) public function postUpload(CreateDocumentRequest $request)
{ {
if (!Utils::hasFeature(FEATURE_DOCUMENTS)) {
return;
}
$result = $this->documentRepo->upload($request->all(), $doc_array); $result = $this->documentRepo->upload($request->all(), $doc_array);
if(is_string($result)){ if(is_string($result)){

File diff suppressed because it is too large Load Diff

View File

@ -56,4 +56,4 @@ class AnalyticsListener
curl_setopt_array($curl, $opts); curl_setopt_array($curl, $opts);
curl_close($curl); curl_close($curl);
} }
} }

View File

@ -49,13 +49,6 @@ class Client extends EntityModel
'website', 'website',
]; ];
/**
* @var array
*/
protected $appends = [
'display_name',
];
/** /**
* @var string * @var string
*/ */
@ -338,17 +331,6 @@ class Client extends EntityModel
return $contact->getDisplayName(); return $contact->getDisplayName();
} }
/**
* Making the virtual property display_name accessible
* via an accessor
*
* @return mixed|string
*/
public function getDisplayNameAttribute()
{
return $this->getDisplayName();
}
/** /**
* @return string * @return string
*/ */

View File

@ -140,9 +140,7 @@ class Invoice extends EntityModel implements BalanceAffecting
*/ */
public function getDisplayName() public function getDisplayName()
{ {
return $this->is_recurring return $this->is_recurring ? trans('texts.recurring') : $this->invoice_number;
? trans('texts.recurring')
: $this->invoice_number.' ('.$this->client->display_name.')';
} }
/** /**

View File

@ -1,20 +1,12 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use URL; use URL;
use App\Models\AccountGateway; use App\Models\AccountGateway;
/**
* Class AccountGatewayDatatable
*/
class AccountGatewayDatatable extends EntityDatatable class AccountGatewayDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_ACCOUNT_GATEWAY; public $entityType = ENTITY_ACCOUNT_GATEWAY;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -56,9 +48,6 @@ class AccountGatewayDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [

View File

@ -1,19 +1,11 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
/**
* Class ActivityDatatable
*/
class ActivityDatatable extends EntityDatatable class ActivityDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_ACTIVITY; public $entityType = ENTITY_ACTIVITY;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [

View File

@ -1,19 +1,11 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use URL; use URL;
/**
* Class BankAccountDatatable
*/
class BankAccountDatatable extends EntityDatatable class BankAccountDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_BANK_ACCOUNT; public $entityType = ENTITY_BANK_ACCOUNT;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -25,16 +17,13 @@ class BankAccountDatatable extends EntityDatatable
], ],
[ [
'bank_library_id', 'bank_library_id',
function () { function ($model) {
return 'OFX'; return 'OFX';
} }
], ],
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -46,4 +35,6 @@ class BankAccountDatatable extends EntityDatatable
] ]
]; ];
} }
} }

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class ClientDatatable
*/
class ClientDatatable extends EntityDatatable class ClientDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_CLIENT; public $entityType = ENTITY_CLIENT;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -58,9 +50,6 @@ class ClientDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -85,7 +74,7 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("tasks/create/{$model->public_id}"); return URL::to("tasks/create/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_TASK); return Auth::user()->can('create', ENTITY_TASK);
} }
], ],
@ -94,7 +83,7 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("invoices/create/{$model->public_id}"); return URL::to("invoices/create/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_INVOICE); return Auth::user()->can('create', ENTITY_INVOICE);
} }
], ],
@ -103,13 +92,13 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("quotes/create/{$model->public_id}"); return URL::to("quotes/create/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE); return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE);
} }
], ],
[ [
'--divider--', function(){return false;}, '--divider--', function(){return false;},
function () { function ($model) {
$user = Auth::user(); $user = Auth::user();
return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE)); return ($user->can('create', ENTITY_TASK) || $user->can('create', ENTITY_INVOICE)) && ($user->can('create', ENTITY_PAYMENT) || $user->can('create', ENTITY_CREDIT) || $user->can('create', ENTITY_EXPENSE));
} }
@ -119,7 +108,7 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("payments/create/{$model->public_id}"); return URL::to("payments/create/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_PAYMENT); return Auth::user()->can('create', ENTITY_PAYMENT);
} }
], ],
@ -128,7 +117,7 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("credits/create/{$model->public_id}"); return URL::to("credits/create/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_CREDIT); return Auth::user()->can('create', ENTITY_CREDIT);
} }
], ],
@ -137,7 +126,7 @@ class ClientDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("expenses/create/0/{$model->public_id}"); return URL::to("expenses/create/0/{$model->public_id}");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_EXPENSE); return Auth::user()->can('create', ENTITY_EXPENSE);
} }
] ]

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class CreditDatatable
*/
class CreditDatatable extends EntityDatatable class CreditDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_CREDIT; public $entityType = ENTITY_CREDIT;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -57,9 +49,6 @@ class CreditDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -68,7 +57,7 @@ class CreditDatatable extends EntityDatatable
function ($model) { function ($model) {
return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1'; return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1';
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_PAYMENT); return Auth::user()->can('create', ENTITY_PAYMENT);
} }
] ]

View File

@ -1,47 +1,22 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
/**
* Class EntityDatatable
*/
class EntityDatatable class EntityDatatable
{ {
public $entityType; public $entityType;
/**
* @var bool
*/
public $isBulkEdit; public $isBulkEdit;
/**
* @var bool
*/
public $hideClient; public $hideClient;
/**
* EntityDatatable constructor.
*
* @param bool $isBulkEdit
* @param bool $hideClient
*/
public function __construct($isBulkEdit = true, $hideClient = false) public function __construct($isBulkEdit = true, $hideClient = false)
{ {
$this->isBulkEdit = $isBulkEdit; $this->isBulkEdit = $isBulkEdit;
$this->hideClient = $hideClient; $this->hideClient = $hideClient;
} }
/**
* @return array
*/
public function columns() public function columns()
{ {
return []; return [];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return []; return [];

View File

@ -1,20 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class ExpenseCategoryDatatable
*/
class ExpenseCategoryDatatable extends EntityDatatable class ExpenseCategoryDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_EXPENSE_CATEGORY; public $entityType = ENTITY_EXPENSE_CATEGORY;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -32,9 +25,6 @@ class ExpenseCategoryDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class ExpenseDatatable
*/
class ExpenseDatatable extends EntityDatatable class ExpenseDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_EXPENSE; public $entityType = ENTITY_EXPENSE;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -95,9 +87,6 @@ class ExpenseDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -131,13 +120,7 @@ class ExpenseDatatable extends EntityDatatable
]; ];
} }
/**
* @param $invoiceId
* @param $shouldBeInvoiced
* @param $balance
*
* @return string
*/
private function getStatusLabel($invoiceId, $shouldBeInvoiced, $balance) private function getStatusLabel($invoiceId, $shouldBeInvoiced, $balance)
{ {
if ($invoiceId) { if ($invoiceId) {
@ -158,4 +141,5 @@ class ExpenseDatatable extends EntityDatatable
return "<h4><div class=\"label label-{$class}\">$label</div></h4>"; return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
} }
} }

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class InvoiceDatatable
*/
class InvoiceDatatable extends EntityDatatable class InvoiceDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_INVOICE; public $entityType = ENTITY_INVOICE;
/**
* @return array
*/
public function columns() public function columns()
{ {
$entityType = $this->entityType; $entityType = $this->entityType;
@ -80,9 +72,6 @@ class InvoiceDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
$entityType = $this->entityType; $entityType = $this->entityType;
@ -102,7 +91,7 @@ class InvoiceDatatable extends EntityDatatable
function ($model) use ($entityType) { function ($model) use ($entityType) {
return URL::to("{$entityType}s/{$model->public_id}/clone"); return URL::to("{$entityType}s/{$model->public_id}/clone");
}, },
function () { function ($model) {
return Auth::user()->can('create', ENTITY_INVOICE); return Auth::user()->can('create', ENTITY_INVOICE);
} }
], ],
@ -166,11 +155,6 @@ class InvoiceDatatable extends EntityDatatable
]; ];
} }
/**
* @param $model
*
* @return string
*/
private function getStatusLabel($model) private function getStatusLabel($model)
{ {
$entityType = $this->entityType; $entityType = $this->entityType;
@ -205,4 +189,5 @@ class InvoiceDatatable extends EntityDatatable
return "<h4><div class=\"label label-{$class}\">$label</div></h4>"; return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
} }
} }

View File

@ -1,32 +1,20 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use App\Models\Payment;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
use App\Models\PaymentMethod; use App\Models\PaymentMethod;
/**
* Class PaymentDatatable
*/
class PaymentDatatable extends EntityDatatable class PaymentDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_PAYMENT; public $entityType = ENTITY_PAYMENT;
/**
* @var array
*/
protected static $refundableGateways = [ protected static $refundableGateways = [
GATEWAY_STRIPE, GATEWAY_STRIPE,
GATEWAY_BRAINTREE, GATEWAY_BRAINTREE,
GATEWAY_WEPAY, GATEWAY_WEPAY,
]; ];
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -113,9 +101,7 @@ class PaymentDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -148,12 +134,7 @@ class PaymentDatatable extends EntityDatatable
]; ];
} }
/** private function getStatusLabel($model)
* @param Payment $model
*
* @return string
*/
private function getStatusLabel(Payment $model)
{ {
$label = trans('texts.status_' . strtolower($model->payment_status_name)); $label = trans('texts.status_' . strtolower($model->payment_status_name));
$class = 'default'; $class = 'default';

View File

@ -1,22 +1,14 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
use Str; use Str;
/**
* Class ProductDatatable
*/
class ProductDatatable extends EntityDatatable class ProductDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_PRODUCT; public $entityType = ENTITY_PRODUCT;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -48,9 +40,6 @@ class ProductDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -62,4 +51,5 @@ class ProductDatatable extends EntityDatatable
] ]
]; ];
} }
} }

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class RecurringInvoiceDatatable
*/
class RecurringInvoiceDatatable extends EntityDatatable class RecurringInvoiceDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_RECURRING_INVOICE; public $entityType = ENTITY_RECURRING_INVOICE;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -55,9 +47,6 @@ class RecurringInvoiceDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -72,4 +61,5 @@ class RecurringInvoiceDatatable extends EntityDatatable
] ]
]; ];
} }
} }

View File

@ -1,22 +1,14 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
use App\Models\Task; use App\Models\Task;
/**
* Class TaskDatatable
*/
class TaskDatatable extends EntityDatatable class TaskDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_TASK; public $entityType = ENTITY_TASK;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -58,9 +50,6 @@ class TaskDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -103,11 +92,6 @@ class TaskDatatable extends EntityDatatable
]; ];
} }
/**
* @param $model
*
* @return string
*/
private function getStatusLabel($model) private function getStatusLabel($model)
{ {
if ($model->invoice_number) { if ($model->invoice_number) {

View File

@ -1,19 +1,11 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use URL; use URL;
/**
* Class TaxRateDatatable
*/
class TaxRateDatatable extends EntityDatatable class TaxRateDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_TAX_RATE; public $entityType = ENTITY_TAX_RATE;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -32,9 +24,6 @@ class TaxRateDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [

View File

@ -1,19 +1,11 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use URL; use URL;
/**
* Class TokenDatatable
*/
class TokenDatatable extends EntityDatatable class TokenDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_TOKEN; public $entityType = ENTITY_TOKEN;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -32,9 +24,6 @@ class TokenDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [

View File

@ -1,19 +1,11 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use URL; use URL;
/**
* Class UserDatatable
*/
class UserDatatable extends EntityDatatable class UserDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_USER; public $entityType = ENTITY_USER;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -50,9 +42,6 @@ class UserDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -77,11 +66,6 @@ class UserDatatable extends EntityDatatable
]; ];
} }
/**
* @param $state
*
* @return string
*/
private function getStatusLabel($state) private function getStatusLabel($state)
{ {
$label = trans("texts.{$state}"); $label = trans("texts.{$state}");

View File

@ -1,21 +1,13 @@
<?php <?php namespace App\Ninja\Datatables;
namespace App\Ninja\Datatables;
use Utils; use Utils;
use URL; use URL;
use Auth; use Auth;
/**
* Class VendorDatatable
*/
class VendorDatatable extends EntityDatatable class VendorDatatable extends EntityDatatable
{ {
public $entityType = ENTITY_VENDOR; public $entityType = ENTITY_VENDOR;
/**
* @return array
*/
public function columns() public function columns()
{ {
return [ return [
@ -52,9 +44,6 @@ class VendorDatatable extends EntityDatatable
]; ];
} }
/**
* @return array
*/
public function actions() public function actions()
{ {
return [ return [
@ -85,4 +74,6 @@ class VendorDatatable extends EntityDatatable
] ]
]; ];
} }
} }

View File

@ -1,9 +1,8 @@
<?php <?php namespace App\Ninja\Mailers;
namespace App\Ninja\Mailers;
use App\Models\Invitation; use App\Models\Invitation;
use Utils; use Utils;
use Event;
use Auth; use Auth;
use App\Services\TemplateService; use App\Services\TemplateService;
use App\Models\Invoice; use App\Models\Invoice;

View File

@ -1,9 +1,8 @@
<?php <?php namespace App\Ninja\Mailers;
namespace App\Ninja\Mailers;
use Exception; use Exception;
use Mail; use Mail;
use App\Models\Invoice;
/** /**
* Class Mailer * Class Mailer
@ -97,7 +96,6 @@ class Mailer
/** /**
* @param $exception * @param $exception
*
* @return string * @return string
*/ */
private function handleFailure($exception) private function handleFailure($exception)

View File

@ -1,15 +1,11 @@
<?php <?php namespace App\Ninja\Mailers;
namespace App\Ninja\Mailers;
use App\Models\Invitation; use App\Models\Invitation;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\User; use App\Models\User;
/**
* Class UserMailer
*/
class UserMailer extends Mailer class UserMailer extends Mailer
{ {
/** /**

View File

@ -1,14 +1,6 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class AuthorizeNetAIMPaymentDriver
*/
class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'refId'; protected $transactionReferenceParam = 'refId';
} }

View File

@ -1,9 +1,5 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\AccountGateway;
use App\Models\Invitation;
use URL; use URL;
use Session; use Session;
use Request; use Request;
@ -17,59 +13,26 @@ use App\Models\Payment;
use App\Models\PaymentMethod; use App\Models\PaymentMethod;
use App\Models\Country; use App\Models\Country;
/**
* Class BasePaymentDriver
*/
class BasePaymentDriver class BasePaymentDriver
{ {
public $invitation; public $invitation;
/**
* @var AccountGateway
*/
public $accountGateway; public $accountGateway;
protected $gatewayType; protected $gatewayType;
protected $gateway; protected $gateway;
protected $customer; protected $customer;
protected $sourceId; protected $sourceId;
/**
* @var array
*/
protected $input; protected $input;
protected $customerResponse; protected $customerResponse;
protected $tokenResponse; protected $tokenResponse;
protected $purchaseResponse; protected $purchaseResponse;
/**
* @var string
*/
protected $sourceReferenceParam = 'token'; protected $sourceReferenceParam = 'token';
/**
* @var string
*/
protected $customerReferenceParam; protected $customerReferenceParam;
/**
* @var string
*/
protected $transactionReferenceParam; protected $transactionReferenceParam;
/** public function __construct($accountGateway = false, $invitation = false, $gatewayType = false)
* BasePaymentDriver constructor.
*
* @param AccountGateway $accountGateway
* @param Invitation $invitation
* @param bool $gatewayType
*/
public function __construct(
AccountGateway $accountGateway = null,
Invitation $invitation = null,
$gatewayType = false
)
{ {
$this->accountGateway = $accountGateway; $this->accountGateway = $accountGateway;
$this->invitation = $invitation; $this->invitation = $invitation;
@ -91,9 +54,6 @@ class BasePaymentDriver
} }
} }
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
return [ return [
@ -106,74 +66,44 @@ class BasePaymentDriver
return in_array($type, $this->gatewayTypes()); return in_array($type, $this->gatewayTypes());
} }
/** // when set to true we won't pass the card details with the form
* When set to true we won't pass the card details with the form
*
* @return bool
*/
public function tokenize() public function tokenize()
{ {
return false; return false;
} }
/** // set payment method as pending until confirmed
* Set payment method as pending until confirmed
*
* @return bool
*/
public function isTwoStep() public function isTwoStep()
{ {
return false; return false;
} }
/**
* @return string
*/
public function providerName() public function providerName()
{ {
return strtolower($this->accountGateway->gateway->provider); return strtolower($this->accountGateway->gateway->provider);
} }
/**
* @return mixed
*/
protected function invoice() protected function invoice()
{ {
return $this->invitation->invoice; return $this->invitation->invoice;
} }
/**
* @return mixed
*/
protected function contact() protected function contact()
{ {
return $this->invitation->contact; return $this->invitation->contact;
} }
/**
* @return mixed
*/
protected function client() protected function client()
{ {
return $this->invoice()->client; return $this->invoice()->client;
} }
/**
* @return mixed
*/
protected function account() protected function account()
{ {
return $this->client()->account; return $this->client()->account;
} }
/** public function startPurchase($input = false, $sourceId = false)
* @param array $input
* @param bool $sourceId
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
* @throws Exception
*/
public function startPurchase(array $input = null, $sourceId = false)
{ {
$this->input = $input; $this->input = $input;
$this->sourceId = $sourceId; $this->sourceId = $sourceId;
@ -220,11 +150,7 @@ class BasePaymentDriver
return view($this->paymentView(), $data); return view($this->paymentView(), $data);
} }
/** // check if a custom view exists for this provider
* Check if a custom view exists for this provider
*
* @return mixed
*/
protected function paymentView() protected function paymentView()
{ {
$file = sprintf('%s/views/payments/%s/%s.blade.php', resource_path(), $this->providerName(), $this->gatewayType); $file = sprintf('%s/views/payments/%s/%s.blade.php', resource_path(), $this->providerName(), $this->gatewayType);
@ -236,11 +162,7 @@ class BasePaymentDriver
} }
} }
/** // check if a custom partial exists for this provider
* Check if a custom partial exists for this provider
*
* @return bool
*/
public function partialView() public function partialView()
{ {
$file = sprintf('%s/views/payments/%s/partial.blade.php', resource_path(), $this->providerName()); $file = sprintf('%s/views/payments/%s/partial.blade.php', resource_path(), $this->providerName());
@ -252,9 +174,6 @@ class BasePaymentDriver
} }
} }
/**
* @return array
*/
public function rules() public function rules()
{ {
$rules = []; $rules = [];
@ -290,9 +209,6 @@ class BasePaymentDriver
return $rules; return $rules;
} }
/**
* @return mixed
*/
protected function gateway() protected function gateway()
{ {
if ($this->gateway) { if ($this->gateway) {
@ -305,14 +221,7 @@ class BasePaymentDriver
return $this->gateway; return $this->gateway;
} }
/** public function completeOnsitePurchase($input = false, $paymentMethod = false)
* @param bool $input
* @param PaymentMethod $paymentMethod
*
* @return Payment|mixed|void
* @throws Exception
*/
public function completeOnsitePurchase($input = false, PaymentMethod $paymentMethod = null)
{ {
$this->input = count($input) ? $input : false; $this->input = count($input) ? $input : false;
$gateway = $this->gateway(); $gateway = $this->gateway();
@ -406,12 +315,7 @@ class BasePaymentDriver
$client->save(); $client->save();
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$invoice = $this->invoice(); $invoice = $this->invoice();
$completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType); $completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType);
@ -441,13 +345,9 @@ class BasePaymentDriver
return $data; return $data;
} }
/** private function paymentDetailsFromInput($input)
* @param array $input
*
* @return array
*/
private function paymentDetailsFromInput(array $input)
{ {
$invoice = $this->invoice();
$client = $this->client(); $client = $this->client();
$data = [ $data = [
@ -488,11 +388,9 @@ class BasePaymentDriver
return $data; return $data;
} }
/**
* @return array
*/
public function paymentDetailsFromClient() public function paymentDetailsFromClient()
{ {
$invoice = $this->invoice();
$client = $this->client(); $client = $this->client();
$contact = $this->invitation->contact ?: $client->contacts()->first(); $contact = $this->invitation->contact ?: $client->contacts()->first();
@ -518,9 +416,6 @@ class BasePaymentDriver
]; ];
} }
/**
* @return bool
*/
protected function shouldCreateToken() protected function shouldCreateToken()
{ {
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) { if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
@ -538,11 +433,19 @@ class BasePaymentDriver
return boolval(array_get($this->input, 'token_billing')); return boolval(array_get($this->input, 'token_billing'));
} }
/** /*
* @param bool $clientId protected function tokenDetails()
* {
* @return null $details = [];
*/
if ($customer = $this->customer()) {
$details['customerReference'] = $customer->token;
}
return $details;
}
*/
public function customer($clientId = false) public function customer($clientId = false)
{ {
if ($this->customer) { if ($this->customer) {
@ -564,51 +467,27 @@ class BasePaymentDriver
return $this->customer; return $this->customer;
} }
/**
* @param $customer
*
* @return bool
*/
protected function checkCustomerExists($customer) protected function checkCustomerExists($customer)
{ {
return true; return true;
} }
/**
* @param $client
* @param $publicId
* @param $amount1
* @param $amount2
*
* @throws Exception
*/
public function verifyBankAccount($client, $publicId, $amount1, $amount2) public function verifyBankAccount($client, $publicId, $amount1, $amount2)
{ {
throw new Exception('verifyBankAccount not implemented'); throw new Exception('verifyBankAccount not implemented');
} }
/** public function removePaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
* @throws Exception
*/
public function removePaymentMethod(PaymentMethod $paymentMethod)
{ {
$paymentMethod->delete(); $paymentMethod->delete();
} }
/** // Some gateways (ie, Checkout.com and Braintree) require generating a token before paying for the invoice
* Some gateways (ie, Checkout.com and Braintree) require generating a token before paying for the invoice
*
* @return null
*/
public function createTransactionToken() public function createTransactionToken()
{ {
return null; return null;
} }
/**
* @return PaymentMethod
*/
public function createToken() public function createToken()
{ {
$account = $this->account(); $account = $this->account();
@ -623,6 +502,17 @@ class BasePaymentDriver
$customer->save(); $customer->save();
} }
/*
// archive the old payment method
$paymentMethod = PaymentMethod::clientId($this->client()->id)
->isBankAccount($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER))
->first();
if ($paymentMethod) {
$paymentMethod->delete();
}
*/
$paymentMethod = $this->createPaymentMethod($customer); $paymentMethod = $this->createPaymentMethod($customer);
if ($paymentMethod && ! $customer->default_payment_method_id) { if ($paymentMethod && ! $customer->default_payment_method_id) {
@ -633,24 +523,13 @@ class BasePaymentDriver
return $paymentMethod; return $paymentMethod;
} }
/**
* @param $customer
*
* @return mixed
*/
protected function creatingCustomer($customer) protected function creatingCustomer($customer)
{ {
return $customer; return $customer;
} }
/**
* @param $customer
*
* @return PaymentMethod
*/
public function createPaymentMethod($customer) public function createPaymentMethod($customer)
{ {
/** @var PaymentMethod $paymentMethod */
$paymentMethod = PaymentMethod::createNew($this->invitation); $paymentMethod = PaymentMethod::createNew($this->invitation);
$paymentMethod->contact_id = $this->contact()->id; $paymentMethod->contact_id = $this->contact()->id;
$paymentMethod->ip = Request::ip(); $paymentMethod->ip = Request::ip();
@ -665,12 +544,7 @@ class BasePaymentDriver
return $paymentMethod; return $paymentMethod;
} }
/** protected function creatingPaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return PaymentMethod
*/
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{ {
return $paymentMethod; return $paymentMethod;
} }
@ -680,13 +554,7 @@ class BasePaymentDriver
} }
/** public function createPayment($ref = false, $paymentMethod = null)
* @param bool $ref
* @param PaymentMethod|null $paymentMethod
*
* @return Payment|mixed
*/
public function createPayment($ref = false, PaymentMethod $paymentMethod = null)
{ {
$invitation = $this->invitation; $invitation = $this->invitation;
$invoice = $this->invoice(); $invoice = $this->invoice();
@ -773,24 +641,12 @@ class BasePaymentDriver
return $payment; return $payment;
} }
/** protected function creatingPayment($payment, $paymentMethod)
* @param Payment $payment
* @param $paymentMethod
*
* @return Payment
*/
protected function creatingPayment(Payment $payment, PaymentMethod $paymentMethod)
{ {
return $payment; return $payment;
} }
/** public function refundPayment($payment, $amount = 0)
* @param Payment $payment
* @param int $amount
*
* @return bool
*/
public function refundPayment(Payment $payment, $amount = 0)
{ {
if ($amount) { if ($amount) {
$amount = min($amount, $payment->getCompletedAmount()); $amount = min($amount, $payment->getCompletedAmount());
@ -822,13 +678,7 @@ class BasePaymentDriver
return false; return false;
} }
/** protected function refundDetails($payment, $amount)
* @param Payment $payment
* @param $amount
*
* @return array
*/
protected function refundDetails(Payment $payment, $amount)
{ {
return [ return [
'amount' => $amount, 'amount' => $amount,
@ -836,14 +686,7 @@ class BasePaymentDriver
]; ];
} }
/** protected function attemptVoidPayment($response, $payment, $amount)
* @param $response
* @param Payment $payment
* @param $amount
*
* @return bool
*/
protected function attemptVoidPayment($response, Payment $payment, $amount)
{ {
// Partial refund not allowed for unsettled transactions // Partial refund not allowed for unsettled transactions
return $amount == $payment->amount; return $amount == $payment->amount;
@ -854,13 +697,7 @@ class BasePaymentDriver
return $payment; return $payment;
} }
/** public function completeOffsitePurchase($input)
* @param $input
*
* @return bool|mixed
* @throws Exception
*/
public function completeOffsitePurchase(array $input)
{ {
$this->input = $input; $this->input = $input;
$ref = array_get($this->input, 'token') ?: $this->invitation->transaction_reference; $ref = array_get($this->input, 'token') ?: $this->invitation->transaction_reference;
@ -893,9 +730,6 @@ class BasePaymentDriver
return $this->createPayment($ref); return $this->createPayment($ref);
} }
/**
* @return array
*/
public function tokenLinks() public function tokenLinks()
{ {
if ( ! $this->customer()) { if ( ! $this->customer()) {
@ -933,9 +767,6 @@ class BasePaymentDriver
return $links; return $links;
} }
/**
* @return array
*/
public function paymentLinks() public function paymentLinks()
{ {
$links = []; $links = [];
@ -954,11 +785,6 @@ class BasePaymentDriver
return $links; return $links;
} }
/**
* @param $gatewayType
*
* @return string
*/
protected function paymentUrl($gatewayType) protected function paymentUrl($gatewayType)
{ {
$account = $this->account(); $account = $this->account();
@ -976,11 +802,6 @@ class BasePaymentDriver
return $url; return $url;
} }
/**
* @param $cardName
*
* @return mixed
*/
protected function parseCardType($cardName) { protected function parseCardType($cardName) {
$cardTypes = [ $cardTypes = [
'visa' => PAYMENT_TYPE_VISA, 'visa' => PAYMENT_TYPE_VISA,
@ -1013,11 +834,6 @@ class BasePaymentDriver
} }
} }
/**
* @param $input
*
* @throws Exception
*/
public function handleWebHook($input) public function handleWebHook($input)
{ {
throw new Exception('Unsupported gateway'); throw new Exception('Unsupported gateway');

View File

@ -1,19 +1,12 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class BitPayPaymentDriver
*/
class BitPayPaymentDriver extends BasePaymentDriver class BitPayPaymentDriver extends BasePaymentDriver
{ {
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
return [ return [
GATEWAY_TYPE_BITCOIN GATEWAY_TYPE_BITCOIN
]; ];
} }
} }

View File

@ -1,31 +1,14 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\PaymentMethod;
use Exception; use Exception;
use Session; use Session;
use Braintree\Customer; use Braintree\Customer;
use App\Models\Payment;
/**
* Class BraintreePaymentDriver
*/
class BraintreePaymentDriver extends BasePaymentDriver class BraintreePaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $customerReferenceParam = 'customerId'; protected $customerReferenceParam = 'customerId';
/**
* @var string
*/
protected $sourceReferenceParam = 'paymentMethodToken'; protected $sourceReferenceParam = 'paymentMethodToken';
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
$types = [ $types = [
@ -40,36 +23,30 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $types; return $types;
} }
/**
* @return bool
*/
public function tokenize() public function tokenize()
{ {
return true; return true;
} }
/** public function startPurchase($input = false, $sourceId = false)
* @param array $input
* @param bool $sourceId
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function startPurchase(array $input = null, $sourceId = false)
{ {
$data = parent::startPurchase($input, $sourceId); $data = parent::startPurchase($input, $sourceId);
if ($this->isGatewayType(GATEWAY_TYPE_PAYPAL)) { if ($this->isGatewayType(GATEWAY_TYPE_PAYPAL)) {
/*
if ( ! $sourceId || empty($input['device_data'])) {
throw new Exception();
}
Session::put($this->invitation->id . 'device_data', $input['device_data']);
*/
$data['details'] = ! empty($input['device_data']) ? json_decode($input['device_data']) : false; $data['details'] = ! empty($input['device_data']) ? json_decode($input['device_data']) : false;
} }
return $data; return $data;
} }
/**
* @param $customer
*
* @return bool
*/
protected function checkCustomerExists($customer) protected function checkCustomerExists($customer)
{ {
if ( ! parent::checkCustomerExists($customer)) { if ( ! parent::checkCustomerExists($customer)) {
@ -83,12 +60,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
return ($customer instanceof Customer); return ($customer instanceof Customer);
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails($paymentMethod); $data = parent::paymentDetails($paymentMethod);
@ -109,9 +81,6 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $data; return $data;
} }
/**
* @return PaymentMethod|bool
*/
public function createToken() public function createToken()
{ {
if ($customer = $this->customer()) { if ($customer = $this->customer()) {
@ -144,9 +113,6 @@ class BraintreePaymentDriver extends BasePaymentDriver
return parent::createToken(); return parent::createToken();
} }
/**
* @return array
*/
private function customerData() private function customerData()
{ {
return [ return [
@ -159,11 +125,6 @@ class BraintreePaymentDriver extends BasePaymentDriver
]; ];
} }
/**
* @param $customer
*
* @return mixed
*/
public function creatingCustomer($customer) public function creatingCustomer($customer)
{ {
$customer->token = $this->tokenResponse->customerId; $customer->token = $this->tokenResponse->customerId;
@ -171,12 +132,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $customer; return $customer;
} }
/** protected function creatingPaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return PaymentMethod|null
*/
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{ {
$response = $this->tokenResponse; $response = $this->tokenResponse;
@ -196,13 +152,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
return $paymentMethod; return $paymentMethod;
} }
/** public function removePaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return bool
* @throws Exception
*/
public function removePaymentMethod(PaymentMethod $paymentMethod)
{ {
parent::removePaymentMethod($paymentMethod); parent::removePaymentMethod($paymentMethod);
@ -217,14 +167,7 @@ class BraintreePaymentDriver extends BasePaymentDriver
} }
} }
/** protected function attemptVoidPayment($response, $payment, $amount)
* @param $response
* @param Payment $payment
* @param $amount
*
* @return bool
*/
protected function attemptVoidPayment($response, Payment $payment, $amount)
{ {
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) { if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
return false; return false;
@ -242,9 +185,6 @@ class BraintreePaymentDriver extends BasePaymentDriver
return false; return false;
} }
/**
* @return mixed
*/
public function createTransactionToken() public function createTransactionToken()
{ {
return $this->gateway() return $this->gateway()

View File

@ -1,17 +1,7 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\PaymentMethod;
/**
* Class CheckoutComPaymentDriver
*/
class CheckoutComPaymentDriver extends BasePaymentDriver class CheckoutComPaymentDriver extends BasePaymentDriver
{ {
/**
* @return bool
*/
public function createTransactionToken() public function createTransactionToken()
{ {
$response = $this->gateway()->purchase([ $response = $this->gateway()->purchase([
@ -31,12 +21,7 @@ class CheckoutComPaymentDriver extends BasePaymentDriver
return false; return false;
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails(); $data = parent::paymentDetails();

View File

@ -1,24 +1,10 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class CybersourcePaymentDriver
*/
class CybersourcePaymentDriver extends BasePaymentDriver class CybersourcePaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'transaction_uuid'; protected $transactionReferenceParam = 'transaction_uuid';
/** public function completeOffsitePurchase($input)
* @param array $input
*
* @return \App\Models\Payment|mixed
* @throws Exception
*/
public function completeOffsitePurchase(array $input)
{ {
if ($input['decision'] == 'ACCEPT') { if ($input['decision'] == 'ACCEPT') {
return $this->createPayment($input['bill_trans_ref_no']); return $this->createPayment($input['bill_trans_ref_no']);

View File

@ -1,23 +1,12 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class DwollaPaymentDriver
*/
class DwollaPaymentDriver extends BasePaymentDriver class DwollaPaymentDriver extends BasePaymentDriver
{ {
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
return [GATEWAY_TYPE_DWOLLA]; return [GATEWAY_TYPE_DWOLLA];
} }
/**
* @return mixed
*/
protected function gateway() protected function gateway()
{ {
$gateway = parent::gateway(); $gateway = parent::gateway();

View File

@ -1,14 +1,6 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class EwayRapidSharedPaymentDriver
*/
class EwayRapidSharedPaymentDriver extends BasePaymentDriver class EwayRapidSharedPaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'AccessCode'; protected $transactionReferenceParam = 'AccessCode';
} }

View File

@ -1,14 +1,6 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class GoCardlessPaymentDriver
*/
class GoCardlessPaymentDriver extends BasePaymentDriver class GoCardlessPaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'signature'; protected $transactionReferenceParam = 'signature';
} }

View File

@ -1,18 +1,8 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class MolliePaymentDriver
*/
class MolliePaymentDriver extends BasePaymentDriver class MolliePaymentDriver extends BasePaymentDriver
{ {
/** public function completeOffsitePurchase($input)
* @param $input
*
* @return \App\Models\Payment|mixed
*/
public function completeOffsitePurchase(array $input)
{ {
$details = $this->paymentDetails(); $details = $this->paymentDetails();

View File

@ -1,18 +1,10 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class PayFastPaymentDriver
*/
class PayFastPaymentDriver extends BasePaymentDriver class PayFastPaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'm_payment_id'; protected $transactionReferenceParam = 'm_payment_id';
public function completeOffsitePurchase(array $input) public function completeOffsitePurchase($input)
{ {
if ($accountGateway->isGateway(GATEWAY_PAYFAST) && Request::has('pt')) { if ($accountGateway->isGateway(GATEWAY_PAYFAST) && Request::has('pt')) {
$token = Request::query('pt'); $token = Request::query('pt');

View File

@ -1,18 +1,8 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\Payment;
use App\Models\PaymentMethod;
/**
* Class PayPalExpressPaymentDriver
*/
class PayPalExpressPaymentDriver extends BasePaymentDriver class PayPalExpressPaymentDriver extends BasePaymentDriver
{ {
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
return [ return [
@ -20,12 +10,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
]; ];
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails(); $data = parent::paymentDetails();
@ -34,13 +19,7 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
return $data; return $data;
} }
/** protected function creatingPayment($payment, $paymentMethod)
* @param Payment $payment
* @param PaymentMethod $paymentMethod
*
* @return Payment
*/
protected function creatingPayment(Payment $payment, PaymentMethod $paymentMethod)
{ {
$payment->payer_id = $this->input['PayerID']; $payment->payer_id = $this->input['PayerID'];

View File

@ -1,17 +1,7 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\PaymentMethod;
/**
* Class PayPalProPaymentDriver
*/
class PayPalProPaymentDriver extends BasePaymentDriver class PayPalProPaymentDriver extends BasePaymentDriver
{ {
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
return [ return [
@ -19,12 +9,7 @@ class PayPalProPaymentDriver extends BasePaymentDriver
]; ];
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails(); $data = parent::paymentDetails();

View File

@ -1,25 +1,14 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use Exception; use Exception;
use Cache; use Cache;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentMethod; use App\Models\PaymentMethod;
/**
* Class StripePaymentDriver
*/
class StripePaymentDriver extends BasePaymentDriver class StripePaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $customerReferenceParam = 'customerReference'; protected $customerReferenceParam = 'customerReference';
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
$types = [ $types = [
@ -34,17 +23,11 @@ class StripePaymentDriver extends BasePaymentDriver
return $types; return $types;
} }
/**
* @return bool|mixed
*/
public function tokenize() public function tokenize()
{ {
return $this->accountGateway->getPublishableStripeKey(); return $this->accountGateway->getPublishableStripeKey();
} }
/**
* @return array
*/
public function rules() public function rules()
{ {
$rules = parent::rules(); $rules = parent::rules();
@ -56,11 +39,6 @@ class StripePaymentDriver extends BasePaymentDriver
return $rules; return $rules;
} }
/**
* @param $customer
*
* @return bool
*/
protected function checkCustomerExists($customer) protected function checkCustomerExists($customer)
{ {
$response = $this->gateway() $response = $this->gateway()
@ -85,20 +63,12 @@ class StripePaymentDriver extends BasePaymentDriver
return true; return true;
} }
/**
* @return bool
*/
public function isTwoStep() public function isTwoStep()
{ {
return $this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER) && empty($this->input['plaidPublicToken']); return $this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER) && empty($this->input['plaidPublicToken']);
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails($paymentMethod); $data = parent::paymentDetails($paymentMethod);
@ -123,10 +93,6 @@ class StripePaymentDriver extends BasePaymentDriver
return $data; return $data;
} }
/**
* @return PaymentMethod
* @throws Exception
*/
public function createToken() public function createToken()
{ {
$invoice = $this->invitation->invoice; $invoice = $this->invitation->invoice;
@ -160,11 +126,6 @@ class StripePaymentDriver extends BasePaymentDriver
} }
} }
/**
* @param $customer
*
* @return mixed
*/
public function creatingCustomer($customer) public function creatingCustomer($customer)
{ {
$customer->token = $this->tokenResponse['id']; $customer->token = $this->tokenResponse['id'];
@ -172,12 +133,7 @@ class StripePaymentDriver extends BasePaymentDriver
return $customer; return $customer;
} }
/** protected function creatingPaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return PaymentMethod|bool
*/
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
{ {
$data = $this->tokenResponse; $data = $this->tokenResponse;
@ -219,30 +175,16 @@ class StripePaymentDriver extends BasePaymentDriver
return $paymentMethod; return $paymentMethod;
} }
/** protected function creatingPayment($payment, $paymentMethod)
* @param Payment $payment
* @param PaymentMethod $paymentMethod
*
* @return Payment
*/
protected function creatingPayment(Payment $payment, PaymentMethod $paymentMethod)
{ {
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER, $paymentMethod)) { if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER, $paymentMethod)) {
$payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded' $payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded' ? PAYMENT_STATUS_COMPLETED : PAYMENT_STATUS_PENDING;
? PAYMENT_STATUS_COMPLETED
: PAYMENT_STATUS_PENDING;
} }
return $payment; return $payment;
} }
/** public function removePaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return bool
* @throws Exception
*/
public function removePaymentMethod(PaymentMethod $paymentMethod)
{ {
parent::removePaymentMethod($paymentMethod); parent::removePaymentMethod($paymentMethod);
@ -262,13 +204,6 @@ class StripePaymentDriver extends BasePaymentDriver
} }
} }
/**
* @param $publicToken
* @param $accountId
*
* @return mixed
* @throws Exception
*/
private function getPlaidToken($publicToken, $accountId) private function getPlaidToken($publicToken, $accountId)
{ {
$clientId = $this->accountGateway->getPlaidClientId(); $clientId = $this->accountGateway->getPlaidClientId();
@ -311,14 +246,6 @@ class StripePaymentDriver extends BasePaymentDriver
} }
} }
/**
* @param $client
* @param $publicId
* @param $amount1
* @param $amount2
*
* @return bool|mixed|string
*/
public function verifyBankAccount($client, $publicId, $amount1, $amount2) public function verifyBankAccount($client, $publicId, $amount1, $amount2)
{ {
$customer = $this->customer($client->id); $customer = $this->customer($client->id);
@ -349,13 +276,6 @@ class StripePaymentDriver extends BasePaymentDriver
return true; return true;
} }
/**
* @param $method
* @param $url
* @param null $body
*
* @return mixed|string
*/
public function makeStripeCall($method, $url, $body = null) public function makeStripeCall($method, $url, $body = null)
{ {
$apiKey = $this->accountGateway->getConfig()->apiKey; $apiKey = $this->accountGateway->getConfig()->apiKey;
@ -392,12 +312,6 @@ class StripePaymentDriver extends BasePaymentDriver
} }
} }
/**
* @param $input
*
* @return array|string
* @throws Exception
*/
public function handleWebHook($input) public function handleWebHook($input)
{ {
$eventId = array_get($input, 'id'); $eventId = array_get($input, 'id');

View File

@ -1,24 +1,11 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
/**
* Class TwoCheckoutPaymentDriver
*/
class TwoCheckoutPaymentDriver extends BasePaymentDriver class TwoCheckoutPaymentDriver extends BasePaymentDriver
{ {
/**
* @var string
*/
protected $transactionReferenceParam = 'cart_order_id'; protected $transactionReferenceParam = 'cart_order_id';
/** // Calling completePurchase results in an 'invalid key' error
* Calling completePurchase results in an 'invalid key' error public function completeOffsitePurchase($input)
*
* @param array $input
* @return \App\Models\Payment|mixed
*/
public function completeOffsitePurchase(array $input)
{ {
return $this->createPayment($input['order_number']); return $this->createPayment($input['order_number']);
} }

View File

@ -1,21 +1,12 @@
<?php <?php namespace App\Ninja\PaymentDrivers;
namespace App\Ninja\PaymentDrivers;
use App\Models\PaymentMethod;
use Session; use Session;
use Utils; use Utils;
use App\Models\Payment; use App\Models\Payment;
use Exception; use Exception;
/**
* Class WePayPaymentDriver
*/
class WePayPaymentDriver extends BasePaymentDriver class WePayPaymentDriver extends BasePaymentDriver
{ {
/**
* @return array
*/
public function gatewayTypes() public function gatewayTypes()
{ {
$types = [ $types = [
@ -30,27 +21,16 @@ class WePayPaymentDriver extends BasePaymentDriver
return $types; return $types;
} }
/**
* @return bool
*/
public function tokenize() public function tokenize()
{ {
return true; return true;
} }
/**
* @param $customer
*
* @return bool
*/
protected function checkCustomerExists($customer) protected function checkCustomerExists($customer)
{ {
return true; return true;
} }
/**
* @return array
*/
public function rules() public function rules()
{ {
$rules = parent::rules(); $rules = parent::rules();
@ -65,12 +45,7 @@ class WePayPaymentDriver extends BasePaymentDriver
return $rules; return $rules;
} }
/** protected function paymentDetails($paymentMethod = false)
* @param PaymentMethod $paymentMethod
*
* @return array
*/
protected function paymentDetails(PaymentMethod $paymentMethod = null)
{ {
$data = parent::paymentDetails($paymentMethod); $data = parent::paymentDetails($paymentMethod);
@ -89,9 +64,6 @@ class WePayPaymentDriver extends BasePaymentDriver
return $data; return $data;
} }
/**
* @return PaymentMethod
*/
public function createToken() public function createToken()
{ {
$wepay = Utils::setupWePay($this->accountGateway); $wepay = Utils::setupWePay($this->accountGateway);
@ -105,6 +77,22 @@ class WePayPaymentDriver extends BasePaymentDriver
'payment_bank_id' => $token, 'payment_bank_id' => $token,
]); ]);
} else { } else {
// Authorize credit card
$tokenResponse = $wepay->request('credit_card/authorize', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => $token,
]);
// Update the callback uri and get the card details
$tokenResponse = $wepay->request('credit_card/modify', [
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
'credit_card_id' => $token,
'auto_update' => WEPAY_AUTO_UPDATE,
'callback_uri' => $this->accountGateway->getWebhookUrl(),
]);
$this->tokenResponse = $wepay->request('credit_card', [ $this->tokenResponse = $wepay->request('credit_card', [
'client_id' => WEPAY_CLIENT_ID, 'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET, 'client_secret' => WEPAY_CLIENT_SECRET,
@ -115,12 +103,23 @@ class WePayPaymentDriver extends BasePaymentDriver
return parent::createToken(); return parent::createToken();
} }
/** /*
* @param PaymentMethod $paymentMethod public function creatingCustomer($customer)
* {
* @return PaymentMethod if ($gatewayResponse instanceof \Omnipay\WePay\Message\CustomCheckoutResponse) {
*/ $wepay = \Utils::setupWePay($accountGateway);
protected function creatingPaymentMethod(PaymentMethod $paymentMethod) $paymentMethodType = $gatewayResponse->getData()['payment_method']['type'];
$gatewayResponse = $wepay->request($paymentMethodType, array(
'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET,
$paymentMethodType.'_id' => $gatewayResponse->getData()['payment_method'][$paymentMethodType]['id'],
));
}
}
*/
protected function creatingPaymentMethod($paymentMethod)
{ {
$source = $this->tokenResponse; $source = $this->tokenResponse;
@ -149,13 +148,7 @@ class WePayPaymentDriver extends BasePaymentDriver
return $paymentMethod; return $paymentMethod;
} }
/** public function removePaymentMethod($paymentMethod)
* @param PaymentMethod $paymentMethod
*
* @return bool
* @throws Exception
*/
public function removePaymentMethod(PaymentMethod $paymentMethod)
{ {
parent::removePaymentMethod($paymentMethod); parent::removePaymentMethod($paymentMethod);
@ -173,13 +166,7 @@ class WePayPaymentDriver extends BasePaymentDriver
} }
} }
/** protected function refundDetails($payment, $amount)
* @param Payment $payment
* @param $amount
*
* @return array
*/
protected function refundDetails(Payment $payment, $amount)
{ {
$data = parent::refundDetails($payment, $amount); $data = parent::refundDetails($payment, $amount);
@ -195,7 +182,7 @@ class WePayPaymentDriver extends BasePaymentDriver
return $data; return $data;
} }
protected function attemptVoidPayment($response, Payment $payment, $amount) protected function attemptVoidPayment($response, $payment, $amount)
{ {
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) { if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
return false; return false;
@ -237,6 +224,8 @@ class WePayPaymentDriver extends BasePaymentDriver
if ($source->state == 'deleted') { if ($source->state == 'deleted') {
$paymentMethod->delete(); $paymentMethod->delete();
} else {
//$this->paymentService->convertPaymentMethodFromWePay($source, null, $paymentMethod)->save();
} }
return 'Processed successfully'; return 'Processed successfully';

View File

@ -1,27 +1,14 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
/**
* Class AccountGatewayRepository
*/
class AccountGatewayRepository extends BaseRepository class AccountGatewayRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\AccountGateway'; return 'App\Models\AccountGateway';
} }
/**
* @param $accountId
*
* @return $this
*/
public function find($accountId) public function find($accountId)
{ {
$query = DB::table('account_gateways') $query = DB::table('account_gateways')

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use Auth; use Auth;
use Request; use Request;
@ -24,9 +22,6 @@ use App\Models\User;
use App\Models\UserAccount; use App\Models\UserAccount;
use App\Models\AccountToken; use App\Models\AccountToken;
/**
* Class AccountRepository
*/
class AccountRepository class AccountRepository
{ {
public function create($firstName = '', $lastName = '', $email = '', $password = '') public function create($firstName = '', $lastName = '', $email = '', $password = '')
@ -643,10 +638,7 @@ class AccountRepository
return $users; return $users;
} }
/** public function unlinkAccount($account) {
* @param Account $account
*/
public function unlinkAccount(Account $account) {
foreach ($account->users as $user) { foreach ($account->users as $user) {
if ($userAccount = self::findUserAccounts($user->id)) { if ($userAccount = self::findUserAccounts($user->id)) {
$userAccount->removeUserId($user->id); $userAccount->removeUserId($user->id);
@ -689,11 +681,7 @@ class AccountRepository
return $code; return $code;
} }
/** public function createTokens($user, $name)
* @param User $user
* @param $name
*/
public function createTokens(User $user, $name)
{ {
$name = trim($name) ?: 'TOKEN'; $name = trim($name) ?: 'TOKEN';
$users = $this->findUsers($user); $users = $this->findUsers($user);
@ -710,12 +698,7 @@ class AccountRepository
} }
} }
/** public function getUserAccountId($account)
* @param Account $account
*
* @return bool|mixed
*/
public function getUserAccountId(Account $account)
{ {
$user = $account->users()->first(); $user = $account->users()->first();
$userAccount = $this->findUserAccounts($user->id); $userAccount = $this->findUserAccounts($user->id);
@ -723,11 +706,7 @@ class AccountRepository
return $userAccount ? $userAccount->id : false; return $userAccount ? $userAccount->id : false;
} }
/** public function save($data, $account)
* @param $data
* @param Account $account
*/
public function save($data, Account $account)
{ {
$account->fill($data); $account->fill($data);
$account->save(); $account->save();

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Auth; use Auth;
@ -10,20 +8,8 @@ use App\Models\Activity;
use App\Models\Client; use App\Models\Client;
use App\Models\Invitation; use App\Models\Invitation;
/**
* Class ActivityRepository
*/
class ActivityRepository class ActivityRepository
{ {
/**
* @param $entity
* @param $activityTypeId
* @param int $balanceChange
* @param int $paidToDateChange
* @param null $altEntity
*
* @return Activity|mixed
*/
public function create($entity, $activityTypeId, $balanceChange = 0, $paidToDateChange = 0, $altEntity = null) public function create($entity, $activityTypeId, $balanceChange = 0, $paidToDateChange = 0, $altEntity = null)
{ {
if ($entity instanceof Client) { if ($entity instanceof Client) {
@ -57,11 +43,6 @@ class ActivityRepository
return $activity; return $activity;
} }
/**
* @param $entity
*
* @return Activity
*/
private function getBlank($entity) private function getBlank($entity)
{ {
$activity = new Activity(); $activity = new Activity();
@ -83,11 +64,6 @@ class ActivityRepository
return $activity; return $activity;
} }
/**
* @param $clientId
*
* @return $this
*/
public function findByClientId($clientId) public function findByClientId($clientId)
{ {
return DB::table('activities') return DB::table('activities')

View File

@ -1,30 +1,17 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Crypt; use Crypt;
use App\Models\BankAccount; use App\Models\BankAccount;
use App\Models\BankSubaccount; use App\Models\BankSubaccount;
/**
* Class BankAccountRepository
*/
class BankAccountRepository extends BaseRepository class BankAccountRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\BankAccount'; return 'App\Models\BankAccount';
} }
/**
* @param $accountId
*
* @return $this
*/
public function find($accountId) public function find($accountId)
{ {
return DB::table('bank_accounts') return DB::table('bank_accounts')
@ -39,11 +26,6 @@ class BankAccountRepository extends BaseRepository
); );
} }
/**
* @param $input
*
* @return mixed
*/
public function save($input) public function save($input)
{ {
$bankAccount = BankAccount::createNew(); $bankAccount = BankAccount::createNew();

View File

@ -1,29 +1,19 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Cache; use Cache;
use App\Models\Client; use App\Models\Client;
use App\Models\Contact;
use App\Events\ClientWasCreated; use App\Events\ClientWasCreated;
use App\Events\ClientWasUpdated; use App\Events\ClientWasUpdated;
/**
* Class ClientRepository
*/
class ClientRepository extends BaseRepository class ClientRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Client'; return 'App\Models\Client';
} }
/**
* @return mixed
*/
public function all() public function all()
{ {
return Client::scope() return Client::scope()
@ -33,12 +23,6 @@ class ClientRepository extends BaseRepository
->get(); ->get();
} }
/**
* @param null $filter
* @param bool $userId
*
* @return $this
*/
public function find($filter = null, $userId = false) public function find($filter = null, $userId = false)
{ {
$query = DB::table('clients') $query = DB::table('clients')
@ -84,13 +68,7 @@ class ClientRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($data, $client = null)
* @param $data
* @param Client|null $client
*
* @return Client|mixed
*/
public function save($data, Client $client = null)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;
@ -117,6 +95,12 @@ class ClientRepository extends BaseRepository
$client->fill($data); $client->fill($data);
$client->save(); $client->save();
/*
if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
return $client;
}
*/
$first = true; $first = true;
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts']; $contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
$contactIds = []; $contactIds = [];

View File

@ -1,19 +1,9 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use App\Models\Contact; use App\Models\Contact;
/**
* Class ContactRepository
*/
class ContactRepository extends BaseRepository class ContactRepository extends BaseRepository
{ {
/**
* @param $data
*
* @return mixed
*/
public function save($data) public function save($data)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;

View File

@ -1,31 +1,17 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils; use Utils;
use App\Models\Credit; use App\Models\Credit;
use App\Models\Client; use App\Models\Client;
/**
* Class CreditRepository
*/
class CreditRepository extends BaseRepository class CreditRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Credit'; return 'App\Models\Credit';
} }
/**
* @param null $clientPublicId
* @param null $filter
*
* @return $this
*/
public function find($clientPublicId = null, $filter = null) public function find($clientPublicId = null, $filter = null)
{ {
$query = DB::table('credits') $query = DB::table('credits')
@ -72,13 +58,7 @@ class CreditRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($input, $credit = null)
* @param $input
* @param Credit|null $credit
*
* @return Credit|mixed
*/
public function save($input, Credit $credit = null)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils; use Utils;
@ -8,22 +6,14 @@ use App\Models\Document;
use Intervention\Image\ImageManager; use Intervention\Image\ImageManager;
use Form; use Form;
/**
* Class DocumentRepository
*/
class DocumentRepository extends BaseRepository class DocumentRepository extends BaseRepository
{ {
/** // Expenses
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Document'; return 'App\Models\Document';
} }
/**
* @return mixed
*/
public function all() public function all()
{ {
return Document::scope() return Document::scope()
@ -31,9 +21,6 @@ class DocumentRepository extends BaseRepository
->get(); ->get();
} }
/**
* @return $this
*/
public function find() public function find()
{ {
$accountid = \Auth::user()->account_id; $accountid = \Auth::user()->account_id;
@ -63,12 +50,6 @@ class DocumentRepository extends BaseRepository
return $query; return $query;
} }
/**
* @param $data
* @param null $doc_array
*
* @return mixed
*/
public function upload($data, &$doc_array=null) public function upload($data, &$doc_array=null)
{ {
$uploaded = $data['file']; $uploaded = $data['file'];
@ -196,14 +177,6 @@ class DocumentRepository extends BaseRepository
return $document; return $document;
} }
/**
* @param $contactId
* @param $entityType
* @param $search
*
* @return \Illuminate\Http\JsonResponse
* @throws \Exception
*/
public function getClientDatatable($contactId, $entityType, $search) public function getClientDatatable($contactId, $entityType, $search)
{ {

View File

@ -1,26 +1,17 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils;
use Auth; use Auth;
use App\Models\ExpenseCategory; use App\Models\ExpenseCategory;
class ExpenseCategoryRepository extends BaseRepository class ExpenseCategoryRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\ExpenseCategory'; return 'App\Models\ExpenseCategory';
} }
/**
* @param null $filter
*
* @return $this
*/
public function find($filter = null) public function find($filter = null)
{ {
$query = DB::table('expense_categories') $query = DB::table('expense_categories')
@ -45,14 +36,10 @@ class ExpenseCategoryRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($input, $category = false)
* @param array $input
* @param ExpenseCategory $category
*
* @return ExpenseCategory|mixed
*/
public function save(array $input, ExpenseCategory $category = false)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
if ( ! $category) { if ( ! $category) {
$category = ExpenseCategory::createNew(); $category = ExpenseCategory::createNew();
} }

View File

@ -1,6 +1,4 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils; use Utils;
@ -9,37 +7,21 @@ use App\Models\Expense;
use App\Models\Vendor; use App\Models\Vendor;
use App\Models\Document; use App\Models\Document;
/**
* Class ExpenseRepository
*/
class ExpenseRepository extends BaseRepository class ExpenseRepository extends BaseRepository
{ {
/**
* @var DocumentRepository
*/
protected $documentRepo; protected $documentRepo;
/** // Expenses
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Expense'; return 'App\Models\Expense';
} }
/**
* ExpenseRepository constructor.
*
* @param DocumentRepository $documentRepo
*/
public function __construct(DocumentRepository $documentRepo) public function __construct(DocumentRepository $documentRepo)
{ {
$this->documentRepo = $documentRepo; $this->documentRepo = $documentRepo;
} }
/**
* @return mixed
*/
public function all() public function all()
{ {
return Expense::scope() return Expense::scope()
@ -49,11 +31,6 @@ class ExpenseRepository extends BaseRepository
->get(); ->get();
} }
/**
* @param $vendorPublicId
*
* @return mixed
*/
public function findVendor($vendorPublicId) public function findVendor($vendorPublicId)
{ {
$vendorId = Vendor::getPrivateId($vendorPublicId); $vendorId = Vendor::getPrivateId($vendorPublicId);
@ -63,11 +40,6 @@ class ExpenseRepository extends BaseRepository
return $query; return $query;
} }
/**
* @param null $filter
*
* @return $this
*/
public function find($filter = null) public function find($filter = null)
{ {
$accountid = \Auth::user()->account_id; $accountid = \Auth::user()->account_id;
@ -138,13 +110,7 @@ class ExpenseRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($input, $expense = null)
* @param array $input
* @param Expense|null $expense
*
* @return Expense|mixed
*/
public function save(array $input, Expense $expense = null)
{ {
$publicId = isset($input['public_id']) ? $input['public_id'] : false; $publicId = isset($input['public_id']) ? $input['public_id'] : false;
@ -208,12 +174,6 @@ class ExpenseRepository extends BaseRepository
return $expense; return $expense;
} }
/**
* @param $ids
* @param $action
*
* @return int
*/
public function bulk($ids, $action) public function bulk($ids, $action)
{ {
$expenses = Expense::withTrashed()->scope($ids)->get(); $expenses = Expense::withTrashed()->scope($ids)->get();
@ -234,6 +194,6 @@ class ExpenseRepository extends BaseRepository
} }
} }
return $expenses->count(); return count($tasks);
} }
} }

View File

@ -748,7 +748,6 @@ class InvoiceRepository extends BaseRepository
/** /**
* @param Invoice $recurInvoice * @param Invoice $recurInvoice
*
* @return mixed * @return mixed
*/ */
public function createRecurringInvoice(Invoice $recurInvoice) public function createRecurringInvoice(Invoice $recurInvoice)
@ -840,7 +839,6 @@ class InvoiceRepository extends BaseRepository
/** /**
* @param Account $account * @param Account $account
*
* @return mixed * @return mixed
*/ */
public function findNeedingReminding(Account $account) public function findNeedingReminding(Account $account)

View File

@ -1,20 +1,10 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use App\Models\Account; use App\Models\Account;
use App\Models\Company;
/**
* Class NinjaRepository
*/
class NinjaRepository class NinjaRepository
{ {
/** public function updatePlanDetails($clientPublicId, $data)
* @param $clientPublicId
* @param array $data
*/
public function updatePlanDetails($clientPublicId, array $data)
{ {
$account = Account::whereId($clientPublicId)->first(); $account = Account::whereId($clientPublicId)->first();
@ -22,7 +12,6 @@ class NinjaRepository
return; return;
} }
/** @var Company $company */
$company = $account->company; $company = $account->company;
$company->plan = !empty($data['plan']) && $data['plan'] != PLAN_FREE?$data['plan']:null; $company->plan = !empty($data['plan']) && $data['plan'] != PLAN_FREE?$data['plan']:null;
$company->plan_term = !empty($data['plan_term'])?$data['plan_term']:null; $company->plan_term = !empty($data['plan_term'])?$data['plan_term']:null;

View File

@ -1,31 +1,18 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils; use Utils;
use App\Models\Payment; use App\Models\Payment;
use App\Models\Credit; use App\Models\Credit;
use App\Models\Invoice;
/**
* Class PaymentRepository
*/
class PaymentRepository extends BaseRepository class PaymentRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Payment'; return 'App\Models\Payment';
} }
/**
* @param null $clientPublicId
* @param null $filter
*
* @return $this
*/
public function find($clientPublicId = null, $filter = null) public function find($clientPublicId = null, $filter = null)
{ {
$query = DB::table('payments') $query = DB::table('payments')
@ -100,12 +87,6 @@ class PaymentRepository extends BaseRepository
return $query; return $query;
} }
/**
* @param null $contactId
* @param null $filter
*
* @return $this
*/
public function findForContact($contactId = null, $filter = null) public function findForContact($contactId = null, $filter = null)
{ {
$query = DB::table('payments') $query = DB::table('payments')
@ -161,13 +142,7 @@ class PaymentRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($input, $payment = null)
* @param array $input
* @param Payment|null $payment
*
* @return Payment|mixed
*/
public function save(array $input, Payment $payment = null)
{ {
$publicId = isset($input['public_id']) ? $input['public_id'] : false; $publicId = isset($input['public_id']) ? $input['public_id'] : false;
@ -226,11 +201,6 @@ class PaymentRepository extends BaseRepository
return $payment; return $payment;
} }
/**
* @param $payment
*
* @return bool
*/
public function delete($payment) public function delete($payment)
{ {
if ($payment->invoice->is_deleted) { if ($payment->invoice->is_deleted) {
@ -240,11 +210,6 @@ class PaymentRepository extends BaseRepository
parent::delete($payment); parent::delete($payment);
} }
/**
* @param $payment
*
* @return bool
*/
public function restore($payment) public function restore($payment)
{ {
if ($payment->invoice->is_deleted) { if ($payment->invoice->is_deleted) {

View File

@ -1,27 +1,18 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
class PaymentTermRepository extends BaseRepository class PaymentTermRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\PaymentTerm'; return 'App\Models\PaymentTerm';
} }
/**
* @param int $accountId
*
* @return $this
*/
public function find($accountId = 0) public function find($accountId = 0)
{ {
return DB::table('payment_terms') return DB::table('payment_terms')
//->where('payment_terms.account_id', '=', $accountId)
->where('payment_terms.deleted_at', '=', null) ->where('payment_terms.deleted_at', '=', null)
->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at'); ->select('payment_terms.public_id', 'payment_terms.name', 'payment_terms.num_days', 'payment_terms.deleted_at');
} }

View File

@ -1,26 +1,15 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use App\Models\Product; use App\Models\Product;
/**
* Class ProductRepository
*/
class ProductRepository extends BaseRepository class ProductRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Product'; return 'App\Models\Product';
} }
/**
* @return mixed
*/
public function all() public function all()
{ {
return Product::scope() return Product::scope()
@ -28,11 +17,6 @@ class ProductRepository extends BaseRepository
->get(); ->get();
} }
/**
* @param $accountId
*
* @return $this
*/
public function find($accountId) public function find($accountId)
{ {
return DB::table('products') return DB::table('products')
@ -53,13 +37,7 @@ class ProductRepository extends BaseRepository
); );
} }
/** public function save($data, $product = null)
* @param array $data
* @param Product|null $product
*
* @return Product|mixed
*/
public function save(array $data, Product $product = null)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;

View File

@ -1,19 +1,9 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use App\Models\Account; use App\Models\Account;
/**
* Class ReferralRepository
*/
class ReferralRepository class ReferralRepository
{ {
/**
* @param $userId
*
* @return array
*/
public function getCounts($userId) public function getCounts($userId)
{ {
$accounts = Account::where('referral_user_id', $userId)->get(); $accounts = Account::where('referral_user_id', $userId)->get();

View File

@ -1,23 +1,12 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use Auth; use Auth;
use Session; use Session;
use App\Models\Client; use App\Models\Client;
use App\Models\Task; use App\Models\Task;
/**
* Class TaskRepository
*/
class TaskRepository class TaskRepository
{ {
/**
* @param null $clientPublicId
* @param null $filter
*
* @return $this
*/
public function find($clientPublicId = null, $filter = null) public function find($clientPublicId = null, $filter = null)
{ {
$query = \DB::table('tasks') $query = \DB::table('tasks')
@ -73,14 +62,7 @@ class TaskRepository
return $query; return $query;
} }
/** public function save($publicId, $data, $task = null)
* @param $publicId
* @param array $data
* @param Task|null $task
*
* @return Task|mixed
*/
public function save($publicId, array $data, Task $task = null)
{ {
if ($task) { if ($task) {
// do nothing // do nothing
@ -127,12 +109,6 @@ class TaskRepository
return $task; return $task;
} }
/**
* @param $ids
* @param $action
*
* @return int
*/
public function bulk($ids, $action) public function bulk($ids, $action)
{ {
$tasks = Task::withTrashed()->scope($ids)->get(); $tasks = Task::withTrashed()->scope($ids)->get();

View File

@ -1,28 +1,16 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Utils;
use App\Models\TaxRate; use App\Models\TaxRate;
/**
* Class TaxRateRepository
*/
class TaxRateRepository extends BaseRepository class TaxRateRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\TaxRate'; return 'App\Models\TaxRate';
} }
/**
* @param $accountId
*
* @return $this
*/
public function find($accountId) public function find($accountId)
{ {
return DB::table('tax_rates') return DB::table('tax_rates')
@ -31,13 +19,7 @@ class TaxRateRepository extends BaseRepository
->select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate', 'tax_rates.deleted_at'); ->select('tax_rates.public_id', 'tax_rates.name', 'tax_rates.rate', 'tax_rates.deleted_at');
} }
/** public function save($data, $taxRate = null)
* @param array $data
* @param TaxRate|null $taxRate
*
* @return TaxRate|mixed
*/
public function save(array $data, TaxRate $taxRate = null)
{ {
if ($taxRate) { if ($taxRate) {
// do nothing // do nothing
@ -53,4 +35,41 @@ class TaxRateRepository extends BaseRepository
return $taxRate; return $taxRate;
} }
/*
public function save($taxRates)
{
$taxRateIds = [];
foreach ($taxRates as $record) {
if (!isset($record->rate) || (isset($record->is_deleted) && $record->is_deleted)) {
continue;
}
if (!isset($record->name) || !trim($record->name)) {
continue;
}
if ($record->public_id) {
$taxRate = TaxRate::scope($record->public_id)->firstOrFail();
} else {
$taxRate = TaxRate::createNew();
}
$taxRate->rate = Utils::parseFloat($record->rate);
$taxRate->name = trim($record->name);
$taxRate->save();
$taxRateIds[] = $taxRate->public_id;
}
$taxRates = TaxRate::scope()->get();
foreach ($taxRates as $taxRate) {
if (!in_array($taxRate->public_id, $taxRateIds)) {
$taxRate->delete();
}
}
}
*/
} }

View File

@ -1,29 +1,16 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use Session; use Session;
use App\Models\Token; use App\Models\Token;
/**
* Class TokenRepository
*/
class TokenRepository extends BaseRepository class TokenRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\AccountToken'; return 'App\Models\AccountToken';
} }
/**
* @param $userId
*
* @return $this
*/
public function find($userId) public function find($userId)
{ {
$query = DB::table('account_tokens') $query = DB::table('account_tokens')

View File

@ -1,29 +1,16 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use App\Models\User;
use DB; use DB;
use Session; use Session;
use App\Models\User;
/**
* Class UserRepository
*/
class UserRepository extends BaseRepository class UserRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\User'; return 'App\Models\User';
} }
/**
* @param $accountId
*
* @return $this
*/
public function find($accountId) public function find($accountId)
{ {
$query = DB::table('users') $query = DB::table('users')
@ -38,13 +25,7 @@ class UserRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($data, $user)
* @param array $data
* @param User $user
*
* @return User
*/
public function save(array $data, User $user)
{ {
$user->fill($data); $user->fill($data);
$user->save(); $user->save();

View File

@ -1,25 +1,18 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use App\Models\Vendor;
use App\Models\VendorContact; use App\Models\VendorContact;
/** // vendor
* Class VendorContactRepository
*/
class VendorContactRepository extends BaseRepository class VendorContactRepository extends BaseRepository
{ {
/** public function save($data)
* @param array $data
* @return mixed
*/
public function save(array $data)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;
if (!$publicId || $publicId == '-1') { if (!$publicId || $publicId == '-1') {
/** @var VendorContact $contact */
$contact = VendorContact::createNew(); $contact = VendorContact::createNew();
//$contact->send_invoice = true;
$contact->vendor_id = $data['vendor_id']; $contact->vendor_id = $data['vendor_id'];
$contact->is_primary = VendorContact::scope()->where('vendor_id', '=', $contact->vendor_id)->count() == 0; $contact->is_primary = VendorContact::scope()->where('vendor_id', '=', $contact->vendor_id)->count() == 0;
} else { } else {

View File

@ -1,26 +1,16 @@
<?php <?php namespace App\Ninja\Repositories;
namespace App\Ninja\Repositories;
use DB; use DB;
use App\Models\Vendor; use App\Models\Vendor;
/** // vendor
* Class VendorRepository
*/
class VendorRepository extends BaseRepository class VendorRepository extends BaseRepository
{ {
/**
* @return string
*/
public function getClassName() public function getClassName()
{ {
return 'App\Models\Vendor'; return 'App\Models\Vendor';
} }
/**
* @return mixed
*/
public function all() public function all()
{ {
return Vendor::scope() return Vendor::scope()
@ -30,11 +20,6 @@ class VendorRepository extends BaseRepository
->get(); ->get();
} }
/**
* @param null $filter
*
* @return $this
*/
public function find($filter = null) public function find($filter = null)
{ {
$query = DB::table('vendors') $query = DB::table('vendors')
@ -75,13 +60,7 @@ class VendorRepository extends BaseRepository
return $query; return $query;
} }
/** public function save($data, $vendor = null)
* @param array $data
* @param Vendor|null $vendor
*
* @return Vendor|mixed
*/
public function save(array $data, Vendor $vendor = null)
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : false; $publicId = isset($data['public_id']) ? $data['public_id'] : false;
@ -96,7 +75,15 @@ class VendorRepository extends BaseRepository
$vendor->fill($data); $vendor->fill($data);
$vendor->save(); $vendor->save();
$first = true;
$vendorcontacts = isset($data['vendor_contact']) ? [$data['vendor_contact']] : $data['vendor_contacts'];
foreach ($vendorcontacts as $vendorcontact) {
$vendorcontact = $vendor->addVendorContact($vendorcontact, $first);
$first = false;
}
return $vendor; return $vendor;
} }
} }

View File

@ -29,4 +29,4 @@ class UserTransformer extends EntityTransformer
'permissions' => (int) $user->getOriginal('permissions'), 'permissions' => (int) $user->getOriginal('permissions'),
]; ];
} }
} }

View File

@ -2,10 +2,4 @@
namespace App\Policies; namespace App\Policies;
/** class ClientPolicy extends EntityPolicy {}
* Class ClientPolicy
*/
class ClientPolicy extends EntityPolicy
{
}

View File

@ -2,10 +2,4 @@
namespace App\Policies; namespace App\Policies;
/** class CreditPolicy extends EntityPolicy {}
* Class CreditPolicy
*/
class CreditPolicy extends EntityPolicy
{
}

View File

@ -2,7 +2,6 @@
namespace App\Policies; namespace App\Policies;
use App\Models\Document;
use App\Models\User; use App\Models\User;
/** /**
@ -12,7 +11,6 @@ class DocumentPolicy extends EntityPolicy
{ {
/** /**
* @param User $user * @param User $user
*
* @return bool * @return bool
*/ */
public static function create(User $user) public static function create(User $user)
@ -22,11 +20,10 @@ class DocumentPolicy extends EntityPolicy
/** /**
* @param User $user * @param User $user
* @param $item * @param Document $document
*
* @return bool * @return bool
*/ */
public static function view(User $user, $item) public static function view(User $user, $document)
{ {
if ($user->hasPermission('view_all')) { if ($user->hasPermission('view_all')) {
return true; return true;

View File

@ -4,9 +4,6 @@ namespace App\Policies;
use App\Models\User; use App\Models\User;
/**
* Class ExpensePolicy
*/
class ExpensePolicy extends EntityPolicy class ExpensePolicy extends EntityPolicy
{ {
/** /**

View File

@ -2,10 +2,4 @@
namespace App\Policies; namespace App\Policies;
/** class InvoicePolicy extends EntityPolicy {}
* Class InvoicePolicy
*/
class InvoicePolicy extends EntityPolicy
{
}

View File

@ -2,10 +2,4 @@
namespace App\Policies; namespace App\Policies;
/** class PaymentPolicy extends EntityPolicy {}
* Class PaymentPolicy
*/
class PaymentPolicy extends EntityPolicy
{
}

View File

@ -2,28 +2,12 @@
namespace App\Policies; namespace App\Policies;
use App\Models\User;
/**
* Class TokenPolicy
*/
class TokenPolicy extends EntityPolicy { class TokenPolicy extends EntityPolicy {
/** public static function edit($user, $item) {
* @param User $user
* @param $item
*
* @return bool
*/
public static function edit(User $user, $item) {
return $user->hasPermission('admin'); return $user->hasPermission('admin');
} }
/** public static function create($user) {
* @param User $user
*
* @return bool
*/
public static function create(User $user) {
return $user->hasPermission('admin'); return $user->hasPermission('admin');
} }
} }

View File

@ -4,14 +4,10 @@ namespace App\Policies;
use App\Models\User; use App\Models\User;
/**
* Class VendorPolicy
*/
class VendorPolicy extends EntityPolicy class VendorPolicy extends EntityPolicy
{ {
/** /**
* @param User $user * @param User $user
*
* @return bool * @return bool
*/ */
public static function create(User $user) { public static function create(User $user) {

View File

@ -17,11 +17,6 @@ class ComposerServiceProvider extends ServiceProvider
['accounts.details', 'clients.edit', 'payments.edit', 'invoices.edit', 'accounts.localization'], ['accounts.details', 'clients.edit', 'payments.edit', 'invoices.edit', 'accounts.localization'],
'App\Http\ViewComposers\TranslationComposer' 'App\Http\ViewComposers\TranslationComposer'
); );
view()->composer(
['header', 'tasks.edit'],
'App\Http\ViewComposers\AppLanguageComposer'
);
} }
/** /**

View File

@ -154,4 +154,4 @@ class PushService
else else
return trans('texts.notification_invoice_viewed_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); return trans('texts.notification_invoice_viewed_subject', ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]);
} }
} }

View File

@ -3,10 +3,8 @@
"version": "0.9.0", "version": "0.9.0",
"dependencies": { "dependencies": {
"jquery": "1.11.3", "jquery": "1.11.3",
"jquery-ui": "1.11.2",
"bootstrap": "3.3.1", "bootstrap": "3.3.1",
"bootstrap-combobox": "1.1.7", "jquery-ui": "1.11.2",
"bootstrap-datepicker": "1.4.0",
"datatables": "1.10.4", "datatables": "1.10.4",
"datatables-bootstrap3": "*", "datatables-bootstrap3": "*",
"knockout.js": "3.1.0", "knockout.js": "3.1.0",
@ -15,13 +13,13 @@
"font-awesome": "~4.*", "font-awesome": "~4.*",
"underscore": "1.7.0", "underscore": "1.7.0",
"jspdf": "1.0.272", "jspdf": "1.0.272",
"jsPDF-plugins": "*", "bootstrap-datepicker": "1.4.0",
"typeahead.js": "0.11.1", "typeahead.js": "0.11.1",
"accounting": "0.3.2", "accounting": "0.3.2",
"spectrum": "1.3.4", "spectrum": "1.3.4",
"d3": "3.4.11", "d3": "3.4.11",
"handsontable": "*", "handsontable": "*",
"pdfmake": "0.1.17", "pdfmake": "*",
"moment": "*", "moment": "*",
"jsoneditor": "*", "jsoneditor": "*",
"moment-timezone": "~0.4.0", "moment-timezone": "~0.4.0",
@ -29,8 +27,7 @@
"datetimepicker": "~2.4.5", "datetimepicker": "~2.4.5",
"stacktrace-js": "~1.0.1", "stacktrace-js": "~1.0.1",
"fuse.js": "~2.0.2", "fuse.js": "~2.0.2",
"dropzone": "~4.3.0", "dropzone": "~4.3.0"
"lightbox2": "~2.8.2"
}, },
"resolutions": { "resolutions": {
"jquery": "~1.11" "jquery": "~1.11"

View File

@ -13,17 +13,13 @@
} }
], ],
"require": { "require": {
"php": ">=5.5.9",
"ext-mcrypt": "*",
"ext-gmp": "*",
"ext-gd": "*",
"turbo124/laravel-push-notification": "dev-laravel5", "turbo124/laravel-push-notification": "dev-laravel5",
"omnipay/mollie": "dev-master#22956c1a62a9662afa5f5d119723b413770ac525", "omnipay/mollie": "dev-master#22956c1a62a9662afa5f5d119723b413770ac525",
"omnipay/2checkout": "dev-master#e9c079c2dde0d7ba461903b3b7bd5caf6dee1248", "omnipay/2checkout": "dev-master#e9c079c2dde0d7ba461903b3b7bd5caf6dee1248",
"omnipay/gocardless": "dev-master", "omnipay/gocardless": "dev-master",
"omnipay/stripe": "dev-master", "omnipay/stripe": "dev-master",
"doctrine/dbal": "2.5.x", "doctrine/dbal": "2.5.x",
"laravelcollective/bus": "5.2.*", "laravelcollective/bus": "5.2.*",
"laravel/framework": "5.2.*", "laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.*", "laravelcollective/html": "5.2.*",
"symfony/css-selector": "~3.0", "symfony/css-selector": "~3.0",

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