From 75ccbff934abeeda88f468b451846fc5cd2cba05 Mon Sep 17 00:00:00 2001 From: akosse Date: Mon, 27 Jan 2020 10:30:26 +0300 Subject: [PATCH] accesses custom delete & validation --- .../accesses/controllers/AccessesController.php | 4 ++++ backend/modules/accesses/views/accesses/index.php | 12 +++++++++++- common/models/Accesses.php | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/modules/accesses/controllers/AccessesController.php b/backend/modules/accesses/controllers/AccessesController.php index 63f10bb..966c5c5 100755 --- a/backend/modules/accesses/controllers/AccessesController.php +++ b/backend/modules/accesses/controllers/AccessesController.php @@ -114,7 +114,11 @@ class AccessesController extends Controller public function actionCustomDelete($id) { + $clean_id = str_replace('=', "", stristr($id, '=')); + UserCardAccesses::deleteAll(['accesses_id' => $clean_id]); + Accesses::deleteAll(['id' => $clean_id]); + return $this->redirect(['index']); } /** diff --git a/backend/modules/accesses/views/accesses/index.php b/backend/modules/accesses/views/accesses/index.php index 0507d75..ba31495 100755 --- a/backend/modules/accesses/views/accesses/index.php +++ b/backend/modules/accesses/views/accesses/index.php @@ -43,7 +43,17 @@ $this->params['breadcrumbs'][] = $this->title; // return $model->getProjectName(); // }, // ], - ['class' => 'yii\grid\ActionColumn'], + [ + 'class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update} {delete}', + 'buttons' => [ + 'delete' => function ($data) { + return Html::a("", + ['/accesses/accesses/custom-delete', 'id' => $data]); + }, + ], + ], +// ['class' => 'yii\grid\ActionColumn'], ], ]); ?> diff --git a/common/models/Accesses.php b/common/models/Accesses.php index 3d49c97..d732767 100755 --- a/common/models/Accesses.php +++ b/common/models/Accesses.php @@ -40,6 +40,7 @@ class Accesses extends \yii\db\ActiveRecord [['info'], 'string'], [['_projects'], 'safe'], [['_users'], 'safe'], + [['name', 'login', 'password', 'link', 'project', 'info'], 'required'], ]; }