<?php
namespace common\data;
use Yii;
use yii\data\ActiveDataProvider as YiiActiveDataProvider;
/**
* Базовый ActiveDataProvider с возможностью перевернуть массив на странице.
*/
class ActiveDataProvider extends YiiActiveDataProvider
{
/**
* @var bool Зеркально отразить массив на странице.
*/
public $reverse = false;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($reverse = Yii::$app->request->getQueryParam('reverse')) {
$this->reverse = ($reverse);
}
}
/**
* @inheritdoc
*/
public function getModels()
{
$models = parent::getModels();
if ($this->reverse && $models) {
return array_reverse($models);
}
return $models;
}
}
[['created_at', 'updated_at'], 'integer' , 'when' => function($model, $attribute){
return !(is_numeric(strtotime($model->$attribute)));
}]
$query->andFilterWhere([
'and',
['>=', 'created_at', ($this->created_at) ? strtotime($this->created_at . '00:00:00') : null],
['<=', 'created_at', ($this->created_at) ? strtotime($this->created_at . '23:59:59') : null],
]);
'repetitory/<city>/<subject>' => 'search-tutor/index',
'repetitory/<city>' => 'search-tutor/index',
'repetitory/<subject>' => 'search-tutor/index',