1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 00:22:51 +01:00
invoiceninja/app/Http/Requests/StripeConnect/InitializeStripeConnectRequest.php

70 lines
1.4 KiB
PHP
Raw Normal View History

2021-04-20 16:08:33 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Requests\StripeConnect;
2021-04-21 16:36:08 +02:00
use App\Models\ClientContact;
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()
{
2021-05-18 04:13:00 +02:00
if($this->state)
$this->token = $this->state;
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
}