'string', 'redirect' => 'string', // TODO: @turbo124 @todo validate, that this is a url without / at the end ]; } // @turbo124 @todo please check for validity, when issue request from frontend public function prepareForValidation() { $input = $this->all(); if (!array_key_exists('redirect', $input)) { $context = $this->getTokenContent(); if ($context && array_key_exists('is_react', $context)) $input["redirect"] = $context["is_react"] ? config("ninja.react_url") : config("ninja.app_url"); else $input["redirect"] = config("ninja.app_url"); $this->replace($input); } } public function getTokenContent() { if ($this->state) { $this->token = $this->state; } $data = Cache::get($this->token); return $data; } public function getContact() { MultiDB::findAndSetDbByCompanyKey($this->getTokenContent()['company_key']); return User::findOrFail($this->getTokenContent()['user_id']); } public function getCompany() { MultiDB::findAndSetDbByCompanyKey($this->getTokenContent()['company_key']); return Company::where('company_key', $this->getTokenContent()['company_key'])->firstOrFail(); } }