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-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
|
|
|
}
|