mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Refactor docblocks, unused vars, unused uses
This commit is contained in:
parent
8590f9ad17
commit
71ab4dc3d8
@ -1,5 +1,10 @@
|
|||||||
<?php namespace App\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Commands;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Command
|
||||||
|
*/
|
||||||
abstract class Command
|
abstract class Command
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
@ -38,6 +40,7 @@ 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
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Carbon;
|
use Carbon;
|
||||||
@ -174,7 +176,6 @@ 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;
|
||||||
@ -182,8 +183,16 @@ 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(['activities.id', 'activities.created_at', 'activities.activity_type_id', 'activities.adjustment', 'activities.balance', 'activities.invoice_id']);
|
->get(
|
||||||
//$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) {
|
||||||
|
|
||||||
@ -231,13 +240,11 @@ 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;
|
||||||
}
|
}
|
||||||
@ -245,7 +252,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -255,7 +261,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -263,12 +268,10 @@ 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;
|
||||||
}
|
}
|
||||||
@ -276,7 +279,6 @@ 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;
|
||||||
}
|
}
|
||||||
@ -284,7 +286,6 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Vendor;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@ -32,6 +35,7 @@ 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
|
||||||
@ -126,9 +130,9 @@ class CreateTestData extends Command
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $client
|
* @param $client
|
||||||
* @param $invoice
|
* @param Invoice $invoice
|
||||||
*/
|
*/
|
||||||
private function createPayment($client, $invoice)
|
private function createPayment($client, Invoice $invoice)
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
@ -167,9 +171,9 @@ class CreateTestData extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $vendor
|
* @param Vendor $vendor
|
||||||
*/
|
*/
|
||||||
private function createExpense($vendor)
|
private function createExpense(Vendor $vendor)
|
||||||
{
|
{
|
||||||
for ($i=0; $i<$this->count; $i++) {
|
for ($i=0; $i<$this->count; $i++) {
|
||||||
$data = [
|
$data = [
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use File;
|
use File;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace InvoiceNinja\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace InvoiceNinja\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Foundation\Inspiring;
|
use Illuminate\Foundation\Inspiring;
|
||||||
@ -6,30 +8,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 name.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name = 'inspire';
|
protected $description = 'Display an inspiring quote';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected $description = 'Display an inspiring quote';
|
public function handle()
|
||||||
|
{
|
||||||
/**
|
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use App\Models\Document;
|
use App\Models\Document;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
@ -9,7 +10,6 @@ use Illuminate\Console\Command;
|
|||||||
*/
|
*/
|
||||||
class ResetData extends Command
|
class ResetData extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Services\BankAccountService;
|
use App\Services\BankAccountService;
|
||||||
|
@ -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,15 +51,16 @@ 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) {
|
||||||
@ -67,26 +68,27 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,83 @@
|
|||||||
<?php namespace App\Handlers;
|
<?php
|
||||||
|
|
||||||
|
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;
|
/**
|
||||||
protected $contactMailer;
|
* @var UserMailer
|
||||||
|
*/
|
||||||
|
protected $userMailer;
|
||||||
|
|
||||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
/**
|
||||||
{
|
* @var ContactMailer
|
||||||
$this->userMailer = $userMailer;
|
*/
|
||||||
$this->contactMailer = $contactMailer;
|
protected $contactMailer;
|
||||||
}
|
|
||||||
|
|
||||||
public function subscribe($events)
|
/**
|
||||||
{
|
* InvoiceEventHandler constructor.
|
||||||
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
*
|
||||||
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
* @param UserMailer $userMailer
|
||||||
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
* @param ContactMailer $contactMailer
|
||||||
}
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
private function sendNotifications($invoice, $type, $payment = null)
|
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
||||||
{
|
}
|
||||||
foreach ($invoice->account->users as $user)
|
|
||||||
{
|
/**
|
||||||
if ($user->{'notify_' . $type})
|
* @param Invoice $invoice
|
||||||
{
|
* @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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,20 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -48,6 +56,9 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -17,13 +25,16 @@ class BankAccountDatatable extends EntityDatatable
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'bank_library_id',
|
'bank_library_id',
|
||||||
function ($model) {
|
function () {
|
||||||
return 'OFX';
|
return 'OFX';
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -35,6 +46,4 @@ class BankAccountDatatable extends EntityDatatable
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -50,6 +58,9 @@ class ClientDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -74,7 +85,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_TASK);
|
return Auth::user()->can('create', ENTITY_TASK);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -83,7 +94,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -92,13 +103,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 ($model) {
|
function () {
|
||||||
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 ($model) {
|
function () {
|
||||||
$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));
|
||||||
}
|
}
|
||||||
@ -108,7 +119,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_PAYMENT);
|
return Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -117,7 +128,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_CREDIT);
|
return Auth::user()->can('create', ENTITY_CREDIT);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -126,7 +137,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_EXPENSE);
|
return Auth::user()->can('create', ENTITY_EXPENSE);
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -49,6 +57,9 @@ class CreditDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -57,7 +68,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_PAYMENT);
|
return Auth::user()->can('create', ENTITY_PAYMENT);
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1,22 +1,47 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [];
|
||||||
|
@ -1,13 +1,20 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -25,6 +32,9 @@ class ExpenseCategoryDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -87,6 +95,9 @@ class ExpenseDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -120,7 +131,13 @@ 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) {
|
||||||
@ -141,5 +158,4 @@ class ExpenseDatatable extends EntityDatatable
|
|||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
@ -72,6 +80,9 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
$entityType = $this->entityType;
|
$entityType = $this->entityType;
|
||||||
@ -91,7 +102,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 ($model) {
|
function () {
|
||||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -155,6 +166,11 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $model
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getStatusLabel($model)
|
private function getStatusLabel($model)
|
||||||
{
|
{
|
||||||
$entityType = $this->entityType;
|
$entityType = $this->entityType;
|
||||||
@ -189,5 +205,4 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
|
|
||||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,32 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -101,7 +113,9 @@ class PaymentDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -134,7 +148,12 @@ 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';
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -40,6 +48,9 @@ class ProductDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -51,5 +62,4 @@ class ProductDatatable extends EntityDatatable
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -47,6 +55,9 @@ class RecurringInvoiceDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -61,5 +72,4 @@ class RecurringInvoiceDatatable extends EntityDatatable
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -50,6 +58,9 @@ class TaskDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -92,6 +103,11 @@ class TaskDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $model
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getStatusLabel($model)
|
private function getStatusLabel($model)
|
||||||
{
|
{
|
||||||
if ($model->invoice_number) {
|
if ($model->invoice_number) {
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -24,6 +32,9 @@ class TaxRateDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -24,6 +32,9 @@ class TokenDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -42,6 +50,9 @@ class UserDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -66,6 +77,11 @@ class UserDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $state
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getStatusLabel($state)
|
private function getStatusLabel($state)
|
||||||
{
|
{
|
||||||
$label = trans("texts.{$state}");
|
$label = trans("texts.{$state}");
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
<?php namespace App\Ninja\Datatables;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -44,6 +52,9 @@ class VendorDatatable extends EntityDatatable
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function actions()
|
public function actions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -74,6 +85,4 @@ class VendorDatatable extends EntityDatatable
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php namespace App\Ninja\Mailers;
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php namespace App\Ninja\Mailers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Mailers;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Mail;
|
use Mail;
|
||||||
use App\Models\Invoice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Mailer
|
* Class Mailer
|
||||||
@ -96,6 +97,7 @@ class Mailer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $exception
|
* @param $exception
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function handleFailure($exception)
|
private function handleFailure($exception)
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
<?php namespace App\Ninja\Mailers;
|
<?php
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AuthorizeNetAIMPaymentDriver
|
||||||
|
*/
|
||||||
class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
|
class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $transactionReferenceParam = 'refId';
|
protected $transactionReferenceParam = 'refId';
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
use App\Models\AccountGateway;
|
||||||
|
use App\Models\Invitation;
|
||||||
use URL;
|
use URL;
|
||||||
use Session;
|
use Session;
|
||||||
use Request;
|
use Request;
|
||||||
@ -13,26 +17,59 @@ 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 = false,
|
||||||
|
Invitation $invitation = false,
|
||||||
|
$gatewayType = false
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->accountGateway = $accountGateway;
|
$this->accountGateway = $accountGateway;
|
||||||
$this->invitation = $invitation;
|
$this->invitation = $invitation;
|
||||||
@ -54,6 +91,9 @@ class BasePaymentDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function gatewayTypes()
|
public function gatewayTypes()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -66,44 +106,74 @@ 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 = false, $sourceId = false)
|
||||||
{
|
{
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->sourceId = $sourceId;
|
$this->sourceId = $sourceId;
|
||||||
@ -150,7 +220,11 @@ 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);
|
||||||
@ -162,7 +236,11 @@ 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());
|
||||||
@ -174,6 +252,9 @@ class BasePaymentDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
$rules = [];
|
$rules = [];
|
||||||
@ -209,6 +290,9 @@ class BasePaymentDriver
|
|||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
protected function gateway()
|
protected function gateway()
|
||||||
{
|
{
|
||||||
if ($this->gateway) {
|
if ($this->gateway) {
|
||||||
@ -221,7 +305,14 @@ 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 = false)
|
||||||
{
|
{
|
||||||
$this->input = count($input) ? $input : false;
|
$this->input = count($input) ? $input : false;
|
||||||
$gateway = $this->gateway();
|
$gateway = $this->gateway();
|
||||||
@ -315,7 +406,12 @@ class BasePaymentDriver
|
|||||||
$client->save();
|
$client->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function paymentDetails($paymentMethod = false)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||||
{
|
{
|
||||||
$invoice = $this->invoice();
|
$invoice = $this->invoice();
|
||||||
$completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType);
|
$completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType);
|
||||||
@ -345,9 +441,13 @@ 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 = [
|
||||||
@ -388,9 +488,11 @@ 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();
|
||||||
|
|
||||||
@ -416,6 +518,9 @@ class BasePaymentDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
protected function shouldCreateToken()
|
protected function shouldCreateToken()
|
||||||
{
|
{
|
||||||
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
|
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
|
||||||
@ -433,19 +538,11 @@ class BasePaymentDriver
|
|||||||
return boolval(array_get($this->input, 'token_billing'));
|
return boolval(array_get($this->input, 'token_billing'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
protected function tokenDetails()
|
* @param bool $clientId
|
||||||
{
|
*
|
||||||
$details = [];
|
* @return null
|
||||||
|
*/
|
||||||
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) {
|
||||||
@ -467,27 +564,51 @@ 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();
|
||||||
@ -502,17 +623,6 @@ 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) {
|
||||||
@ -523,13 +633,24 @@ 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->ip = Request::ip();
|
$paymentMethod->ip = Request::ip();
|
||||||
$paymentMethod->account_gateway_token_id = $customer->id;
|
$paymentMethod->account_gateway_token_id = $customer->id;
|
||||||
@ -543,7 +664,12 @@ class BasePaymentDriver
|
|||||||
return $paymentMethod;
|
return $paymentMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function creatingPaymentMethod($paymentMethod)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return PaymentMethod
|
||||||
|
*/
|
||||||
|
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||||
{
|
{
|
||||||
return $paymentMethod;
|
return $paymentMethod;
|
||||||
}
|
}
|
||||||
@ -553,7 +679,13 @@ 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();
|
||||||
@ -640,12 +772,24 @@ class BasePaymentDriver
|
|||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function creatingPayment($payment, $paymentMethod)
|
/**
|
||||||
|
* @param Payment $payment
|
||||||
|
* @param $paymentMethod
|
||||||
|
*
|
||||||
|
* @return Payment
|
||||||
|
*/
|
||||||
|
protected function creatingPayment(Payment $payment, $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());
|
||||||
@ -677,7 +821,13 @@ 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,
|
||||||
@ -685,7 +835,14 @@ 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;
|
||||||
@ -696,6 +853,12 @@ class BasePaymentDriver
|
|||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $input
|
||||||
|
*
|
||||||
|
* @return bool|mixed
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function completeOffsitePurchase($input)
|
public function completeOffsitePurchase($input)
|
||||||
{
|
{
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
@ -717,6 +880,9 @@ class BasePaymentDriver
|
|||||||
return $this->createPayment($ref);
|
return $this->createPayment($ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function tokenLinks()
|
public function tokenLinks()
|
||||||
{
|
{
|
||||||
if ( ! $this->customer()) {
|
if ( ! $this->customer()) {
|
||||||
@ -754,6 +920,9 @@ class BasePaymentDriver
|
|||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function paymentLinks()
|
public function paymentLinks()
|
||||||
{
|
{
|
||||||
$links = [];
|
$links = [];
|
||||||
@ -772,6 +941,11 @@ class BasePaymentDriver
|
|||||||
return $links;
|
return $links;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $gatewayType
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function paymentUrl($gatewayType)
|
protected function paymentUrl($gatewayType)
|
||||||
{
|
{
|
||||||
$account = $this->account();
|
$account = $this->account();
|
||||||
@ -789,6 +963,11 @@ 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,
|
||||||
@ -821,6 +1000,11 @@ class BasePaymentDriver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $input
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
public function handleWebHook($input)
|
public function handleWebHook($input)
|
||||||
{
|
{
|
||||||
throw new Exception('Unsupported gateway');
|
throw new Exception('Unsupported gateway');
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,30 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
use App\Models\PaymentMethod;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Session;
|
use Session;
|
||||||
use Braintree\Customer;
|
use Braintree\Customer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = [
|
||||||
@ -23,30 +39,36 @@ 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 = false, $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)) {
|
||||||
@ -60,7 +82,12 @@ 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 = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails($paymentMethod);
|
$data = parent::paymentDetails($paymentMethod);
|
||||||
|
|
||||||
@ -81,6 +108,9 @@ 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()) {
|
||||||
@ -113,6 +143,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
|||||||
return parent::createToken();
|
return parent::createToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
private function customerData()
|
private function customerData()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -125,6 +158,11 @@ 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;
|
||||||
@ -132,7 +170,12 @@ 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;
|
||||||
|
|
||||||
@ -152,7 +195,13 @@ 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);
|
||||||
|
|
||||||
@ -167,7 +216,14 @@ 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;
|
||||||
@ -185,6 +241,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function createTransactionToken()
|
public function createTransactionToken()
|
||||||
{
|
{
|
||||||
return $this->gateway()
|
return $this->gateway()
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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([
|
||||||
@ -21,7 +31,12 @@ class CheckoutComPaymentDriver extends BasePaymentDriver
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function paymentDetails($paymentMethod = false)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails();
|
$data = parent::paymentDetails();
|
||||||
|
|
||||||
|
@ -1,10 +1,24 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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']);
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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();
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class EwayRapidSharedPaymentDriver
|
||||||
|
*/
|
||||||
class EwayRapidSharedPaymentDriver extends BasePaymentDriver
|
class EwayRapidSharedPaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $transactionReferenceParam = 'AccessCode';
|
protected $transactionReferenceParam = 'AccessCode';
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GoCardlessPaymentDriver
|
||||||
|
*/
|
||||||
class GoCardlessPaymentDriver extends BasePaymentDriver
|
class GoCardlessPaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $transactionReferenceParam = 'signature';
|
protected $transactionReferenceParam = 'signature';
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\PaymentDrivers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class MolliePaymentDriver
|
||||||
|
*/
|
||||||
class MolliePaymentDriver extends BasePaymentDriver
|
class MolliePaymentDriver extends BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param $input
|
||||||
|
*
|
||||||
|
* @return \App\Models\Payment|mixed
|
||||||
|
*/
|
||||||
public function completeOffsitePurchase($input)
|
public function completeOffsitePurchase($input)
|
||||||
{
|
{
|
||||||
$details = $this->paymentDetails();
|
$details = $this->paymentDetails();
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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($input)
|
public function completeOffsitePurchase($input)
|
||||||
{
|
{
|
||||||
if ($accountGateway->isGateway(GATEWAY_PAYFAST) && Request::has('pt')) {
|
if ($accountGateway->isGateway(GATEWAY_PAYFAST) && Request::has('pt')) {
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -10,7 +20,12 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function paymentDetails($paymentMethod = false)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails();
|
$data = parent::paymentDetails();
|
||||||
|
|
||||||
@ -19,7 +34,13 @@ 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'];
|
||||||
|
|
||||||
|
@ -1,7 +1,17 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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 [
|
||||||
@ -9,7 +19,12 @@ class PayPalProPaymentDriver extends BasePaymentDriver
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function paymentDetails($paymentMethod = false)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails();
|
$data = parent::paymentDetails();
|
||||||
|
|
||||||
|
@ -1,14 +1,25 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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 = [
|
||||||
@ -23,11 +34,17 @@ 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();
|
||||||
@ -39,6 +56,11 @@ 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()
|
||||||
@ -63,12 +85,20 @@ 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 = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails($paymentMethod);
|
$data = parent::paymentDetails($paymentMethod);
|
||||||
|
|
||||||
@ -93,6 +123,10 @@ 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;
|
||||||
@ -126,6 +160,11 @@ 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'];
|
||||||
@ -133,7 +172,12 @@ 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;
|
||||||
|
|
||||||
@ -175,16 +219,30 @@ 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_STATUS_COMPLETED : PAYMENT_STATUS_PENDING;
|
$payment->payment_status_id = $this->purchaseResponse['status'] == 'succeeded'
|
||||||
|
? 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);
|
||||||
|
|
||||||
@ -204,6 +262,13 @@ 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();
|
||||||
@ -246,6 +311,14 @@ 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);
|
||||||
@ -276,6 +349,13 @@ 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;
|
||||||
@ -312,6 +392,12 @@ 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');
|
||||||
|
@ -1,11 +1,24 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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
|
/**
|
||||||
public function completeOffsitePurchase($input)
|
* Calling completePurchase results in an 'invalid key' error
|
||||||
|
*
|
||||||
|
* @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']);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
<?php namespace App\Ninja\PaymentDrivers;
|
<?php
|
||||||
|
|
||||||
|
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 = [
|
||||||
@ -21,16 +30,27 @@ 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();
|
||||||
@ -45,7 +65,12 @@ class WePayPaymentDriver extends BasePaymentDriver
|
|||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function paymentDetails($paymentMethod = false)
|
/**
|
||||||
|
* @param PaymentMethod $paymentMethod
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||||
{
|
{
|
||||||
$data = parent::paymentDetails($paymentMethod);
|
$data = parent::paymentDetails($paymentMethod);
|
||||||
|
|
||||||
@ -64,6 +89,9 @@ 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);
|
||||||
@ -77,22 +105,6 @@ 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,
|
||||||
@ -103,23 +115,12 @@ class WePayPaymentDriver extends BasePaymentDriver
|
|||||||
return parent::createToken();
|
return parent::createToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
public function creatingCustomer($customer)
|
* @param PaymentMethod $paymentMethod
|
||||||
{
|
*
|
||||||
if ($gatewayResponse instanceof \Omnipay\WePay\Message\CustomCheckoutResponse) {
|
* @return PaymentMethod
|
||||||
$wepay = \Utils::setupWePay($accountGateway);
|
*/
|
||||||
$paymentMethodType = $gatewayResponse->getData()['payment_method']['type'];
|
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||||
|
|
||||||
$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;
|
||||||
|
|
||||||
@ -148,7 +149,13 @@ 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);
|
||||||
|
|
||||||
@ -166,7 +173,13 @@ 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);
|
||||||
|
|
||||||
@ -182,7 +195,7 @@ class WePayPaymentDriver extends BasePaymentDriver
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function attemptVoidPayment($response, $payment, $amount)
|
protected function attemptVoidPayment($response, Payment $payment, $amount)
|
||||||
{
|
{
|
||||||
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
|
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
|
||||||
return false;
|
return false;
|
||||||
@ -231,8 +244,6 @@ 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';
|
||||||
|
@ -1,14 +1,27 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use Request;
|
use Request;
|
||||||
@ -21,6 +23,9 @@ 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 = '')
|
||||||
@ -619,7 +624,10 @@ 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);
|
||||||
@ -662,7 +670,11 @@ 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);
|
||||||
@ -679,7 +691,12 @@ 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);
|
||||||
@ -687,7 +704,11 @@ 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();
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Auth;
|
use Auth;
|
||||||
@ -7,8 +9,20 @@ use Request;
|
|||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
@ -42,6 +56,11 @@ class ActivityRepository
|
|||||||
return $activity;
|
return $activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $entity
|
||||||
|
*
|
||||||
|
* @return Activity
|
||||||
|
*/
|
||||||
private function getBlank($entity)
|
private function getBlank($entity)
|
||||||
{
|
{
|
||||||
$activity = new Activity();
|
$activity = new Activity();
|
||||||
@ -63,6 +82,11 @@ 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')
|
||||||
|
@ -1,17 +1,30 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -26,6 +39,11 @@ class BankAccountRepository extends BaseRepository
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
public function save($input)
|
public function save($input)
|
||||||
{
|
{
|
||||||
$bankAccount = BankAccount::createNew();
|
$bankAccount = BankAccount::createNew();
|
||||||
|
@ -1,19 +1,29 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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()
|
||||||
@ -23,6 +33,12 @@ 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')
|
||||||
@ -68,7 +84,13 @@ 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;
|
||||||
|
|
||||||
@ -95,12 +117,6 @@ 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 = [];
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -1,17 +1,31 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -58,7 +72,13 @@ 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;
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -6,14 +8,22 @@ 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()
|
||||||
@ -21,6 +31,9 @@ class DocumentRepository extends BaseRepository
|
|||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
public function find()
|
public function find()
|
||||||
{
|
{
|
||||||
$accountid = \Auth::user()->account_id;
|
$accountid = \Auth::user()->account_id;
|
||||||
@ -50,6 +63,12 @@ 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'];
|
||||||
@ -177,6 +196,14 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,17 +1,26 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -36,10 +45,14 @@ 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();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Repositories;
|
||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
use Utils;
|
use Utils;
|
||||||
@ -7,21 +9,37 @@ 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()
|
||||||
@ -31,6 +49,11 @@ 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);
|
||||||
@ -40,6 +63,11 @@ 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;
|
||||||
@ -110,7 +138,13 @@ 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;
|
||||||
|
|
||||||
@ -174,6 +208,12 @@ 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();
|
||||||
@ -194,6 +234,6 @@ class ExpenseRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return count($tasks);
|
return $expenses->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -748,6 +748,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Invoice $recurInvoice
|
* @param Invoice $recurInvoice
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function createRecurringInvoice(Invoice $recurInvoice)
|
public function createRecurringInvoice(Invoice $recurInvoice)
|
||||||
@ -839,6 +840,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function findNeedingReminding(Account $account)
|
public function findNeedingReminding(Account $account)
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
@ -12,6 +22,7 @@ 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;
|
||||||
|
@ -1,18 +1,31 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -87,6 +100,12 @@ 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')
|
||||||
@ -142,7 +161,13 @@ 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;
|
||||||
|
|
||||||
@ -201,7 +226,12 @@ class PaymentRepository extends BaseRepository
|
|||||||
return $payment;
|
return $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete($payment)
|
/**
|
||||||
|
* @param Payment $payment
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete(Payment $payment)
|
||||||
{
|
{
|
||||||
if ($payment->invoice->is_deleted) {
|
if ($payment->invoice->is_deleted) {
|
||||||
return false;
|
return false;
|
||||||
@ -210,7 +240,12 @@ class PaymentRepository extends BaseRepository
|
|||||||
parent::delete($payment);
|
parent::delete($payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function restore($payment)
|
/**
|
||||||
|
* @param Payment $payment
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function restore(Payment $payment)
|
||||||
{
|
{
|
||||||
if ($payment->invoice->is_deleted) {
|
if ($payment->invoice->is_deleted) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,18 +1,27 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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');
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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()
|
||||||
@ -17,6 +28,11 @@ 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')
|
||||||
@ -37,7 +53,13 @@ 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;
|
||||||
|
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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();
|
||||||
|
@ -1,12 +1,23 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -62,7 +73,14 @@ 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
|
||||||
@ -109,6 +127,12 @@ 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();
|
||||||
|
@ -1,16 +1,28 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -19,7 +31,13 @@ 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
|
||||||
@ -35,41 +53,4 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,29 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
|
@ -1,16 +1,29 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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')
|
||||||
@ -25,7 +38,13 @@ 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();
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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 {
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
<?php namespace App\Ninja\Repositories;
|
<?php
|
||||||
|
|
||||||
|
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()
|
||||||
@ -20,6 +30,11 @@ 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')
|
||||||
@ -60,7 +75,13 @@ 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;
|
||||||
|
|
||||||
@ -75,15 +96,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,4 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
class ClientPolicy extends EntityPolicy {}
|
/**
|
||||||
|
* Class ClientPolicy
|
||||||
|
*/
|
||||||
|
class ClientPolicy extends EntityPolicy
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -2,4 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
class CreditPolicy extends EntityPolicy {}
|
/**
|
||||||
|
* Class CreditPolicy
|
||||||
|
*/
|
||||||
|
class CreditPolicy extends EntityPolicy
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Policies;
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use App\Models\Document;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,6 +12,7 @@ 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)
|
||||||
@ -21,9 +23,10 @@ class DocumentPolicy extends EntityPolicy
|
|||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param Document $document
|
* @param Document $document
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function view(User $user, $document)
|
public static function view(User $user, Document $document)
|
||||||
{
|
{
|
||||||
if ($user->hasPermission('view_all')) {
|
if ($user->hasPermission('view_all')) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -4,6 +4,9 @@ namespace App\Policies;
|
|||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExpensePolicy
|
||||||
|
*/
|
||||||
class ExpensePolicy extends EntityPolicy
|
class ExpensePolicy extends EntityPolicy
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user