Answer the question
In order to leave comments, you need to log in
Yii2. Closure. How to get the id of the added field?
return (new \common\models\Company([
'user_id' => $user_id,
'region_id' => $this->region_id,
'city_id' => $this->city_id,
'address' => $this->address,
'subdomain' => $this->subdomain,
]))->save();
Answer the question
In order to leave comments, you need to log in
$model = new \common\models\Company([
'user_id' => $user_id,
'region_id' => $this->region_id,
'city_id' => $this->city_id,
'address' => $this->address,
'subdomain' => $this->subdomain,
]);
$model->save();
echo $model->id; // ID нового элемента
return $model;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question