public function saveLot($request){ $this->load($request); $transaction = Auction::$app->db->beginTransaction(); try{ if(!$this->save()) return false; $preferences= new LotPreference(); $preferences->load($request); $preferences->lots = $this->primaryKey; if($preferences->save()){ $transaction->commit(); return true; } return false; }catch(Exception $ex){ Auction::error('Lot Not Saved Due to following Errors'.$ex->getMessage()); $transaction->rollBack(); return false; } }
/** * @return \yii\db\ActiveQuery */ public function getLotPreferences() { return $this->hasMany(LotPreference::className(), ['brand' => 'id']); }