Calling unknown method: yii\db\ActiveQuery::delete()

Hi, I am new to Yii Framework. Currently I am dong the project by using the Yii 2.0. I am facing the problem for delete the data. Actually I am following the online tutorial. The error show "Calling unknown method: yii\db\ActiveQuery::delete()" when i am trying to delete the date.

Below is my code, please let me know where is the mistake. Thank you.

      public  function actionDelete($id=null){


	if($id===null)


	{


		Yii::$app->session->setFlash('error','no data');


		Yii::$app->getResponse()->redirect(array('site/userlist'));


	}


	$deluser= User::find($id);


	if ($deluser===NULL)


	{


		Yii::$app->session->setFlash('error','no id data');


		Yii::$app->getResponse()->redirect(array('site/userlist'));


	}


	$deluser ->delete();


	Yii::$app->session->setFlash('success','id deleted');


	Yii::$app->getResponse()->redirect(array('site/userlist'));


   }

change




$deluser= User::find($id);



[color="#1C2837"][size="2"]to[/size][/color]




$deluser= User::find()->where(['id' => $id])->one();



Thank you Radu Dumbraveanu. I already found my mistake.

Thx Radu u solved my problem

You can try this one also :


$deluser= User::findOne($id);