I have issue with getting parameter from URL to my Yii2 Model.
URL : https://example.com/?key=test&id=1234
My code is :
public function save()
{
$httpClient = new Client();
$keyword = Yii::$app->getRequest()->getQueryParam('key');
$data = [
'civilite' => $this->civility,
'nom' => $this->lastName,
'prenom' => $this->firstName,
'telephone' => $this->phoneNumber,
'email' => $this->emailAddress,
'operateur' => $this->operator,
'tel_domicile' => $this->phone,
'keyword' => $keyword,
];
$preferences = explode(',', $this->preferences);
$index = 0;
foreach ($preferences as $preference) {
$index++;
$data['attente' . $index] = $preference;
}
LeadLogHelper::log($data);
$rawResponse = $httpClient->createRequest()
->setMethod('POST')
->setUrl(\Yii::$app->params['leadWebserviceUrl'])
->setData($data)
->send();
$response = json_decode($rawResponse->content);
if (!$response->Statut) {
Yii::error('An error occurred while saving the data using the webservice', __METHOD__);
Yii::error($data, __METHOD__);
Yii::error($response, __METHOD__);
}
return $response->Statut == 1 || $response->Message === 'La Fiche existe déjà.';
}
The Save function work, but with a null value for $Keyword, please Help!!
load()call here, sorules()should not matter.