$('#insurance').on('change', function() {
$.pjax({
timeout: 4000,
url: $('#filter-form').attr('action'),
container: '.my_class_for_summary',
fragment: '.my_class_for_summary',
scrollTo: true,
replace: false,
data: {insurance: this.options[this.selectedIndex].value},
});
});
$('#rating').on('change', function() {
$.pjax({
timeout: 4000,
url: $('#filter-form').attr('action'),
container: '.my_class_for_summary',
fragment: '.my_class_for_summary',
scrollTo: true,
data: {rating: this.options[this.selectedIndex].value},
});
});
Аргумент 1, передаваемый в yii \ base \ View :: {closure} (), должен быть экземпляром Category, заданным экземпляром common \ models \ Category
return ArrayHelper::map(Category::find()->orderBy('lft')->asArray()->all(), 'id', function (array $category) {
return ($category['depth'] > 1 ? str_repeat('-- ', $category['depth'] - 1) . ' ' : '') . $category['name'];
});
/files/file.doc
, и файл такой есть то проблема в .htaccess 'components' => [
// ...
'authManager' => [
'class' => 'yii\rbac\PhpManager',
],
// ...
],
<?php
namespace app\commands;
use Yii;
use yii\console\Controller;
use \app\rbac\UserGroupRule;
class RbacController extends Controller
{
public function actionInit()
{
$authManager = \Yii::$app->authManager;
// Create roles
$guest = $authManager->createRole('guest');
$brand = $authManager->createRole('BRAND');
$talent = $authManager->createRole('TALENT');
$admin = $authManager->createRole('admin');
// Create simple, based on action{$NAME} permissions
$login = $authManager->createPermission('login');
$logout = $authManager->createPermission('logout');
$error = $authManager->createPermission('error');
$signUp = $authManager->createPermission('sign-up');
$index = $authManager->createPermission('index');
$view = $authManager->createPermission('view');
$update = $authManager->createPermission('update');
$delete = $authManager->createPermission('delete');
// Add permissions in Yii::$app->authManager
$authManager->add($login);
$authManager->add($logout);
$authManager->add($error);
$authManager->add($signUp);
$authManager->add($index);
$authManager->add($view);
$authManager->add($update);
$authManager->add($delete);
// Add rule, based on UserExt->group === $user->group
$userGroupRule = new UserGroupRule();
$authManager->add($userGroupRule);
// Add rule "UserGroupRule" in roles
$guest->ruleName = $userGroupRule->name;
$brand->ruleName = $userGroupRule->name;
$talent->ruleName = $userGroupRule->name;
$admin->ruleName = $userGroupRule->name;
// Add roles in Yii::$app->authManager
$authManager->add($guest);
$authManager->add($brand);
$authManager->add($talent);
$authManager->add($admin);
// Add permission-per-role in Yii::$app->authManager
// Guest
$authManager->addChild($guest, $login);
$authManager->addChild($guest, $logout);
$authManager->addChild($guest, $error);
$authManager->addChild($guest, $signUp);
$authManager->addChild($guest, $index);
$authManager->addChild($guest, $view);
// BRAND
$authManager->addChild($brand, $update);
$authManager->addChild($brand, $guest);
// TALENT
$authManager->addChild($talent, $update);
$authManager->addChild($talent, $guest);
// Admin
$authManager->addChild($admin, $delete);
$authManager->addChild($admin, $talent);
$authManager->addChild($admin, $brand);
}
}
'controllerNamespace' => 'app\commands',
require('bootstrap');
. Файл app.js регистрируйте в html шаблоне app/rbac/rules.php
// add the rule
$userProfileOwnerRule = new UserProfileOwnerRule();
$authManager->add($userProfileOwnerRule);
$updateOwnProfile = $authManager->createPermission('updateOwnProfile');
$updateOwnProfile->ruleName = $userProfileOwnerRule->name;
$authManager->add($updateOwnProfile);
$authManager->addChild($brand, $updateOwnProfile);
$authManager->addChild($talent, $updateOwnProfile);
<?php
return [
'userGroup' => 'O:22:"app\\rbac\\UserGroupRule":3:{s:4:"name";s:9:"userGroup";s:9:"createdAt";N;s:9:"updatedAt";N;}',
];
public function actionUpdate($id)
{
if (!\Yii::$app->user->can('updateOwnProfile', ['profileId' => \Yii::$app->user->id])) {
throw new ForbiddenHttpException('Access denied');
}
// ...
}