models/ExcelImportForm.php
public function getCellValue($value, $model, $record, $key, $isParent = true)
	{
		if ($isParent) {
			if(isset($model->importSafeAttributes()[$value]) && is_array($model->importSafeAttributes()[$value])) {
				$array = $model->importSafeAttributes()[$value];

				return $array['model']::find()
				->andWhere([$array['fieldName'] => $record[$key]])
				->one()
				->id;
			}

			return isset($record[$key]) ? $record[$key] : '';
		}

		if (!is_array($value)) {
			return $record[array_search($key, $this->header)];
		}

		return $value['model']::find()
		->andWhere([$value['fieldName'] => $record[array_search($key, $this->header)]])
		->one()
		->id;
	}
public function getCellValue($value, $model, $record, $key, $isParent = true)
	{
		if ($isParent) {
			if(isset($model->importSafeAttributes()[$value]) && is_array($model->importSafeAttributes()[$value])) {
				$array = $model->importSafeAttributes()[$value];

				return $array['model']::find()
				->andWhere([$array['fieldName'] => $record[$key]])
				->one()
				->id;
			}

			return isset($record[$key]) ? $record[$key] : '';
		}

		if (!is_array($value)) {
			return $record[array_search($key, $this->header)];
		}

		return $value['model']::find()
		->andWhere([$value['fieldName'] => $record[array_search($key, $this->header)]])
		->one()
		->id;
	}
public function getCellValue ( $ value , $ model , $ record , $ key , $ isParent = true ) { if ( $ isParent ) { if ( isset ( $ model -> importSafeAttributes ( ) [ $ value ] ) && is_array ( $ model -> importSafeAttributes ( ) [ $ value ] ) ) { $ array = $ model -> importSafeAttributes ( ) [ $ value ] ; return $ array [ 'model' ] :: find ( ) -> andWhere ( [ $ array [ 'fieldName' ] => $ record [ $ key ] ] ) -> one ( ) -> id ; } return isset ( $ record [ $ key ] ) ? $ record [ $ key ] : '' ; } if ( ! is_array ( $ value ) ) { return $ record [ array_search ( $ key , $ this -> header ) ] ; } return $ value [ 'model' ] :: find ( ) -> andWhere ( [ $ value [ 'fieldName' ] => $ record [ array_search ( $ key , $ this -> header ) ] ] ) -> one ( ) -> id ; }
Get excel cell value. If the import safe attributes has the model declared, it will grab the id from that model instead of the cell value
@param string $model The model name to save the excel rows into
@param array $value The values to be assigned
@param string $record The model name to save the excel rows into
@param string $key The key
@return Return true if all records is saved
Get excel cell value . If the import safe attributes has the model declared it will grab the id from that model instead of the cell value