$perPage = [10, 25, 50];
$current = Yii::$app->request->get('per-page');
<select name="per-page" onchange="location = this.value">
<?php foreach ($perPage as $value): ?>
<option value="<?php Html::encode(\yii\helpers\Url::current(['per-page' => $value, 'page' => null])) ?>"
<?php if ($current == $value): ?>selected="selected"<?php endif; ?>
>
<?= $value ?>
</option>
<?php endforeach; ?>
</select>
/home/ruslan/Development/test_kma.biz/models/NewsSearch.php:81:
array (size=4)
0 =>
object(app\models\News)[145]
public 'image' => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 1
'image_path' => string 'images/posts/1551009564.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 18:35:08' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 1
'user_id' => int 1
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 1
'image_path' => string 'images/posts/1551009564.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 18:35:08' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 1
'user_id' => int 1
private '_related' (yii\db\BaseActiveRecord) =>
array (size=1)
'user' => null
private '_relationsDependencies' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_eventWildcards' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty
1 =>
object(app\models\News)[147]
public 'image' => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 2
'image_path' => string 'images/posts/1551011057.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:24:07' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 1
'user_id' => int 4
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 2
'image_path' => string 'images/posts/1551011057.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:24:07' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 1
'user_id' => int 4
private '_related' (yii\db\BaseActiveRecord) =>
array (size=1)
'user' => null
private '_relationsDependencies' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_eventWildcards' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty
2 =>
object(app\models\News)[148]
public 'image' => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 3
'image_path' => string 'images/posts/1551011121.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:47:37' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 0
'user_id' => int 1
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 3
'image_path' => string 'images/posts/1551011121.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:47:37' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 0
'user_id' => int 1
private '_related' (yii\db\BaseActiveRecord) =>
array (size=1)
'user' => null
private '_relationsDependencies' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_eventWildcards' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty
3 =>
object(app\models\News)[149]
public 'image' => null
private '_attributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 4
'image_path' => string 'images/posts/1551011150.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:47:37' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 0
'user_id' => int 1
private '_oldAttributes' (yii\db\BaseActiveRecord) =>
array (size=9)
'id' => int 4
'image_path' => string 'images/posts/1551011150.png' (length=27)
'title' => string 'ыфвыф' (length=10)
'description' => string 'вфы' (length=6)
'text' => string '<p>вфывфы</p>
' (length=21)
'created_at' => string '2019-02-24 17:47:37' (length=19)
'updated_at' => string '0000-00-00 00:00:00' (length=19)
'status' => int 0
'user_id' => int 1
private '_related' (yii\db\BaseActiveRecord) =>
array (size=1)
'user' => null
private '_relationsDependencies' (yii\db\BaseActiveRecord) =>
array (size=0)
empty
private '_errors' (yii\base\Model) => null
private '_validators' (yii\base\Model) => null
private '_scenario' (yii\base\Model) => string 'default' (length=7)
private '_events' (yii\base\Component) =>
array (size=0)
empty
private '_eventWildcards' (yii\base\Component) =>
array (size=0)
empty
private '_behaviors' (yii\base\Component) =>
array (size=0)
empty
<?php
namespace app\models;
use Yii;
use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\web\IdentityInterface;
/**
* User model
*
* @property integer $id
* @property string $username
* @property string $password_hash
* @property string $password_reset_token
* @property string $email
* @property string $auth_key
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
* @property string $auth_date
* @property string $password write-only password
*/
class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
public $id;
public $username;
public $email;
public $created_at;
public $auth_date;
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%user}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
['status', 'default', 'value' => self::STATUS_DELETED],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED]],
];
}
/**
* @inheritdoc
*/
public static function findIdentity($id)
{
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
}
/**
* @inheritdoc
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* Finds user by username
*
* @param string $username
* @return static|null
*/
public static function findByUsername($username)
{
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
}
/**
* @inheritdoc
*/
public function getId()
{
return $this->getPrimaryKey();
}
/**
* @inheritdoc
*/
public function getAuthKey()
{
return $this->auth_key;
}
/**
* @inheritdoc
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* Validates password
*
* @param string $password password to validate
* @return bool if password provided is valid for current user
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
/**
* Generates "remember me" authentication key
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
}
"export 'default' (imported as 'component') was not found in './components'