1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Add is_deleted to client_gateway_tokens table

This commit is contained in:
David Bomba 2020-08-12 08:17:32 +10:00
parent 049b778d5f
commit 7feae1fd45
7 changed files with 91 additions and 2 deletions

View File

@ -245,8 +245,8 @@ class LoginController extends BaseController
$company_token = CompanyToken::whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first();
$cu = CompanyUser::query()
->where('user_id', $company_token->user_id)
->where('company_id', $company_token->company_id);
->where('user_id', $company_token->user_id);
//->where('company_id', $company_token->company_id);
//$ct = CompanyUser::whereUserId(auth()->user()->id);
return $this->refreshResponse($cu);

View File

@ -117,6 +117,8 @@ class BaseDriver extends AbstractPaymentDriver
$payment->invoices()->sync($invoices);
$payment->save();
$payment->service()->applyNumber()->save();
return $payment;
}

View File

@ -0,0 +1,46 @@
<?php
/**
* Payment Ninja (https://paymentninja.com)
*
* @link https://github.com/paymentninja/paymentninja source repository
*
* @copyright Copyright (c) 2020. Payment Ninja LLC (https://paymentninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Services\Payment;
use App\Events\Payment\PaymentWasCreated;
use App\Factory\PaymentFactory;
use App\Models\Client;
use App\Models\Payment;
use App\Services\AbstractService;
use App\Services\Client\ClientService;
use App\Services\Payment\PaymentService;
use App\Utils\Traits\GeneratesCounter;
class ApplyNumber extends AbstractService
{
use GeneratesCounter;
private $payment;
public function __construct(Payment $payment)
{
$this->client = $payment->client;
$this->payment = $payment;
}
public function run()
{
if ($this->payment->number != '') {
return $this->payment;
}
$this->payment->number = $this->getNextPaymentNumber($this->client);
return $this->payment;
}
}

View File

@ -14,6 +14,7 @@ namespace App\Services\Payment;
use App\Factory\PaymentFactory;
use App\Models\Invoice;
use App\Models\Payment;
use App\Services\Payment\ApplyNumber;
use App\Services\Payment\DeletePayment;
use App\Services\Payment\RefundPayment;
use App\Services\Payment\UpdateInvoicePayment;
@ -87,4 +88,12 @@ class PaymentService
{
return ((new UpdateInvoicePayment($this->payment)))->run();
}
public function applyNumber()
{
$this->payment = (new ApplyNumber($this->payment))->run();
return $this;
}
}

View File

@ -39,6 +39,7 @@ class ClientGatewayTokenTransformer extends EntityTransformer
'created_at' => (int)$cgt->created_at,
'updated_at' => (int)$cgt->updated_at,
'archived_at' => (int)$cgt->deleted_at,
'is_deleted' => (bool) $cgt->is_deleted,
];
}
}

View File

@ -33,6 +33,7 @@ class ClientTransformer extends EntityTransformer
protected $defaultIncludes = [
'contacts',
'documents',
'gateway_tokens',
];
/**

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIsDeletedFlagToClientGatewayTokenTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('client_gateway_tokens', function (Blueprint $table) {
$table->boolean('is_deleted')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}