Open Padmore51 opened 7 years ago
I am using laravel 4.2 on a project and i need the permissions checkboxes to be checked when i want to edit a role. this is html code `
<div class="col-sm-10"> @foreach($permissions as $permission ) <div class="checkbox"> <label> <input {{isset($editrole)&&array_key_exists($permission->name,$editrole) ?'checked': ''}} {{isset($permission_role[$permission->name])&&$permission_role[$permission->name]==1?'checked':''}} type="checkbox" name="permissionname[]" id="{{{$permission->name}}}" value="{{$permission->name}}" class="flat"> {{$permission->display_name}} </label> </div> @endforeach </div> </div>
` the associated permission checkboxes should be checked when i select a row.
below is the ajax script $(document).on('click', '#permisson_edit', function(){ var actionurl = '<?php echo URL::route('setup.roles') ?>'; row = $(this).closest('tr'); cols = row.find('td');
$.ajax({ url: actionurl, type: 'get', dataType: 'json', data: {'id': row.data('id')}, success: function (data) { $('#id').val(data.id); $('#name').val(data.name) $('#display_name').val(data.display_name) $('#permissionname').val(data.permissionname) $('.role_modal').modal('toggle'); }, error: function (e) { console.log(e) } }); })
my controller only returns the roles. return Response::json($roles);
return Response::json($roles);
How can i return the one to many relationship on roles and permissions?? How do i create that relationship in the first place? Then how will those checkboxes be checked?
I am using laravel 4.2 on a project and i need the permissions checkboxes to be checked when i want to edit a role. this is html code `
` the associated permission checkboxes should be checked when i select a row.
below is the ajax script $(document).on('click', '#permisson_edit', function(){ var actionurl = '<?php echo URL::route('setup.roles') ?>'; row = $(this).closest('tr'); cols = row.find('td');
my controller only returns the roles.
return Response::json($roles);
How can i return the one to many relationship on roles and permissions?? How do i create that relationship in the first place? Then how will those checkboxes be checked?