hi, to sync permission i created a table permission_list on db with the same value of AuthGroups.php :
Code:
/**
* --------------------------------------------------------------------
* Permissions
* --------------------------------------------------------------------
* The available permissions in the system.
*
* If a permission is not listed here it cannot be used.
*/
public array $permissions = [
'superadmin.manage-admin' => 'Can manage other admin and user',
'admin.access' => 'Can access the sites admin area',
'admin.settings' => 'Can access the main site settings',
'admin.remove_event_admin' => 'Can remove all admin event',
'admin.remove_event_user' => 'Can remove all user event',
'admin.manage-admins' => 'Can manage other admins',
'admin.manage-users' => 'Can manage Users',
'admin.payment-manage' => 'Can manage payment',
'user.create-panel' => 'Can create panel',
'user.access' => 'Can access the sites user area',
'user.premium_front_end' => 'Accesso completo lifetime', // 1 [old]
'user.mountly_front_end' => 'Accesso completo mensile', // 2 [old]
'user.pro' => 'Funzioni avanzate valido per lifetime/mensile', // 3 [old]
'user.agency' => 'accesso lifetime+PRO con possibilità di rivendita', // 4 [old]
'user.white_label_100' => '100 licence di sub-account admin completo', // 5 [old]
'user.white_label_500' => '500 licence di sub-account admin completo', // 6 [old]
'user.new_plan' => 'Accesso test illimitato', // 7 [old]
];
then i create a model to get all table's value and in user edit :
Code:
<div class="row mt-2 mb-2">
<?php foreach($tutti_permessi as $v):?>
<div class="col-md-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="id_<?=$v->nome ?>" name="permessi['<?=$v->nome ?>']" value="<?=$v->nome ?>" >
<label class="form-check-label" for="mySwitch"><?=ucfirst(str_replace('_',' ',$v->nome)) ?></label>
</div>
</div>
<?php endforeach; ?>
</div>
in the controller method :
Code:
################ GESTIONE PERMESSI #########################
$string_permessi ='' ;
foreach($post['permessi'] as $permesso){
$string_permessi .= "'user.".$permesso."'";
if (next($post['permessi'])) {
//Doesn't Process last element
$string_permessi .= ",";
}
}
//dd($string_permessi);
$user->syncPermissions($string_permessi);
################ FINE GESTIONE GRUPPO #########################
if i remove a comment of //dd line i have :
Code:
$string_permessi string (40) "'user.premium_front_end','user.new_plan'"
but if i comment dd i have :
Code:
'user.premium_front_end','user.new_plan' is not a valid permission
Why ?