2021-11-11 17:51:04 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-11-11 17:51:04 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Gateways\GoCardless;
|
|
|
|
|
2022-06-21 11:57:17 +02:00
|
|
|
use App\Libraries\MultiDB;
|
2021-11-11 17:51:04 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\Company;
|
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
use App\Models\PaymentHash;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
class IbpRequest extends FormRequest
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize()
|
|
|
|
{
|
2021-12-14 23:35:58 +01:00
|
|
|
MultiDB::findAndSetDbByCompanyKey($this->company_key);
|
|
|
|
|
2021-11-11 17:51:04 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCompany(): ?Company
|
|
|
|
{
|
|
|
|
return Company::where('company_key', $this->company_key)->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCompanyGateway(): ?CompanyGateway
|
|
|
|
{
|
|
|
|
return CompanyGateway::find($this->decodePrimaryKey($this->company_gateway_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentHash(): ?PaymentHash
|
|
|
|
{
|
|
|
|
return PaymentHash::where('hash', $this->hash)->firstOrFail();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getClient(): ?Client
|
|
|
|
{
|
|
|
|
return Client::find($this->getPaymentHash()->data->client_id);
|
|
|
|
}
|
|
|
|
}
|