Yii2 Order by RAND sql query

For get random item from your model in yii2 you can use:

Fast and simply solution is:

$item = YourModel::find()->orderBy('rand()')->one();

Proffessional way:

use yii\db\Expression;
...
$item = YourModel::find()->orderBy(new Expression('rand()'));