Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.83 KB | None | 0 0
  1. @extends('layouts.template')
  2.  
  3. @section('title', 'Users')
  4.  
  5. @section('main')
  6.     <h1>Users</h1>
  7.     @include('shared.alert')
  8.     <form method="get" action="/admin/users" id="searchForm">
  9.         <div class="row">
  10.             <div class="col-sm-7 mb-2">
  11.                 <p>Filter Username or E-mail</p>
  12.                 <input type="text" class="form-control" name="artist" id="artist"
  13.                        value="{{ request()->artist }}"
  14.                        placeholder="Filter Username or E-mail">
  15.             </div>
  16.             <div class="col-sm-5 mb-2">
  17.                 <p>Sort by</p>
  18.                 <select class="form-control" name="sort" id="sort">
  19.                     @foreach ($orderby as $i => $sort)
  20.                         <option value="{{$i}}" {{ (request()->sort == $i ? 'selected' : '') }}>{{$sort["DisplayName"]}}</option>
  21.                     @endforeach
  22.                 </select>
  23.             </div>
  24.         </div>
  25.  
  26.     </form>
  27.  
  28.     @if ($users->count() == 0)
  29.         <div class="alert alert-danger alert-dismissible fade show">
  30.             Can't find any user with <b>'{{ request()->name_email }}'</b> in his name or email
  31.            <button type="button" class="close" data-dismiss="alert">
  32.                <span>&times;</span>
  33.            </button>
  34.        </div>
  35.    @endif
  36.  
  37.    <div class="table-responsive">
  38.        <table class="table">
  39.            <thead>
  40.            <tr>
  41.                <th>#</th>
  42.                <th>Name</th>
  43.                <th>Email</th>
  44.                <th>Active</th>
  45.                <th>Admin</th>
  46.                <th>Actions</th>
  47.            </tr>
  48.            </thead>
  49.            <tbody>
  50.            @foreach($users as $user)
  51.                <tr>
  52.                    <td>{{ $user->id }}</td>
  53.                    <td>{{ $user->name }}</td>
  54.                    <td>{{ $user->email }}</td>
  55.                    <td> @if($user->active == 1) <i class="fas fa-check"></i> @else  @endif </td>
  56.                    <td>@if($user->admin == 1) <i class="fas fa-check"></i> @else  @endif </td>
  57.  
  58.                    <td>
  59.                        <form action="/admin/users/{{ $user->id }}" method="post" class="deleteForm" novalidate >
  60.                            @method('delete')
  61.                            @csrf
  62.                            <div class="btn-group btn-group-sm" >
  63.  
  64.                                <a href="/admin/users/{{ $user->id }}/edit" class="btn btn-outline-success @if($user->id == Auth::user()->id) disabled @endif"
  65.                                   data-toggle="tooltip"
  66.                                   title="Edit {{ $user->name }}">
  67.                                    <i class="fas fa-edit"></i>
  68.                                </a>
  69.                                <button type="button" class="btn btn-outline-danger"
  70.                                        data-toggle="tooltip"
  71.                                        @if($user->id == Auth::user()->id) disabled @endif
  72.                                        data-username="{{ $user->name }}"
  73.                                        title="Delete {{ $user->name }}">
  74.                                    <i class="fas fa-trash-alt"></i>
  75.                                </button>
  76.                            </div>
  77.                        </form>
  78.                    </td>
  79.                </tr>
  80.  
  81.            @endforeach
  82.  
  83.            </tbody>
  84.        </table>
  85.    </div>
  86.    {{ $users->links() }}
  87. @endsection
  88.  
  89. @section('script_after')
  90.    <script>
  91.        $(function () {
  92.  
  93.            // submit form when leaving text field 'artist'
  94.            $('#artist').blur(function () {
  95.                $('#searchForm').submit();
  96.             });
  97.             $('#sort').change(function () {
  98.                 $('#searchForm').submit();
  99.             });
  100.  
  101.         });
  102.  
  103.         $(function () {
  104.             $('.deleteForm button').click(function () {
  105.                 let username = $(this).data('username');
  106.                 let msg = `Delete the user ${username}?`;
  107.                 let form =$(this).closest('form');
  108.  
  109.                 // Show Noty
  110.                 let modal = new Noty({
  111.                     timeout: false,
  112.                     layout: 'center',
  113.                     modal: true,
  114.                     type: 'warning',
  115.                     text: msg,
  116.                     buttons: [
  117.                         Noty.button('Delete user', ` btn btn-success`, function () {
  118.                             // Delete genre and close modal
  119.                             $(form).submit();
  120.                             modal.close();
  121.                         }),
  122.                         Noty.button('Cancel', 'btn btn-secondary ml-2', function () {
  123.                             modal.close();
  124.                         })
  125.                     ]
  126.                 }).show();
  127.             })
  128.         });
  129.  
  130.     </script>
  131. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement