init
This commit is contained in:
88
helpers/UserGrid.php
Normal file
88
helpers/UserGrid.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace app\helpers;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class UserGrid {
|
||||
|
||||
public static function engineNameFunc() {
|
||||
return function ($data) {
|
||||
return $data->app->app_name;
|
||||
};
|
||||
}
|
||||
|
||||
public static function getLayout() {
|
||||
return "{items}<div class='row'><div class='col-md-4'>{summary}</div><div class='col-md-8 text-right'>{pager}</div></div>";
|
||||
}
|
||||
|
||||
public static function actionTemplate() {
|
||||
return "{view} {update} {delete}";
|
||||
}
|
||||
|
||||
public static function avatar() {
|
||||
return function($model) {
|
||||
return "23432";
|
||||
};
|
||||
}
|
||||
|
||||
public static function roles() {
|
||||
return function($model) {
|
||||
return $model->roleName;
|
||||
};
|
||||
}
|
||||
|
||||
public static function view() {
|
||||
return function($url, $model) {
|
||||
if (\Yii::$app->user->can("administrator")) {
|
||||
return Html::button("<i class='fa fa-search'></i>", [
|
||||
"class" => "btn btn-info btn-xs",
|
||||
"data" => [
|
||||
"toggle" => "tooltip",
|
||||
"href" => Url::to(['/user/view', 'id' => $model->id])
|
||||
],
|
||||
"title" => Yii::t("app", "View"),
|
||||
"onclick" => "user.form(this);"
|
||||
]);
|
||||
}
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
public static function update() {
|
||||
return function($url, $model) {
|
||||
if (\Yii::$app->user->can("administrator")) {
|
||||
return Html::button("<i class='fa fa-pencil'></i>", [
|
||||
"class" => "btn btn-success btn-xs",
|
||||
"data" => [
|
||||
"toggle" => "tooltip",
|
||||
"href" => Url::to(['/user/update', 'id' => $model->id])
|
||||
],
|
||||
"title" => Yii::t("app", "Edit"),
|
||||
"onclick" => "user.form(this);"
|
||||
]);
|
||||
}
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
public static function delete() {
|
||||
return function($url, $model) {
|
||||
if (\Yii::$app->user->can("administrator")) {
|
||||
return Html::a('<i class="fa fa-trash"></i>', ['/user/delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger btn-xs',
|
||||
'title' => Yii::t("app", "Delete"),
|
||||
'data' => [
|
||||
'toggle' => 'tooltip',
|
||||
'confirm' => "Bạn có chắc chắn muốn xóa người dùng này không?",
|
||||
'method' => 'post'
|
||||
]
|
||||
]);
|
||||
}
|
||||
return "";
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user