2021-04-20 16:08:33 +02: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-04-20 16:08:33 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-04-20 16:08:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Requests\StripeConnect;
|
|
|
|
|
2021-04-21 16:36:08 +02:00
|
|
|
use App\Models\Company;
|
2021-04-22 15:40:36 +02:00
|
|
|
use App\Models\User;
|
2021-04-20 16:08:33 +02:00
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
|
|
class InitializeStripeConnectRequest extends FormRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function authorize(): bool
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
//
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resolve one-time token instance.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getTokenContent()
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
if ($this->state) {
|
2021-05-18 04:13:00 +02:00
|
|
|
$this->token = $this->state;
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
|
|
|
|
2021-04-21 16:36:08 +02:00
|
|
|
$data = Cache::get($this->token);
|
2021-04-20 16:08:33 +02:00
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
2021-04-21 16:36:08 +02:00
|
|
|
|
|
|
|
public function getContact()
|
|
|
|
{
|
2021-04-22 15:40:36 +02:00
|
|
|
return User::findOrFail($this->getTokenContent()['user_id']);
|
2021-04-21 16:36:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getCompany()
|
|
|
|
{
|
|
|
|
return Company::where('company_key', $this->getTokenContent()['company_key'])->firstOrFail();
|
|
|
|
}
|
2021-04-20 16:08:33 +02:00
|
|
|
}
|