PHP code example of voskobovich / yii2-admin-toolkit

1. Go to this page and download the library: Download voskobovich/yii2-admin-toolkit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

voskobovich / yii2-admin-toolkit example snippets




namespace app\controllers;

use voskobovich\alert\helpers\AlertHelper;
use voskobovich\crud\actions\UpdateAction;
use voskobovich\crud\actions\ViewAction;
use Yii;
// and more namespases ...

/**
 * Class ProfileController.
 */
class ProfileController extends Controller
{
    /**
     * {@inheritdoc}
     */
    public function actions()
    {
        $successCallback = function () {
            Yii::$app->session->setFlash('success', 'Saved successfully!');
        };

        $errorCallback = function () {
            Yii::$app->session->setFlash('error', 'Error saving!');
        };

        $webUser = Yii::$app->user;

        return [
            'update' => [
                'class' => UpdateAction::className(),
                'modelClass' => ProfileUpdateForm::className(),
                'primaryKey' => $webUser->id,
                'redirectUrl' => false,
                'successCallback' => $successCallback,
                'errorCallback' => $errorCallback,
            ],
            'password' => [
                'class' => UpdateAction::className(),
                'modelClass' => ProfilePasswordForm::className(),
                'primaryKey' => $webUser->id,
                'redirectUrl' => ['password'],
                'viewFile' => 'password',
                'successCallback' => function () {
                    Yii::$app->session->setFlash('success', 'Password changed');
                },
                'errorCallback' => $errorCallback,
            ],
            'photo' => [
                'class' => UploadAction::className(),
                'modelClass' => ProfilePhotoForm::className(),
                'primaryKey' => $webUser->id,
                'viewFile' => 'photo',
                'redirectUrl' => false,
                'successCallback' => false,
                'errorCallback' => false,
            ],
            'photo-delete' => [
                'class' => UpdateAction::className(),
                'modelClass' => ProfilePhotoDeleteForm::className(),
                'primaryKey' => $webUser->id,
                'viewFile' => false,
                'redirectUrl' => ['update'],
                'successCallback' => false,
                'errorCallback' => false,
            ],
            'contacts' => [
                'class' => ViewAction::className(),
                'modelClass' => User::className(),
                'loadedModel' => $webUser->identity,
                'viewFile' => 'contacts',
            ],
        ];
    }
}
bash
./vendor/bin/php-cs-fixer fix