mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
Merge pull request #979 from codedge/Refactoring-docblocks-dead-code-unused-uses
Refactor docblocks, unused vars, unused uses
This commit is contained in:
commit
7b4b84cedd
@ -1,5 +1,10 @@
|
||||
<?php namespace App\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
/**
|
||||
* Class Command
|
||||
*/
|
||||
abstract class Command
|
||||
{
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
@ -39,6 +41,7 @@ class ChargeRenewalInvoices extends Command
|
||||
|
||||
/**
|
||||
* ChargeRenewalInvoices constructor.
|
||||
*
|
||||
* @param Mailer $mailer
|
||||
* @param AccountRepository $repo
|
||||
* @param PaymentService $paymentService
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Carbon;
|
||||
@ -174,7 +176,6 @@ class CheckData extends Command {
|
||||
|
||||
foreach ($clients as $client) {
|
||||
$this->info("=== Client:{$client->id} Balance:{$client->balance} Actual Balance:{$client->actual_balance} ===");
|
||||
$foundProblem = false;
|
||||
$lastBalance = 0;
|
||||
$lastAdjustment = 0;
|
||||
$lastCreatedAt = null;
|
||||
@ -182,8 +183,16 @@ class CheckData extends Command {
|
||||
$activities = DB::table('activities')
|
||||
->where('client_id', '=', $client->id)
|
||||
->orderBy('activities.id')
|
||||
->get(['activities.id', 'activities.created_at', 'activities.activity_type_id', 'activities.adjustment', 'activities.balance', 'activities.invoice_id']);
|
||||
//$this->info(var_dump($activities));
|
||||
->get(
|
||||
[
|
||||
'activities.id',
|
||||
'activities.created_at',
|
||||
'activities.activity_type_id',
|
||||
'activities.adjustment',
|
||||
'activities.balance',
|
||||
'activities.invoice_id'
|
||||
]
|
||||
);
|
||||
|
||||
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**
|
||||
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}");
|
||||
$foundProblem = true;
|
||||
$clientFix += $invoice->amount;
|
||||
$activityFix = $invoice->amount;
|
||||
// **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)) {
|
||||
$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;
|
||||
$activityFix = 0;
|
||||
}
|
||||
@ -245,7 +252,6 @@ class CheckData extends Command {
|
||||
// **Fix for updating balance when deleting a recurring invoice**
|
||||
if ($activity->adjustment != 0 && $invoice->is_recurring) {
|
||||
$this->info("Incorrect adjustment for deleted invoice adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
if ($activity->balance != $lastBalance) {
|
||||
$clientFix -= $activity->adjustment;
|
||||
}
|
||||
@ -255,7 +261,6 @@ class CheckData extends Command {
|
||||
// **Fix for updating balance when archiving an invoice**
|
||||
if ($activity->adjustment != 0 && !$invoice->is_recurring) {
|
||||
$this->info("Incorrect adjustment for archiving invoice adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$activityFix = 0;
|
||||
$clientFix += $activity->adjustment;
|
||||
}
|
||||
@ -263,12 +268,10 @@ class CheckData extends Command {
|
||||
// **Fix for updating balance when updating recurring invoice**
|
||||
if ($activity->adjustment != 0 && $invoice->is_recurring) {
|
||||
$this->info("Incorrect adjustment for updated recurring invoice adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$clientFix -= $activity->adjustment;
|
||||
$activityFix = 0;
|
||||
} 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}");
|
||||
$foundProblem = true;
|
||||
$clientFix -= $activity->adjustment;
|
||||
$activityFix = 0;
|
||||
}
|
||||
@ -276,7 +279,6 @@ class CheckData extends Command {
|
||||
// **Fix for updating balance when updating a quote**
|
||||
if ($activity->balance != $lastBalance) {
|
||||
$this->info("Incorrect adjustment for updated quote adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$clientFix += $lastBalance - $activity->balance;
|
||||
$activityFix = 0;
|
||||
}
|
||||
@ -284,7 +286,6 @@ class CheckData extends Command {
|
||||
// **Fix for deleting payment after deleting invoice**
|
||||
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
|
||||
$this->info("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$activityFix = 0;
|
||||
$clientFix -= $activity->adjustment;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Auth;
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
@ -32,6 +35,7 @@ class CreateTestData extends Command
|
||||
|
||||
/**
|
||||
* CreateTestData constructor.
|
||||
*
|
||||
* @param ClientRepository $clientRepo
|
||||
* @param InvoiceRepository $invoiceRepo
|
||||
* @param PaymentRepository $paymentRepo
|
||||
@ -126,9 +130,9 @@ class CreateTestData extends Command
|
||||
|
||||
/**
|
||||
* @param $client
|
||||
* @param $invoice
|
||||
* @param Invoice $invoice
|
||||
*/
|
||||
private function createPayment($client, $invoice)
|
||||
private function createPayment($client, Invoice $invoice)
|
||||
{
|
||||
$data = [
|
||||
'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++) {
|
||||
$data = [
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace InvoiceNinja\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace InvoiceNinja\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
@ -6,30 +8,30 @@ use Illuminate\Foundation\Inspiring;
|
||||
/**
|
||||
* Class Inspire
|
||||
*/
|
||||
class Inspire extends Command {
|
||||
class Inspire extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
/**
|
||||
* 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 Illuminate\Console\Command;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DateTime;
|
||||
use App\Models\Document;
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
@ -9,7 +10,6 @@ use Illuminate\Console\Command;
|
||||
*/
|
||||
class ResetData extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\BankAccountService;
|
||||
|
@ -16,17 +16,17 @@ use Illuminate\Validation\ValidationException;
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
AuthorizationException::class,
|
||||
HttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
ValidationException::class,
|
||||
];
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
@ -36,14 +36,14 @@ class Handler extends ExceptionHandler
|
||||
* @param \Exception $e
|
||||
* @return bool|void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
public function report(Exception $e)
|
||||
{
|
||||
// don't show these errors in the logs
|
||||
if ($e instanceof HttpResponseException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Utils::isNinja() && ! Utils::isTravis()) {
|
||||
|
||||
if (Utils::isNinja() && !Utils::isTravis()) {
|
||||
Utils::logError(Utils::getErrorString($e));
|
||||
return false;
|
||||
} else {
|
||||
@ -51,15 +51,16 @@ class Handler extends ExceptionHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof ModelNotFoundException) {
|
||||
return Redirect::to('/');
|
||||
} elseif ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
@ -67,26 +68,27 @@ class Handler extends ExceptionHandler
|
||||
if ($request->path() != 'get_started') {
|
||||
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
||||
return redirect()
|
||||
->back()
|
||||
->withInput($request->except('password', '_token'))
|
||||
->with([
|
||||
'warning' => trans('texts.token_expired')
|
||||
]);
|
||||
->back()
|
||||
->withInput($request->except('password', '_token'))
|
||||
->with([
|
||||
'warning' => trans('texts.token_expired')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// In production, except for maintenance mode, we'll show a custom error screen
|
||||
if (Utils::isNinjaProd()
|
||||
&& !Utils::isDownForMaintenance()
|
||||
&& !($e instanceof HttpResponseException)) {
|
||||
&& !($e instanceof HttpResponseException)
|
||||
) {
|
||||
$data = [
|
||||
'error' => get_class($e),
|
||||
'hideHeader' => true,
|
||||
];
|
||||
|
||||
|
||||
return response()->view('error', $data);
|
||||
} else {
|
||||
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\ContactMailer;
|
||||
|
||||
class InvoiceEventHandler
|
||||
{
|
||||
protected $userMailer;
|
||||
protected $contactMailer;
|
||||
/**
|
||||
* @var UserMailer
|
||||
*/
|
||||
protected $userMailer;
|
||||
|
||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
}
|
||||
/**
|
||||
* @var ContactMailer
|
||||
*/
|
||||
protected $contactMailer;
|
||||
|
||||
public function subscribe($events)
|
||||
{
|
||||
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
||||
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
||||
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
||||
}
|
||||
/**
|
||||
* InvoiceEventHandler constructor.
|
||||
*
|
||||
* @param UserMailer $userMailer
|
||||
* @param ContactMailer $contactMailer
|
||||
*/
|
||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
}
|
||||
|
||||
public function onSent($invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'sent');
|
||||
}
|
||||
/**
|
||||
* @param $events
|
||||
*/
|
||||
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)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'viewed');
|
||||
}
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
*/
|
||||
public function onSent(Invoice $invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'sent');
|
||||
}
|
||||
|
||||
public function onPaid($payment)
|
||||
{
|
||||
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||
/**
|
||||
* @param Invoice $invoice
|
||||
*/
|
||||
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)
|
||||
{
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_' . $type})
|
||||
{
|
||||
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,20 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use URL;
|
||||
use App\Models\AccountGateway;
|
||||
|
||||
/**
|
||||
* Class AccountGatewayDatatable
|
||||
*/
|
||||
class AccountGatewayDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_ACCOUNT_GATEWAY;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -48,6 +56,9 @@ class AccountGatewayDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
|
@ -1,11 +1,19 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* Class ActivityDatatable
|
||||
*/
|
||||
class ActivityDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_ACTIVITY;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
|
@ -1,11 +1,19 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use URL;
|
||||
|
||||
/**
|
||||
* Class BankAccountDatatable
|
||||
*/
|
||||
class BankAccountDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_BANK_ACCOUNT;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -17,13 +25,16 @@ class BankAccountDatatable extends EntityDatatable
|
||||
],
|
||||
[
|
||||
'bank_library_id',
|
||||
function ($model) {
|
||||
function () {
|
||||
return 'OFX';
|
||||
}
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
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 URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class ClientDatatable
|
||||
*/
|
||||
class ClientDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_CLIENT;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -50,6 +58,9 @@ class ClientDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
@ -74,7 +85,7 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("tasks/create/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_TASK);
|
||||
}
|
||||
],
|
||||
@ -83,7 +94,7 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("invoices/create/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||
}
|
||||
],
|
||||
@ -92,13 +103,13 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("quotes/create/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->hasFeature(FEATURE_QUOTES) && Auth::user()->can('create', ENTITY_INVOICE);
|
||||
}
|
||||
],
|
||||
[
|
||||
'--divider--', function(){return false;},
|
||||
function ($model) {
|
||||
function () {
|
||||
$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));
|
||||
}
|
||||
@ -108,7 +119,7 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("payments/create/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_PAYMENT);
|
||||
}
|
||||
],
|
||||
@ -117,7 +128,7 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("credits/create/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_CREDIT);
|
||||
}
|
||||
],
|
||||
@ -126,7 +137,7 @@ class ClientDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("expenses/create/0/{$model->public_id}");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_EXPENSE);
|
||||
}
|
||||
]
|
||||
|
@ -1,13 +1,21 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class CreditDatatable
|
||||
*/
|
||||
class CreditDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_CREDIT;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -49,6 +57,9 @@ class CreditDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
@ -57,7 +68,7 @@ class CreditDatatable extends EntityDatatable
|
||||
function ($model) {
|
||||
return URL::to("payments/create/{$model->client_public_id}") . '?paymentTypeId=1';
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
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
|
||||
{
|
||||
public $entityType;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $isBulkEdit;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $hideClient;
|
||||
|
||||
/**
|
||||
* EntityDatatable constructor.
|
||||
*
|
||||
* @param bool $isBulkEdit
|
||||
* @param bool $hideClient
|
||||
*/
|
||||
public function __construct($isBulkEdit = true, $hideClient = false)
|
||||
{
|
||||
$this->isBulkEdit = $isBulkEdit;
|
||||
$this->hideClient = $hideClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [];
|
||||
|
@ -1,13 +1,20 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class ExpenseCategoryDatatable
|
||||
*/
|
||||
class ExpenseCategoryDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_EXPENSE_CATEGORY;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -25,6 +32,9 @@ class ExpenseCategoryDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
|
@ -1,13 +1,21 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class ExpenseDatatable
|
||||
*/
|
||||
class ExpenseDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_EXPENSE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -87,6 +95,9 @@ class ExpenseDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
@ -120,7 +131,13 @@ class ExpenseDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $invoiceId
|
||||
* @param $shouldBeInvoiced
|
||||
* @param $balance
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getStatusLabel($invoiceId, $shouldBeInvoiced, $balance)
|
||||
{
|
||||
if ($invoiceId) {
|
||||
@ -141,5 +158,4 @@ class ExpenseDatatable extends EntityDatatable
|
||||
|
||||
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 URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class InvoiceDatatable
|
||||
*/
|
||||
class InvoiceDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_INVOICE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
$entityType = $this->entityType;
|
||||
@ -72,6 +80,9 @@ class InvoiceDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
$entityType = $this->entityType;
|
||||
@ -91,7 +102,7 @@ class InvoiceDatatable extends EntityDatatable
|
||||
function ($model) use ($entityType) {
|
||||
return URL::to("{$entityType}s/{$model->public_id}/clone");
|
||||
},
|
||||
function ($model) {
|
||||
function () {
|
||||
return Auth::user()->can('create', ENTITY_INVOICE);
|
||||
}
|
||||
],
|
||||
@ -155,6 +166,11 @@ class InvoiceDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getStatusLabel($model)
|
||||
{
|
||||
$entityType = $this->entityType;
|
||||
@ -189,5 +205,4 @@ class InvoiceDatatable extends EntityDatatable
|
||||
|
||||
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 URL;
|
||||
use Auth;
|
||||
use App\Models\PaymentMethod;
|
||||
|
||||
/**
|
||||
* Class PaymentDatatable
|
||||
*/
|
||||
class PaymentDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_PAYMENT;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $refundableGateways = [
|
||||
GATEWAY_STRIPE,
|
||||
GATEWAY_BRAINTREE,
|
||||
GATEWAY_WEPAY,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -101,7 +113,9 @@ class PaymentDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
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));
|
||||
$class = 'default';
|
||||
|
@ -1,14 +1,22 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
use Str;
|
||||
|
||||
/**
|
||||
* Class ProductDatatable
|
||||
*/
|
||||
class ProductDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_PRODUCT;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -40,6 +48,9 @@ class ProductDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
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 URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class RecurringInvoiceDatatable
|
||||
*/
|
||||
class RecurringInvoiceDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_RECURRING_INVOICE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -47,6 +55,9 @@ class RecurringInvoiceDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
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 URL;
|
||||
use Auth;
|
||||
use App\Models\Task;
|
||||
|
||||
/**
|
||||
* Class TaskDatatable
|
||||
*/
|
||||
class TaskDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_TASK;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -50,6 +58,9 @@ class TaskDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
@ -92,6 +103,11 @@ class TaskDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getStatusLabel($model)
|
||||
{
|
||||
if ($model->invoice_number) {
|
||||
|
@ -1,11 +1,19 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use URL;
|
||||
|
||||
/**
|
||||
* Class TaxRateDatatable
|
||||
*/
|
||||
class TaxRateDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_TAX_RATE;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -24,6 +32,9 @@ class TaxRateDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
|
@ -1,11 +1,19 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use URL;
|
||||
|
||||
/**
|
||||
* Class TokenDatatable
|
||||
*/
|
||||
class TokenDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_TOKEN;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -24,6 +32,9 @@ class TokenDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
|
@ -1,11 +1,19 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use URL;
|
||||
|
||||
/**
|
||||
* Class UserDatatable
|
||||
*/
|
||||
class UserDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_USER;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -42,6 +50,9 @@ class UserDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
@ -66,6 +77,11 @@ class UserDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $state
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getStatusLabel($state)
|
||||
{
|
||||
$label = trans("texts.{$state}");
|
||||
|
@ -1,13 +1,21 @@
|
||||
<?php namespace App\Ninja\Datatables;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Datatables;
|
||||
|
||||
use Utils;
|
||||
use URL;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
* Class VendorDatatable
|
||||
*/
|
||||
class VendorDatatable extends EntityDatatable
|
||||
{
|
||||
public $entityType = ENTITY_VENDOR;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function columns()
|
||||
{
|
||||
return [
|
||||
@ -44,6 +52,9 @@ class VendorDatatable extends EntityDatatable
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
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 Utils;
|
||||
use Event;
|
||||
use Auth;
|
||||
use App\Services\TemplateService;
|
||||
use App\Models\Invoice;
|
||||
|
@ -1,8 +1,9 @@
|
||||
<?php namespace App\Ninja\Mailers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Mailers;
|
||||
|
||||
use Exception;
|
||||
use Mail;
|
||||
use App\Models\Invoice;
|
||||
|
||||
/**
|
||||
* Class Mailer
|
||||
@ -96,6 +97,7 @@ class Mailer
|
||||
|
||||
/**
|
||||
* @param $exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
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\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class UserMailer
|
||||
*/
|
||||
class UserMailer extends Mailer
|
||||
{
|
||||
/**
|
||||
|
@ -1,6 +1,14 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class AuthorizeNetAIMPaymentDriver
|
||||
*/
|
||||
class AuthorizeNetAIMPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
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 Session;
|
||||
use Request;
|
||||
@ -13,26 +17,59 @@ use App\Models\Payment;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Country;
|
||||
|
||||
/**
|
||||
* Class BasePaymentDriver
|
||||
*/
|
||||
class BasePaymentDriver
|
||||
{
|
||||
public $invitation;
|
||||
|
||||
/**
|
||||
* @var AccountGateway
|
||||
*/
|
||||
public $accountGateway;
|
||||
|
||||
protected $gatewayType;
|
||||
protected $gateway;
|
||||
protected $customer;
|
||||
protected $sourceId;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $input;
|
||||
|
||||
protected $customerResponse;
|
||||
protected $tokenResponse;
|
||||
protected $purchaseResponse;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sourceReferenceParam = 'token';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $customerReferenceParam;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
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->invitation = $invitation;
|
||||
@ -54,6 +91,9 @@ class BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [
|
||||
@ -66,44 +106,74 @@ class BasePaymentDriver
|
||||
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()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// set payment method as pending until confirmed
|
||||
/**
|
||||
* Set payment method as pending until confirmed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTwoStep()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function providerName()
|
||||
{
|
||||
return strtolower($this->accountGateway->gateway->provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function invoice()
|
||||
{
|
||||
return $this->invitation->invoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function contact()
|
||||
{
|
||||
return $this->invitation->contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function client()
|
||||
{
|
||||
return $this->invoice()->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function 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->sourceId = $sourceId;
|
||||
@ -150,7 +220,11 @@ class BasePaymentDriver
|
||||
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()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$file = sprintf('%s/views/payments/%s/partial.blade.php', resource_path(), $this->providerName());
|
||||
@ -174,6 +252,9 @@ class BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = [];
|
||||
@ -209,6 +290,9 @@ class BasePaymentDriver
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function gateway()
|
||||
{
|
||||
if ($this->gateway) {
|
||||
@ -221,7 +305,14 @@ class BasePaymentDriver
|
||||
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;
|
||||
$gateway = $this->gateway();
|
||||
@ -315,7 +406,12 @@ class BasePaymentDriver
|
||||
$client->save();
|
||||
}
|
||||
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||
{
|
||||
$invoice = $this->invoice();
|
||||
$completeUrl = url('complete/' . $this->invitation->invitation_key . '/' . $this->gatewayType);
|
||||
@ -345,9 +441,13 @@ class BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function paymentDetailsFromInput($input)
|
||||
/**
|
||||
* @param array $input
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function paymentDetailsFromInput(array $input)
|
||||
{
|
||||
$invoice = $this->invoice();
|
||||
$client = $this->client();
|
||||
|
||||
$data = [
|
||||
@ -388,9 +488,11 @@ class BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function paymentDetailsFromClient()
|
||||
{
|
||||
$invoice = $this->invoice();
|
||||
$client = $this->client();
|
||||
$contact = $this->invitation->contact ?: $client->contacts()->first();
|
||||
|
||||
@ -416,6 +518,9 @@ class BasePaymentDriver
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function shouldCreateToken()
|
||||
{
|
||||
if ($this->isGatewayType(GATEWAY_TYPE_BANK_TRANSFER)) {
|
||||
@ -433,19 +538,11 @@ class BasePaymentDriver
|
||||
return boolval(array_get($this->input, 'token_billing'));
|
||||
}
|
||||
|
||||
/*
|
||||
protected function tokenDetails()
|
||||
{
|
||||
$details = [];
|
||||
|
||||
if ($customer = $this->customer()) {
|
||||
$details['customerReference'] = $customer->token;
|
||||
}
|
||||
|
||||
return $details;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param bool $clientId
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function customer($clientId = false)
|
||||
{
|
||||
if ($this->customer) {
|
||||
@ -467,27 +564,51 @@ class BasePaymentDriver
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $client
|
||||
* @param $publicId
|
||||
* @param $amount1
|
||||
* @param $amount2
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function verifyBankAccount($client, $publicId, $amount1, $amount2)
|
||||
{
|
||||
throw new Exception('verifyBankAccount not implemented');
|
||||
}
|
||||
|
||||
public function removePaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removePaymentMethod(PaymentMethod $paymentMethod)
|
||||
{
|
||||
$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()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentMethod
|
||||
*/
|
||||
public function createToken()
|
||||
{
|
||||
$account = $this->account();
|
||||
@ -502,17 +623,6 @@ class BasePaymentDriver
|
||||
$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);
|
||||
|
||||
if ($paymentMethod && ! $customer->default_payment_method_id) {
|
||||
@ -523,13 +633,24 @@ class BasePaymentDriver
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function creatingCustomer($customer)
|
||||
{
|
||||
return $customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return PaymentMethod
|
||||
*/
|
||||
public function createPaymentMethod($customer)
|
||||
{
|
||||
/** @var PaymentMethod $paymentMethod */
|
||||
$paymentMethod = PaymentMethod::createNew($this->invitation);
|
||||
$paymentMethod->contact_id = $this->contact()->id;
|
||||
$paymentMethod->ip = Request::ip();
|
||||
@ -544,7 +665,12 @@ class BasePaymentDriver
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
protected function creatingPaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return PaymentMethod
|
||||
*/
|
||||
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||
{
|
||||
return $paymentMethod;
|
||||
}
|
||||
@ -554,7 +680,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;
|
||||
$invoice = $this->invoice();
|
||||
@ -641,12 +773,24 @@ class BasePaymentDriver
|
||||
return $payment;
|
||||
}
|
||||
|
||||
protected function creatingPayment($payment, $paymentMethod)
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param $paymentMethod
|
||||
*
|
||||
* @return Payment
|
||||
*/
|
||||
protected function creatingPayment(Payment $payment, $paymentMethod)
|
||||
{
|
||||
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) {
|
||||
$amount = min($amount, $payment->getCompletedAmount());
|
||||
@ -678,7 +822,13 @@ class BasePaymentDriver
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function refundDetails($payment, $amount)
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param $amount
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function refundDetails(Payment $payment, $amount)
|
||||
{
|
||||
return [
|
||||
'amount' => $amount,
|
||||
@ -686,7 +836,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
|
||||
return $amount == $payment->amount;
|
||||
@ -697,6 +854,12 @@ class BasePaymentDriver
|
||||
return $payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
*
|
||||
* @return bool|mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function completeOffsitePurchase($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
@ -730,6 +893,9 @@ class BasePaymentDriver
|
||||
return $this->createPayment($ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function tokenLinks()
|
||||
{
|
||||
if ( ! $this->customer()) {
|
||||
@ -767,6 +933,9 @@ class BasePaymentDriver
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function paymentLinks()
|
||||
{
|
||||
$links = [];
|
||||
@ -785,6 +954,11 @@ class BasePaymentDriver
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $gatewayType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function paymentUrl($gatewayType)
|
||||
{
|
||||
$account = $this->account();
|
||||
@ -802,6 +976,11 @@ class BasePaymentDriver
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cardName
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function parseCardType($cardName) {
|
||||
$cardTypes = [
|
||||
'visa' => PAYMENT_TYPE_VISA,
|
||||
@ -834,6 +1013,11 @@ class BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handleWebHook($input)
|
||||
{
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [
|
||||
GATEWAY_TYPE_BITCOIN
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,30 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use Exception;
|
||||
use Session;
|
||||
use Braintree\Customer;
|
||||
|
||||
/**
|
||||
* Class BraintreePaymentDriver
|
||||
*/
|
||||
class BraintreePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $customerReferenceParam = 'customerId';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sourceReferenceParam = 'paymentMethodToken';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
$types = [
|
||||
@ -23,30 +39,36 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function tokenize()
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
if ( ! parent::checkCustomerExists($customer)) {
|
||||
@ -60,7 +82,12 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return ($customer instanceof Customer);
|
||||
}
|
||||
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||
{
|
||||
$data = parent::paymentDetails($paymentMethod);
|
||||
|
||||
@ -81,6 +108,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentMethod|bool
|
||||
*/
|
||||
public function createToken()
|
||||
{
|
||||
if ($customer = $this->customer()) {
|
||||
@ -113,6 +143,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return parent::createToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function customerData()
|
||||
{
|
||||
return [
|
||||
@ -125,6 +158,11 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function creatingCustomer($customer)
|
||||
{
|
||||
$customer->token = $this->tokenResponse->customerId;
|
||||
@ -132,7 +170,12 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return $customer;
|
||||
}
|
||||
|
||||
protected function creatingPaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return PaymentMethod|null
|
||||
*/
|
||||
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||
{
|
||||
$response = $this->tokenResponse;
|
||||
|
||||
@ -152,7 +195,13 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
public function removePaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removePaymentMethod(PaymentMethod $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)) {
|
||||
return false;
|
||||
@ -185,6 +241,9 @@ class BraintreePaymentDriver extends BasePaymentDriver
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function createTransactionToken()
|
||||
{
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function createTransactionToken()
|
||||
{
|
||||
$response = $this->gateway()->purchase([
|
||||
@ -21,7 +31,12 @@ class CheckoutComPaymentDriver extends BasePaymentDriver
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||
{
|
||||
$data = parent::paymentDetails();
|
||||
|
||||
|
@ -1,10 +1,24 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class CybersourcePaymentDriver
|
||||
*/
|
||||
class CybersourcePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
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') {
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [GATEWAY_TYPE_DWOLLA];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function gateway()
|
||||
{
|
||||
$gateway = parent::gateway();
|
||||
|
@ -1,6 +1,14 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class EwayRapidSharedPaymentDriver
|
||||
*/
|
||||
class EwayRapidSharedPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $transactionReferenceParam = 'AccessCode';
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class GoCardlessPaymentDriver
|
||||
*/
|
||||
class GoCardlessPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $transactionReferenceParam = 'signature';
|
||||
}
|
||||
|
@ -1,7 +1,17 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class MolliePaymentDriver
|
||||
*/
|
||||
class MolliePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @param $input
|
||||
*
|
||||
* @return \App\Models\Payment|mixed
|
||||
*/
|
||||
public function completeOffsitePurchase($input)
|
||||
{
|
||||
$details = $this->paymentDetails();
|
||||
|
@ -1,9 +1,17 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
/**
|
||||
* Class PayFastPaymentDriver
|
||||
*/
|
||||
class PayFastPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $transactionReferenceParam = 'm_payment_id';
|
||||
|
||||
|
||||
public function completeOffsitePurchase($input)
|
||||
{
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
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();
|
||||
|
||||
@ -19,7 +34,13 @@ class PayPalExpressPaymentDriver extends BasePaymentDriver
|
||||
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'];
|
||||
|
||||
|
@ -1,7 +1,17 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
|
||||
/**
|
||||
* Class PayPalProPaymentDriver
|
||||
*/
|
||||
class PayPalProPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -1,14 +1,25 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
use Exception;
|
||||
use Cache;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentMethod;
|
||||
|
||||
/**
|
||||
* Class StripePaymentDriver
|
||||
*/
|
||||
class StripePaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $customerReferenceParam = 'customerReference';
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
$types = [
|
||||
@ -23,11 +34,17 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function tokenize()
|
||||
{
|
||||
return $this->accountGateway->getPublishableStripeKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = parent::rules();
|
||||
@ -39,6 +56,11 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
$response = $this->gateway()
|
||||
@ -63,12 +85,20 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isTwoStep()
|
||||
{
|
||||
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);
|
||||
|
||||
@ -93,6 +123,10 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentMethod
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createToken()
|
||||
{
|
||||
$invoice = $this->invitation->invoice;
|
||||
@ -126,6 +160,11 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function creatingCustomer($customer)
|
||||
{
|
||||
$customer->token = $this->tokenResponse['id'];
|
||||
@ -133,7 +172,12 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $customer;
|
||||
}
|
||||
|
||||
protected function creatingPaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return PaymentMethod|bool
|
||||
*/
|
||||
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||
{
|
||||
$data = $this->tokenResponse;
|
||||
|
||||
@ -175,16 +219,30 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
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)) {
|
||||
$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;
|
||||
}
|
||||
|
||||
public function removePaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removePaymentMethod(PaymentMethod $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)
|
||||
{
|
||||
$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)
|
||||
{
|
||||
$customer = $this->customer($client->id);
|
||||
@ -276,6 +349,13 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @param $url
|
||||
* @param null $body
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function makeStripeCall($method, $url, $body = null)
|
||||
{
|
||||
$apiKey = $this->accountGateway->getConfig()->apiKey;
|
||||
@ -312,6 +392,12 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
*
|
||||
* @return array|string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handleWebHook($input)
|
||||
{
|
||||
$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
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
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']);
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
<?php namespace App\Ninja\PaymentDrivers;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\PaymentDrivers;
|
||||
|
||||
use App\Models\PaymentMethod;
|
||||
use Session;
|
||||
use Utils;
|
||||
use App\Models\Payment;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class WePayPaymentDriver
|
||||
*/
|
||||
class WePayPaymentDriver extends BasePaymentDriver
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
$types = [
|
||||
@ -21,16 +30,27 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function tokenize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customer
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$rules = parent::rules();
|
||||
@ -45,7 +65,12 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return $rules;
|
||||
}
|
||||
|
||||
protected function paymentDetails($paymentMethod = false)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function paymentDetails(PaymentMethod $paymentMethod = false)
|
||||
{
|
||||
$data = parent::paymentDetails($paymentMethod);
|
||||
|
||||
@ -64,6 +89,9 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentMethod
|
||||
*/
|
||||
public function createToken()
|
||||
{
|
||||
$wepay = Utils::setupWePay($this->accountGateway);
|
||||
@ -77,22 +105,6 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
'payment_bank_id' => $token,
|
||||
]);
|
||||
} 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', [
|
||||
'client_id' => WEPAY_CLIENT_ID,
|
||||
'client_secret' => WEPAY_CLIENT_SECRET,
|
||||
@ -103,23 +115,12 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return parent::createToken();
|
||||
}
|
||||
|
||||
/*
|
||||
public function creatingCustomer($customer)
|
||||
{
|
||||
if ($gatewayResponse instanceof \Omnipay\WePay\Message\CustomCheckoutResponse) {
|
||||
$wepay = \Utils::setupWePay($accountGateway);
|
||||
$paymentMethodType = $gatewayResponse->getData()['payment_method']['type'];
|
||||
|
||||
$gatewayResponse = $wepay->request($paymentMethodType, array(
|
||||
'client_id' => WEPAY_CLIENT_ID,
|
||||
'client_secret' => WEPAY_CLIENT_SECRET,
|
||||
$paymentMethodType.'_id' => $gatewayResponse->getData()['payment_method'][$paymentMethodType]['id'],
|
||||
));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
protected function creatingPaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return PaymentMethod
|
||||
*/
|
||||
protected function creatingPaymentMethod(PaymentMethod $paymentMethod)
|
||||
{
|
||||
$source = $this->tokenResponse;
|
||||
|
||||
@ -148,7 +149,13 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return $paymentMethod;
|
||||
}
|
||||
|
||||
public function removePaymentMethod($paymentMethod)
|
||||
/**
|
||||
* @param PaymentMethod $paymentMethod
|
||||
*
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function removePaymentMethod(PaymentMethod $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);
|
||||
|
||||
@ -182,7 +195,7 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function attemptVoidPayment($response, $payment, $amount)
|
||||
protected function attemptVoidPayment($response, Payment $payment, $amount)
|
||||
{
|
||||
if ( ! parent::attemptVoidPayment($response, $payment, $amount)) {
|
||||
return false;
|
||||
@ -224,8 +237,6 @@ class WePayPaymentDriver extends BasePaymentDriver
|
||||
|
||||
if ($source->state == 'deleted') {
|
||||
$paymentMethod->delete();
|
||||
} else {
|
||||
//$this->paymentService->convertPaymentMethodFromWePay($source, null, $paymentMethod)->save();
|
||||
}
|
||||
|
||||
return 'Processed successfully';
|
||||
|
@ -1,14 +1,27 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
|
||||
/**
|
||||
* Class AccountGatewayRepository
|
||||
*/
|
||||
class AccountGatewayRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\AccountGateway';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
$query = DB::table('account_gateways')
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
@ -22,6 +24,9 @@ use App\Models\User;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\AccountToken;
|
||||
|
||||
/**
|
||||
* Class AccountRepository
|
||||
*/
|
||||
class AccountRepository
|
||||
{
|
||||
public function create($firstName = '', $lastName = '', $email = '', $password = '')
|
||||
@ -638,7 +643,10 @@ class AccountRepository
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function unlinkAccount($account) {
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function unlinkAccount(Account $account) {
|
||||
foreach ($account->users as $user) {
|
||||
if ($userAccount = self::findUserAccounts($user->id)) {
|
||||
$userAccount->removeUserId($user->id);
|
||||
@ -681,7 +689,11 @@ class AccountRepository
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function createTokens($user, $name)
|
||||
/**
|
||||
* @param User $user
|
||||
* @param $name
|
||||
*/
|
||||
public function createTokens(User $user, $name)
|
||||
{
|
||||
$name = trim($name) ?: 'TOKEN';
|
||||
$users = $this->findUsers($user);
|
||||
@ -698,7 +710,12 @@ class AccountRepository
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserAccountId($account)
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return bool|mixed
|
||||
*/
|
||||
public function getUserAccountId(Account $account)
|
||||
{
|
||||
$user = $account->users()->first();
|
||||
$userAccount = $this->findUserAccounts($user->id);
|
||||
@ -706,7 +723,11 @@ class AccountRepository
|
||||
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->save();
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Auth;
|
||||
@ -8,8 +10,20 @@ use App\Models\Activity;
|
||||
use App\Models\Client;
|
||||
use App\Models\Invitation;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
if ($entity instanceof Client) {
|
||||
@ -43,6 +57,11 @@ class ActivityRepository
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $entity
|
||||
*
|
||||
* @return Activity
|
||||
*/
|
||||
private function getBlank($entity)
|
||||
{
|
||||
$activity = new Activity();
|
||||
@ -64,6 +83,11 @@ class ActivityRepository
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $clientId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function findByClientId($clientId)
|
||||
{
|
||||
return DB::table('activities')
|
||||
|
@ -1,17 +1,30 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Crypt;
|
||||
use App\Models\BankAccount;
|
||||
use App\Models\BankSubaccount;
|
||||
|
||||
/**
|
||||
* Class BankAccountRepository
|
||||
*/
|
||||
class BankAccountRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\BankAccount';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
return DB::table('bank_accounts')
|
||||
@ -26,6 +39,11 @@ class BankAccountRepository extends BaseRepository
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $input
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($input)
|
||||
{
|
||||
$bankAccount = BankAccount::createNew();
|
||||
|
@ -1,19 +1,29 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Cache;
|
||||
use App\Models\Client;
|
||||
use App\Models\Contact;
|
||||
use App\Events\ClientWasCreated;
|
||||
use App\Events\ClientWasUpdated;
|
||||
|
||||
/**
|
||||
* Class ClientRepository
|
||||
*/
|
||||
class ClientRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Client';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return Client::scope()
|
||||
@ -23,6 +33,12 @@ class ClientRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $filter
|
||||
* @param bool $userId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($filter = null, $userId = false)
|
||||
{
|
||||
$query = DB::table('clients')
|
||||
@ -68,7 +84,13 @@ class ClientRepository extends BaseRepository
|
||||
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;
|
||||
|
||||
@ -95,12 +117,6 @@ class ClientRepository extends BaseRepository
|
||||
$client->fill($data);
|
||||
$client->save();
|
||||
|
||||
/*
|
||||
if ( ! isset($data['contact']) && ! isset($data['contacts'])) {
|
||||
return $client;
|
||||
}
|
||||
*/
|
||||
|
||||
$first = true;
|
||||
$contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts'];
|
||||
$contactIds = [];
|
||||
|
@ -1,9 +1,19 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use App\Models\Contact;
|
||||
|
||||
/**
|
||||
* Class ContactRepository
|
||||
*/
|
||||
class ContactRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$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 Utils;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Client;
|
||||
|
||||
/**
|
||||
* Class CreditRepository
|
||||
*/
|
||||
class CreditRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Credit';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $clientPublicId
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($clientPublicId = null, $filter = null)
|
||||
{
|
||||
$query = DB::table('credits')
|
||||
@ -58,7 +72,13 @@ class CreditRepository extends BaseRepository
|
||||
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;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Utils;
|
||||
@ -6,14 +8,22 @@ use App\Models\Document;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Form;
|
||||
|
||||
/**
|
||||
* Class DocumentRepository
|
||||
*/
|
||||
class DocumentRepository extends BaseRepository
|
||||
{
|
||||
// Expenses
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Document';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return Document::scope()
|
||||
@ -21,6 +31,9 @@ class DocumentRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function find()
|
||||
{
|
||||
$accountid = \Auth::user()->account_id;
|
||||
@ -50,6 +63,12 @@ class DocumentRepository extends BaseRepository
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @param null $doc_array
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upload($data, &$doc_array=null)
|
||||
{
|
||||
$uploaded = $data['file'];
|
||||
@ -177,6 +196,14 @@ class DocumentRepository extends BaseRepository
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $contactId
|
||||
* @param $entityType
|
||||
* @param $search
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getClientDatatable($contactId, $entityType, $search)
|
||||
{
|
||||
|
||||
|
@ -1,17 +1,26 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Utils;
|
||||
use Auth;
|
||||
use App\Models\ExpenseCategory;
|
||||
|
||||
class ExpenseCategoryRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\ExpenseCategory';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($filter = null)
|
||||
{
|
||||
$query = DB::table('expense_categories')
|
||||
@ -36,10 +45,14 @@ class ExpenseCategoryRepository extends BaseRepository
|
||||
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) {
|
||||
$category = ExpenseCategory::createNew();
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Utils;
|
||||
@ -7,21 +9,37 @@ use App\Models\Expense;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Document;
|
||||
|
||||
/**
|
||||
* Class ExpenseRepository
|
||||
*/
|
||||
class ExpenseRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @var DocumentRepository
|
||||
*/
|
||||
protected $documentRepo;
|
||||
|
||||
// Expenses
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Expense';
|
||||
}
|
||||
|
||||
/**
|
||||
* ExpenseRepository constructor.
|
||||
*
|
||||
* @param DocumentRepository $documentRepo
|
||||
*/
|
||||
public function __construct(DocumentRepository $documentRepo)
|
||||
{
|
||||
$this->documentRepo = $documentRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return Expense::scope()
|
||||
@ -31,6 +49,11 @@ class ExpenseRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $vendorPublicId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function findVendor($vendorPublicId)
|
||||
{
|
||||
$vendorId = Vendor::getPrivateId($vendorPublicId);
|
||||
@ -40,6 +63,11 @@ class ExpenseRepository extends BaseRepository
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($filter = null)
|
||||
{
|
||||
$accountid = \Auth::user()->account_id;
|
||||
@ -110,7 +138,13 @@ class ExpenseRepository extends BaseRepository
|
||||
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;
|
||||
|
||||
@ -174,6 +208,12 @@ class ExpenseRepository extends BaseRepository
|
||||
return $expense;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ids
|
||||
* @param $action
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function bulk($ids, $action)
|
||||
{
|
||||
$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
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function createRecurringInvoice(Invoice $recurInvoice)
|
||||
@ -839,6 +840,7 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
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\Company;
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
@ -12,6 +22,7 @@ class NinjaRepository
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Company $company */
|
||||
$company = $account->company;
|
||||
$company->plan = !empty($data['plan']) && $data['plan'] != PLAN_FREE?$data['plan']: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 Utils;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
|
||||
/**
|
||||
* Class PaymentRepository
|
||||
*/
|
||||
class PaymentRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Payment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $clientPublicId
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($clientPublicId = null, $filter = null)
|
||||
{
|
||||
$query = DB::table('payments')
|
||||
@ -87,6 +100,12 @@ class PaymentRepository extends BaseRepository
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $contactId
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function findForContact($contactId = null, $filter = null)
|
||||
{
|
||||
$query = DB::table('payments')
|
||||
@ -142,7 +161,13 @@ class PaymentRepository extends BaseRepository
|
||||
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;
|
||||
|
||||
@ -201,6 +226,11 @@ class PaymentRepository extends BaseRepository
|
||||
return $payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $payment
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($payment)
|
||||
{
|
||||
if ($payment->invoice->is_deleted) {
|
||||
@ -210,6 +240,11 @@ class PaymentRepository extends BaseRepository
|
||||
parent::delete($payment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $payment
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function restore($payment)
|
||||
{
|
||||
if ($payment->invoice->is_deleted) {
|
||||
|
@ -1,18 +1,27 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
|
||||
class PaymentTermRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\PaymentTerm';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId = 0)
|
||||
{
|
||||
return DB::table('payment_terms')
|
||||
//->where('payment_terms.account_id', '=', $accountId)
|
||||
->where('payment_terms.deleted_at', '=', null)
|
||||
->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 App\Models\Product;
|
||||
|
||||
/**
|
||||
* Class ProductRepository
|
||||
*/
|
||||
class ProductRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Product';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return Product::scope()
|
||||
@ -17,6 +28,11 @@ class ProductRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -1,9 +1,19 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use App\Models\Account;
|
||||
|
||||
/**
|
||||
* Class ReferralRepository
|
||||
*/
|
||||
class ReferralRepository
|
||||
{
|
||||
/**
|
||||
* @param $userId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCounts($userId)
|
||||
{
|
||||
$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 Session;
|
||||
use App\Models\Client;
|
||||
use App\Models\Task;
|
||||
|
||||
/**
|
||||
* Class TaskRepository
|
||||
*/
|
||||
class TaskRepository
|
||||
{
|
||||
/**
|
||||
* @param null $clientPublicId
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($clientPublicId = null, $filter = null)
|
||||
{
|
||||
$query = \DB::table('tasks')
|
||||
@ -62,7 +73,14 @@ class TaskRepository
|
||||
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) {
|
||||
// do nothing
|
||||
@ -109,6 +127,12 @@ class TaskRepository
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ids
|
||||
* @param $action
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function bulk($ids, $action)
|
||||
{
|
||||
$tasks = Task::withTrashed()->scope($ids)->get();
|
||||
|
@ -1,16 +1,28 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Utils;
|
||||
use App\Models\TaxRate;
|
||||
|
||||
/**
|
||||
* Class TaxRateRepository
|
||||
*/
|
||||
class TaxRateRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\TaxRate';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
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) {
|
||||
// do nothing
|
||||
@ -35,41 +53,4 @@ class TaxRateRepository extends BaseRepository
|
||||
|
||||
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 Session;
|
||||
use App\Models\Token;
|
||||
|
||||
/**
|
||||
* Class TokenRepository
|
||||
*/
|
||||
class TokenRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\AccountToken';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($userId)
|
||||
{
|
||||
$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 Session;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class UserRepository
|
||||
*/
|
||||
class UserRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\User';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $accountId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($accountId)
|
||||
{
|
||||
$query = DB::table('users')
|
||||
@ -25,7 +38,13 @@ class UserRepository extends BaseRepository
|
||||
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->save();
|
||||
|
@ -1,18 +1,25 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use App\Models\VendorContact;
|
||||
|
||||
// vendor
|
||||
/**
|
||||
* Class VendorContactRepository
|
||||
*/
|
||||
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;
|
||||
|
||||
if (!$publicId || $publicId == '-1') {
|
||||
/** @var VendorContact $contact */
|
||||
$contact = VendorContact::createNew();
|
||||
//$contact->send_invoice = true;
|
||||
$contact->vendor_id = $data['vendor_id'];
|
||||
$contact->is_primary = VendorContact::scope()->where('vendor_id', '=', $contact->vendor_id)->count() == 0;
|
||||
} else {
|
||||
|
@ -1,16 +1,26 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
<?php
|
||||
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use App\Models\Vendor;
|
||||
|
||||
// vendor
|
||||
/**
|
||||
* Class VendorRepository
|
||||
*/
|
||||
class VendorRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return 'App\Models\Vendor';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return Vendor::scope()
|
||||
@ -20,6 +30,11 @@ class VendorRepository extends BaseRepository
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $filter
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function find($filter = null)
|
||||
{
|
||||
$query = DB::table('vendors')
|
||||
@ -60,7 +75,13 @@ class VendorRepository extends BaseRepository
|
||||
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;
|
||||
|
||||
@ -75,15 +96,7 @@ class VendorRepository extends BaseRepository
|
||||
|
||||
$vendor->fill($data);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,10 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
class ClientPolicy extends EntityPolicy {}
|
||||
/**
|
||||
* Class ClientPolicy
|
||||
*/
|
||||
class ClientPolicy extends EntityPolicy
|
||||
{
|
||||
|
||||
}
|
@ -2,4 +2,10 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
class CreditPolicy extends EntityPolicy {}
|
||||
/**
|
||||
* Class CreditPolicy
|
||||
*/
|
||||
class CreditPolicy extends EntityPolicy
|
||||
{
|
||||
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
@ -11,6 +12,7 @@ class DocumentPolicy extends EntityPolicy
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function create(User $user)
|
||||
@ -20,10 +22,11 @@ class DocumentPolicy extends EntityPolicy
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param Document $document
|
||||
* @param $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function view(User $user, $document)
|
||||
public static function view(User $user, $item)
|
||||
{
|
||||
if ($user->hasPermission('view_all')) {
|
||||
return true;
|
||||
|
@ -4,6 +4,9 @@ namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class ExpensePolicy
|
||||
*/
|
||||
class ExpensePolicy extends EntityPolicy
|
||||
{
|
||||
/**
|
||||
|
@ -2,4 +2,10 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
class InvoicePolicy extends EntityPolicy {}
|
||||
/**
|
||||
* Class InvoicePolicy
|
||||
*/
|
||||
class InvoicePolicy extends EntityPolicy
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -2,4 +2,10 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
class PaymentPolicy extends EntityPolicy {}
|
||||
/**
|
||||
* Class PaymentPolicy
|
||||
*/
|
||||
class PaymentPolicy extends EntityPolicy
|
||||
{
|
||||
|
||||
}
|
@ -2,12 +2,28 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class TokenPolicy
|
||||
*/
|
||||
class TokenPolicy extends EntityPolicy {
|
||||
public static function edit($user, $item) {
|
||||
/**
|
||||
* @param User $user
|
||||
* @param $item
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function edit(User $user, $item) {
|
||||
return $user->hasPermission('admin');
|
||||
}
|
||||
|
||||
public static function create($user) {
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function create(User $user) {
|
||||
return $user->hasPermission('admin');
|
||||
}
|
||||
}
|
@ -4,10 +4,14 @@ namespace App\Policies;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class VendorPolicy
|
||||
*/
|
||||
class VendorPolicy extends EntityPolicy
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function create(User $user) {
|
||||
|
Loading…
Reference in New Issue
Block a user