mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 07:24:37 -04:00
Static Analysis Cleanup
This commit is contained in:
parent
6e64a9c74a
commit
91d39aab82
@ -31,7 +31,10 @@ class StoreCreditRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return auth()->user()->can('create', Credit::class);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->can('create', Credit::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,10 +58,13 @@ class StoreCreditRequest extends Request
|
|||||||
$rules['file'] = $this->file_validation;
|
$rules['file'] = $this->file_validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;
|
||||||
|
|
||||||
// $rules['number'] = new UniqueCreditNumberRule($this->all());
|
// $rules['number'] = new UniqueCreditNumberRule($this->all());
|
||||||
$rules['number'] = ['nullable', Rule::unique('credits')->where('company_id', auth()->user()->company()->id)];
|
$rules['number'] = ['nullable', Rule::unique('credits')->where('company_id', $user->company()->id)];
|
||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
$rules['tax_rate1'] = 'bail|sometimes|numeric';
|
||||||
@ -67,7 +73,7 @@ class StoreCreditRequest extends Request
|
|||||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
if ($this->invoice_id) {
|
if ($this->invoice_id) {
|
||||||
$rules['invoice_id'] = new ValidInvoiceCreditRule();
|
$rules['invoice_id'] = new ValidInvoiceCreditRule();
|
||||||
|
@ -30,7 +30,10 @@ class UpdateCreditRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->can('edit', $this->credit);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->can('edit', $this->credit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,6 +43,9 @@ class UpdateCreditRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
@ -55,7 +61,7 @@ class UpdateCreditRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->number) {
|
if ($this->number) {
|
||||||
$rules['number'] = Rule::unique('credits')->where('company_id', auth()->user()->company()->id)->ignore($this->credit->id);
|
$rules['number'] = Rule::unique('credits')->where('company_id', $user->company()->id)->ignore($this->credit->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
@ -67,7 +73,7 @@ class UpdateCreditRequest extends Request
|
|||||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ class StoreInvoiceRequest extends Request
|
|||||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,9 @@ class UpdateInvoiceRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
@ -57,7 +60,7 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$rules['id'] = new LockedInvoiceRule($this->invoice);
|
$rules['id'] = new LockedInvoiceRule($this->invoice);
|
||||||
|
|
||||||
if ($this->number) {
|
if ($this->number) {
|
||||||
$rules['number'] = Rule::unique('invoices')->where('company_id', auth()->user()->company()->id)->ignore($this->invoice->id);
|
$rules['number'] = Rule::unique('invoices')->where('company_id', $user->company()->id)->ignore($this->invoice->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
@ -72,10 +75,7 @@ class UpdateInvoiceRequest extends Request
|
|||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
|
$rules['status_id'] = 'bail|sometimes|not_in:5'; //do not allow cancelled invoices to be modfified.
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
// not needed.
|
|
||||||
// $rules['partial_due_date'] = 'bail|sometimes|required_unless:partial,0,null';
|
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,10 @@ class StorePurchaseOrderRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return auth()->user()->can('create', PurchaseOrder::class);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->can('create', PurchaseOrder::class);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@ -38,11 +41,14 @@ class StorePurchaseOrderRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
$rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.auth()->user()->company()->id.',is_deleted,0';
|
$rules['vendor_id'] = 'bail|required|exists:vendors,id,company_id,'.$user->company()->id.',is_deleted,0';
|
||||||
|
|
||||||
$rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', auth()->user()->company()->id)];
|
$rules['number'] = ['nullable', Rule::unique('purchase_orders')->where('company_id', $user->company()->id)];
|
||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
@ -60,7 +66,7 @@ class StorePurchaseOrderRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rules['status_id'] = 'nullable|integer|in:1,2,3,4,5';
|
$rules['status_id'] = 'nullable|integer|in:1,2,3,4,5';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class UpdatePurchaseOrderRequest extends Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rules['status_id'] = 'sometimes|integer|in:1,2,3,4,5';
|
$rules['status_id'] = 'sometimes|integer|in:1,2,3,4,5';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,20 @@ class StoreQuoteRequest extends Request
|
|||||||
*/
|
*/
|
||||||
public function authorize() : bool
|
public function authorize() : bool
|
||||||
{
|
{
|
||||||
return auth()->user()->can('create', Quote::class);
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return $user->can('create', Quote::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;
|
||||||
|
|
||||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
$rules['documents.*'] = $this->file_validation;
|
$rules['documents.*'] = $this->file_validation;
|
||||||
@ -51,11 +57,11 @@ class StoreQuoteRequest extends Request
|
|||||||
$rules['file'] = $this->file_validation;
|
$rules['file'] = $this->file_validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['number'] = ['nullable', Rule::unique('quotes')->where('company_id', auth()->user()->company()->id)];
|
$rules['number'] = ['nullable', Rule::unique('quotes')->where('company_id', $user->company()->id)];
|
||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
|
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
// $rules['number'] = new UniqueQuoteNumberRule($this->all());
|
// $rules['number'] = new UniqueQuoteNumberRule($this->all());
|
||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
|
@ -57,7 +57,7 @@ class UpdateQuoteRequest extends Request
|
|||||||
$rules['line_items'] = 'array';
|
$rules['line_items'] = 'array';
|
||||||
$rules['discount'] = 'sometimes|numeric';
|
$rules['discount'] = 'sometimes|numeric';
|
||||||
$rules['is_amount_discount'] = ['boolean'];
|
$rules['is_amount_discount'] = ['boolean'];
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,9 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
|
||||||
if ($this->file('documents') && is_array($this->file('documents'))) {
|
if ($this->file('documents') && is_array($this->file('documents'))) {
|
||||||
@ -54,7 +57,7 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
$rules['file'] = $this->file_validation;
|
$rules['file'] = $this->file_validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules['client_id'] = 'required|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
$rules['client_id'] = 'required|exists:clients,id,company_id,'.$user->company()->id;
|
||||||
|
|
||||||
$rules['invitations.*.client_contact_id'] = 'distinct';
|
$rules['invitations.*.client_contact_id'] = 'distinct';
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ class StoreRecurringInvoiceRequest extends Request
|
|||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['due_date_days'] = 'bail|sometimes|string';
|
$rules['due_date_days'] = 'bail|sometimes|string';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name1'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name2'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
$rules['tax_name3'] = 'bail|sometimes|string|nullable';
|
||||||
$rules['exchange_rate'] = 'bail|sometimes|gt:0';
|
$rules['exchange_rate'] = 'bail|sometimes|numeric';
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
unset($input['documents']);
|
unset($input['documents']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('exchange_rate', $input) && (is_null($input['exchange_rate']) || $input['exchange_rate'] == 0)) {
|
if (array_key_exists('exchange_rate', $input) && (is_null($input['exchange_rate']) || $input['exchange_rate'] == 0) || !isset($input['exchange_rate'])) {
|
||||||
$input['exchange_rate'] = 1;
|
$input['exchange_rate'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class UpdateRecurringInvoiceRequest extends Request
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function setAutoBillFlag($auto_bill)
|
private function setAutoBillFlag($auto_bill): bool
|
||||||
{
|
{
|
||||||
if ($auto_bill == 'always' || $auto_bill == 'optout') {
|
if ($auto_bill == 'always' || $auto_bill == 'optout') {
|
||||||
return true;
|
return true;
|
||||||
|
@ -288,7 +288,7 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
$this->available_balance = $amount;
|
$this->available_balance = $amount;
|
||||||
|
|
||||||
\DB::connection(config('database.default'))->transaction(function () use ($invoices) {
|
\DB::connection(config('database.default'))->transaction(function () use ($invoices) {
|
||||||
$invoices->each(function ($invoice) use ($invoices) {
|
$invoices->each(function ($invoice) {
|
||||||
$this->invoice = Invoice::withTrashed()->where('id', $invoice->id)->lockForUpdate()->first();
|
$this->invoice = Invoice::withTrashed()->where('id', $invoice->id)->lockForUpdate()->first();
|
||||||
|
|
||||||
$_amount = false;
|
$_amount = false;
|
||||||
|
@ -1803,7 +1803,8 @@ class Import implements ShouldQueue
|
|||||||
$modified['client_id'] = $this->transformId('clients', $resource['client_id']);
|
$modified['client_id'] = $this->transformId('clients', $resource['client_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$project = Project::Create($modified);
|
/** @var \App\Models\Project $project **/
|
||||||
|
$project = Project::create($modified);
|
||||||
|
|
||||||
$key = "projects_{$resource['id']}";
|
$key = "projects_{$resource['id']}";
|
||||||
|
|
||||||
|
@ -53,11 +53,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property int $use_inventory_management
|
* @property int $use_inventory_management
|
||||||
* @property string|null $optional_product_ids
|
* @property string|null $optional_product_ids
|
||||||
* @property string|null $optional_recurring_product_ids
|
* @property string|null $optional_recurring_product_ids
|
||||||
* @property \App\Models\Company $company
|
* @property-read \App\Models\Company $company
|
||||||
* @property-read mixed $hashed_id
|
* @property-read mixed $hashed_id
|
||||||
* @property-read \App\Models\GroupSetting|null $group_settings
|
* @property-read \App\Models\GroupSetting|null $group_settings
|
||||||
* @property-read \App\Models\User $user
|
* @property-read \App\Models\User $user
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel company()
|
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
||||||
* @method static \Database\Factories\SubscriptionFactory factory($count = null, $state = [])
|
* @method static \Database\Factories\SubscriptionFactory factory($count = null, $state = [])
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|Subscription filter(\App\Filters\QueryFilters $filters)
|
* @method static \Illuminate\Database\Eloquent\Builder|Subscription filter(\App\Filters\QueryFilters $filters)
|
||||||
|
@ -39,7 +39,7 @@ class PaymentIntentPartiallyFundedWebhook implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||||
|
|
||||||
$company = Company::where('company_key', $this->company_key)->first();
|
$company = Company::query()->where('company_key', $this->company_key)->first();
|
||||||
|
|
||||||
foreach ($this->stripe_request as $transaction) {
|
foreach ($this->stripe_request as $transaction) {
|
||||||
$payment_intent = false;
|
$payment_intent = false;
|
||||||
@ -65,7 +65,7 @@ class PaymentIntentPartiallyFundedWebhook implements ShouldQueue
|
|||||||
nlog("paymentintent found but no payment");
|
nlog("paymentintent found but no payment");
|
||||||
}
|
}
|
||||||
|
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$stripe_driver = $company_gateway->driver()->init();
|
$stripe_driver = $company_gateway->driver()->init();
|
||||||
|
|
||||||
$hash = isset($transaction['metadata']['payment_hash']) ? $transaction['metadata']['payment_hash'] : false;
|
$hash = isset($transaction['metadata']['payment_hash']) ? $transaction['metadata']['payment_hash'] : false;
|
||||||
|
@ -57,17 +57,15 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||||
|
|
||||||
$company = Company::where('company_key', $this->company_key)->first();
|
$company = Company::query()->where('company_key', $this->company_key)->first();
|
||||||
|
|
||||||
foreach ($this->stripe_request as $transaction) {
|
foreach ($this->stripe_request as $transaction) {
|
||||||
if (array_key_exists('payment_intent', $transaction)) {
|
if (array_key_exists('payment_intent', $transaction)) {
|
||||||
/** @var \App\Models\Payment $payment **/
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $company->id)
|
->where('company_id', $company->id)
|
||||||
->where('transaction_reference', $transaction['payment_intent'])
|
->where('transaction_reference', $transaction['payment_intent'])
|
||||||
->first();
|
->first();
|
||||||
} else {
|
} else {
|
||||||
/** @var \App\Models\Payment $payment **/
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $company->id)
|
->where('company_id', $company->id)
|
||||||
->where('transaction_reference', $transaction['id'])
|
->where('transaction_reference', $transaction['id'])
|
||||||
@ -97,8 +95,7 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
if ($this->payment_completed) {
|
if ($this->payment_completed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/** @var \App\Models\CompanyGateway $company_gateway **/
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
|
||||||
$stripe_driver = $company_gateway->driver()->init();
|
$stripe_driver = $company_gateway->driver()->init();
|
||||||
|
|
||||||
$charge_id = false;
|
$charge_id = false;
|
||||||
@ -126,10 +123,8 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var \App\Models\Company $company **/
|
$company = Company::query()->where('company_key', $this->company_key)->first();
|
||||||
$company = Company::where('company_key', $this->company_key)->first();
|
|
||||||
|
|
||||||
/** @var \App\Models\Payment $payment **/
|
|
||||||
$payment = Payment::query()
|
$payment = Payment::query()
|
||||||
->where('company_id', $company->id)
|
->where('company_id', $company->id)
|
||||||
->where('transaction_reference', $charge['id'])
|
->where('transaction_reference', $charge['id'])
|
||||||
@ -189,7 +184,7 @@ class PaymentIntentProcessingWebhook implements ShouldQueue
|
|||||||
|
|
||||||
private function updateAchPayment($payment_hash, $client, $meta)
|
private function updateAchPayment($payment_hash, $client, $meta)
|
||||||
{
|
{
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$payment_method_type = $meta['gateway_type_id'];
|
$payment_method_type = $meta['gateway_type_id'];
|
||||||
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class PaymentIntentWebhook implements ShouldQueue
|
|||||||
{
|
{
|
||||||
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
||||||
|
|
||||||
$company = Company::where('company_key', $this->company_key)->first();
|
$company = Company::query()->where('company_key', $this->company_key)->first();
|
||||||
|
|
||||||
foreach ($this->stripe_request as $transaction) {
|
foreach ($this->stripe_request as $transaction) {
|
||||||
if (array_key_exists('payment_intent', $transaction)) {
|
if (array_key_exists('payment_intent', $transaction)) {
|
||||||
@ -84,7 +84,7 @@ class PaymentIntentWebhook implements ShouldQueue
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$stripe_driver = $company_gateway->driver()->init();
|
$stripe_driver = $company_gateway->driver()->init();
|
||||||
|
|
||||||
$charge_id = false;
|
$charge_id = false;
|
||||||
@ -196,7 +196,7 @@ class PaymentIntentWebhook implements ShouldQueue
|
|||||||
|
|
||||||
private function updateAchPayment($payment_hash, $client, $meta)
|
private function updateAchPayment($payment_hash, $client, $meta)
|
||||||
{
|
{
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$payment_method_type = $meta['gateway_type_id'];
|
$payment_method_type = $meta['gateway_type_id'];
|
||||||
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ class PaymentIntentWebhook implements ShouldQueue
|
|||||||
|
|
||||||
private function updateCreditCardPayment($payment_hash, $client, $meta)
|
private function updateCreditCardPayment($payment_hash, $client, $meta)
|
||||||
{
|
{
|
||||||
$company_gateway = CompanyGateway::find($this->company_gateway_id);
|
$company_gateway = CompanyGateway::query()->find($this->company_gateway_id);
|
||||||
$payment_method_type = $meta['gateway_type_id'];
|
$payment_method_type = $meta['gateway_type_id'];
|
||||||
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
$driver = $company_gateway->driver($client)->init()->setPaymentMethod($payment_method_type);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class UpdatePaymentMethods
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($bank_methods->data as $method) {
|
foreach ($bank_methods->data as $method) {
|
||||||
$token = ClientGatewayToken::where([
|
$token = ClientGatewayToken::query()->where([
|
||||||
'gateway_customer_reference' => $customer->id,
|
'gateway_customer_reference' => $customer->id,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
@ -140,7 +140,7 @@ class UpdatePaymentMethods
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($sources->data as $method) {
|
foreach ($sources->data as $method) {
|
||||||
$token_exists = ClientGatewayToken::where([
|
$token_exists = ClientGatewayToken::query()->where([
|
||||||
'gateway_customer_reference' => $customer->id,
|
'gateway_customer_reference' => $customer->id,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
@ -176,7 +176,7 @@ class UpdatePaymentMethods
|
|||||||
|
|
||||||
private function addOrUpdateCard(PaymentMethod $method, $customer_reference, Client $client, $type_id)
|
private function addOrUpdateCard(PaymentMethod $method, $customer_reference, Client $client, $type_id)
|
||||||
{
|
{
|
||||||
$token_exists = ClientGatewayToken::where([
|
$token_exists = ClientGatewayToken::query()->where([
|
||||||
'gateway_customer_reference' => $customer_reference,
|
'gateway_customer_reference' => $customer_reference,
|
||||||
'token' => $method->id,
|
'token' => $method->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
|
@ -501,7 +501,8 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
$client_gateway_token = ClientGatewayToken::whereClientId($this->client->id)
|
$client_gateway_token = ClientGatewayToken::query()
|
||||||
|
->whereClientId($this->client->id)
|
||||||
->whereCompanyGatewayId($this->company_gateway->id)
|
->whereCompanyGatewayId($this->company_gateway->id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
@ -892,7 +893,7 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
public function setClientFromCustomer($customer)
|
public function setClientFromCustomer($customer)
|
||||||
{
|
{
|
||||||
$this->client = ClientGatewayToken::where('gateway_customer_reference', $customer)->client;
|
$this->client = ClientGatewayToken::query()->where('gateway_customer_reference', $customer)->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ class PaymentMethod
|
|||||||
|
|
||||||
private $amount;
|
private $amount;
|
||||||
|
|
||||||
/** @var \Illuminate\Support\Collection<CompanyGateway> $gateways */
|
/** @var \Illuminate\Support\Collection<CompanyGateway> $gateways **/
|
||||||
private $gateways;
|
private $gateways;
|
||||||
|
|
||||||
private $payment_methods;
|
private $payment_methods;
|
||||||
|
@ -13,6 +13,7 @@ namespace App\Transformers;
|
|||||||
|
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\BankIntegration;
|
use App\Models\BankIntegration;
|
||||||
|
use App\Models\BankTransaction;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Transformers\EntityTransformer;
|
use App\Transformers\EntityTransformer;
|
||||||
|
|
||||||
|
@ -94,11 +94,14 @@ class UserTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($user->company_users, $transformer, CompanyUser::class);
|
return $this->includeCollection($user->company_users, $transformer, CompanyUser::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
*/
|
||||||
public function includeCompanyUser(User $user)
|
public function includeCompanyUser(User $user)
|
||||||
{
|
{
|
||||||
if (! $user->company_id && request()->header('X-API-TOKEN')) {
|
if (! $user->company_id && request()->header('X-API-TOKEN')) {
|
||||||
$company_token = CompanyToken::where('token', request()->header('X-API-TOKEN'))->first();
|
$company_token = CompanyToken::query()->where('token', request()->header('X-API-TOKEN'))->first();
|
||||||
/** @var \App\Models\User $user */
|
|
||||||
$user->company_id = $company_token->company_id;
|
$user->company_id = $company_token->company_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user