cleric.test/controllers/UserSearchController.php

51 lines
1.2 KiB
PHP

<?php
namespace app\controllers;
use app\models\UserSearch;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\Request;
class UserSearchController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'only' => ['search'],
'rules' => [
[
'actions' => ['search'],
'allow' => true,
'roles' => ['userListViewer']
]
]
],
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'search' => ['POST'],
]
]
];
}
public function actionSearch(Request $request)
{
if (!$request->isPost) {
return false;
}
if (Yii::$app->user->id === null) {
return false;
}
$search = new UserSearch();
$provider = $search->search($request->post());
return $provider->query->all();
}
}