1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/app/Http/Requests/Payments/PaymentWebhookRequest.php

48 lines
932 B
PHP
Raw Normal View History

2020-06-27 15:53:12 +02:00
<?php
namespace App\Http\Requests\Payments;
use App\Models\Company;
use App\Models\CompanyGateway;
use Illuminate\Foundation\Http\FormRequest;
class PaymentWebhookRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
//
];
}
public function company()
{
2020-06-27 17:39:28 +02:00
if (!$this->company_key) {
return false;
}
2020-06-27 15:53:12 +02:00
return Company::query()
->where('company_key', $this->company_key)
->firstOrFail();
}
public function companyGateway()
{
2020-06-27 17:39:28 +02:00
if (!$this->gateway_key || !$this->company_key) {
return false;
}
2020-06-27 15:53:12 +02:00
$company = $this->company();
return CompanyGateway::query()
->where('gateway_key', $this->gateway_key)
->where('company_id', $company->id)
->firstOrFail();
}
}