sasha-x / yii2-admin
Looks like 'universal CRUD' for models list you configure.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.2
- yiisoft/yii2: >=2.0.14
This package is auto-updated.
Last update: 2024-05-09 00:25:58 UTC
README
Looks like "universal CRUD" for models list you configure. Inspired by PhpMyAdmin & SonataAdminBundle
Простая админ-панель БД для yii2.
Installation
The preferred way to install this extension is through composer.
Required
- Either run
php composer.phar require --prefer-dist sasha-x/yii2-admin "*"
or add
"sasha-x/yii2-admin": "*"
to the require section of your composer.json
file.
- In
config/web.php
'modules' => [ 'admin' => [ 'class' => 'sasha_x\admin\Module', 'models' => [ 'app\models\User', ... other models you need to edit ... ], //optionally 'allowTruncate' => true, 'customViewsPath' => '@app/views/admin', ], ], //Need to add custom routing $config['bootstrap'][] = 'admin';
Optional
- Tweak scenarios for each destination model. Looks like:
//fields list for each action in admin module gets here public function scenarios() { return [ 'default' => ['username', 'email', 'plainPassword', 'status', 'is_admin'], 'index' => ['username', 'email', 'status', 'is_admin', 'created_at', 'last_login'], 'view' => ['id', 'username', 'email', 'status', 'is_admin', 'created_at', 'updated_at', 'last_login'], 'create' => ['username', 'email', 'plainPassword', 'is_admin'], 'update' => ['username', 'email', 'plainPassword', 'status', 'is_admin'], ]; }
3.b. Make UserAdmin
model class, if you don't want to touch basic model.
- Assumed you have User model with is_admin property. If no, extend and edit AdminController::checkAccess() code.
Change defaults
Example:
//new default values set Yii::$container->setDefinitions([ 'yii\data\Pagination' => [ 'defaultPageSize' => 40, ], 'yii\grid\ActionColumn' => [ 'template' => '{update} {delete}', ], 'yii\i18n\Formatter' => [ 'dateFormat' => 'php:Y-m-d', 'timeFormat' => 'php:H:i:s', 'datetimeFormat' => 'php:Y-m-d H:i:s', ], ]);
Custom views
...
TODO
-
readOnly flag in table map
-
model relations process
-
релейшены = лейблы / отключаемые
-
названия сценариев - константами/переменными
-
расширеные тайпхинты для gridview и _form
-
вынос конфига из центрального в модульный
-
кастомные страницы
-
modal, jexcel