php - Laravel Datatables while using Entrust Package -


i'm using entrust package roles management , have impleted in project based on steps mentioned in github , it's working fine assigning roles user page getting values 2 queries mentioned below , if user list goes upto 100 how can user details , want datatables view can please me view datatables format , configured yajra datatables project , working other pages, using https://github.com/zizaco/entrust

controller.php

  public function index() {     $company_id=auth::user()->company_id;     $users=user::where('company_id',$company_id)->get();     $allroles=role::where('company_id',$company_id)->get();     return view('usersroles.index',compact(['users','allroles'])); } 

view.blade.php

<table class="table table-bordered" >     <tr class="thead-cls">         <th class="center">name</th>         <th class="center">employee id</th>         <th class="center">roles</th>         <th class="center">action</th>     </tr>     @forelse($users $user)         <tr>             <td class="center">{{$user->name}}</td>             <td class="center">{{$user->emp_id}}</td>             <td class="center">                 @foreach( $user->roles $role)                     {{$role->name}},                 @endforeach              </td>              <td class="center">             @permission('users-roles-edit')                  <!-- button trigger modal -->                 <button type="button" class="btn btn-primary btn-add" data-toggle="modal" data-target="#mymodal-{{$user->id}}">                     edit                 </button>              @endrole                 <!-- modal -->                 <div class="modal fade" id="mymodal-{{$user->id}}" tabindex="-1" role="dialog" aria-labelledby="mymodallabel">                     <div class="modal-dialog" role="document">                         <div class="modal-content">                             <div class="modal-header">                                 <button type="button" class="close" data-dismiss="modal" aria-label="close"><span                                             aria-hidden="true">&times;</span></button>                                 <h4 class="modal-title" id="mymodallabel"> editing<b> {{$user->name}}'s</b> role</h4>                             </div>                             <div class="modal-body">                                 <form action="{{route('usersroles.update',$user->id)}}" method="post" role="form" id="role-form-{{$user->id}}">                                     {{csrf_field()}}                                     {{method_field('patch')}}                                     <div class="form-group">                                          <select name="roles[]" multiple required="">                                             @foreach($allroles $role)                                                 <option value="{{$role->id}}">{{$role->name}}</option>                                             @endforeach                                         </select>                                      </div>                                      {{--<button type="submit" class="btn btn-primary">submit</button>--}}                                 </form>                             </div>                             <div class="modal-footer">                                 <button type="button" class="btn btn-default btn-add" data-dismiss="modal">close</button>                                 <button type="submit" class="btn btn-primary btn-add" onclick="$('#role-form-{{$user->id}}').submit()">save changes</button>                             </div>                         </div>                     </div>                 </div>             </td>         </tr>     @empty         <td>no users</td>     @endforelse </table>        [![need datatables view][1]][1] 

just add piece of code in view jquery:

$(document).ready(function(){     $('#mytable').datatable(); }); 

#mytable id of table. more info, read documentation.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -