%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
namespace mdm\admin\models\searchs;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use mdm\admin\models\Menu as MenuModel;
/**
* Menu represents the model behind the search form about [[\mdm\admin\models\Menu]].
*
* @author Misbahul D Munir <misbahuldmunir@gmail.com>
* @since 1.0
*/
class Menu extends MenuModel
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'parent', 'order'], 'integer'],
[['name', 'route', 'parent_name'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Searching menu
* @param array $params
* @return \yii\data\ActiveDataProvider
*/
public function search($params)
{
$query = MenuModel::find()
->from(MenuModel::tableName() . ' t')
->joinWith(['menuParent' => function ($q) {
$q->from(MenuModel::tableName() . ' parent');
}]);
$dataProvider = new ActiveDataProvider([
'query' => $query
]);
$sort = $dataProvider->getSort();
$sort->attributes['menuParent.name'] = [
'asc' => ['parent.name' => SORT_ASC],
'desc' => ['parent.name' => SORT_DESC],
'label' => 'parent',
];
$sort->attributes['order'] = [
'asc' => ['parent.order' => SORT_ASC, 't.order' => SORT_ASC],
'desc' => ['parent.order' => SORT_DESC, 't.order' => SORT_DESC],
'label' => 'order',
];
$sort->defaultOrder = ['menuParent.name' => SORT_ASC];
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere([
't.id' => $this->id,
't.parent' => $this->parent,
]);
$query->andFilterWhere(['like', 'lower(t.name)', strtolower($this->name)])
->andFilterWhere(['like', 't.route', $this->route])
->andFilterWhere(['like', 'lower(parent.name)', strtolower($this->parent_name)]);
return $dataProvider;
}
}