Переделал виджет, более читаем

This commit is contained in:
maxim
2021-09-13 16:40:37 +03:00
parent 4b08696ed2
commit 358ffbf794
12 changed files with 255 additions and 249 deletions

View File

@ -4,22 +4,29 @@ namespace backend\modules\calendar\controllers;
use backend\modules\card\models\UserCardSearch;
use Yii;
use yii\helpers\ArrayHelper;
use yii\web\Response;
class AjaxController extends \yii\web\Controller
{
public function actionGetBirthdayByMonth($month )
public function actionGetBirthdayDate($date)
{
$searchModel = new UserCardSearch();
$dataProvider = $searchModel->search(['date' => $date]);
return $this->render('_gridView', [
'dataProvider' => $dataProvider
]);
}
public function actionGetBirthdayDatesByMonth($month )
{
$searchModel = new UserCardSearch();
$models = $searchModel->search(Yii::$app->request->queryParams)->getModels();
$models_array = ArrayHelper::toArray($models, [
'backend\modules\card\models\UserCard' => [
'id',
'dob',
'fio'
],
]);
$models_array = array_map(function ($date){return date('Y').substr($date, 4,6);},
array_column($models, 'dob')
);
$response = Yii::$app->response;
$response->format = Response::FORMAT_JSON;