src/base/BaseOrderModel.php
public function beforeSave ($insert)
		{
			if ($parent = parent::beforeSave($insert))
			{
				if ($this->isNewRecord)
				{
					if ($this->hasAttribute('order') and empty($this->order))
					{
						$query = self::find()->select('order')->orderBy([ 'order' => SORT_DESC ]);

						$condition = $this->orderCondition();
						if ($condition !== null)
						{
							$query->where($condition);
						}

						$order = $query->scalar();

						$this->order = !is_null($order) ? $order + 1 : 1;
					}
				}
			}

			return $parent;
		}
public function beforeSave ($insert)
		{
			if ($parent = parent::beforeSave($insert))
			{
				if ($this->isNewRecord)
				{
					if ($this->hasAttribute('order') and empty($this->order))
					{
						$query = self::find()->select('order')->orderBy([ 'order' => SORT_DESC ]);

						$condition = $this->orderCondition();
						if ($condition !== null)
						{
							$query->where($condition);
						}

						$order = $query->scalar();

						$this->order = !is_null($order) ? $order + 1 : 1;
					}
				}
			}

			return $parent;
		}
public function beforeSave ( $ insert ) { if ( $ parent = parent :: beforeSave ( $ insert ) ) { if ( $ this -> isNewRecord ) { if ( $ this -> hasAttribute ( 'order' ) and empty ( $ this -> order ) ) { $ query = self :: find ( ) -> select ( 'order' ) -> orderBy ( [ 'order' => SORT_DESC ] ) ; $ condition = $ this -> orderCondition ( ) ; if ( $ condition !== null ) { $ query -> where ( $ condition ) ; } $ order = $ query -> scalar ( ) ; $ this -> order = ! is_null ( $ order ) ? $ order + 1 : 1 ; } } } return $ parent ; }
Looking for the biggest order in the table, and the current model doing +1.

@param bool $insert
@return bool
Looking for the biggest order in the table and the current model doing + 1 .