1
I’m creating a scheduling system with Laravel and Adminlte. The authentication method I used was not the Laravel Auth or the Adminlte, because I simply used a Controller that uses a method for authentication in my AD (ldap_connect and ldap_bind). Once logged in, the controller itself will search in my users table (using Cpf obtained from AD) the level field containing 1 or 2 (1 for admin and 2 for users). The intention is that the Adminlte menu will be different for the admin and for the users. I tried to edit the Appserviceprovider file, but it does not get back to Session with get(), so I can’t create my menu. I know that using Laravel’s traditional authentication method would work well, but in my case it’s different.
Trecho da autenticação LoginController.php
$user = DB::table('users') ->Where('Cpf', '=', $usr) ->first();
      if (isset($user)) {
        if ($user->level == '1') {
          Session::put('admin', $user->level);
        } else {
          Session::put('admin', '2');
        }
      }else {
        Session::put('admin', '2');
      }
      $level = Session::get('admin');
      return view('welcome', compact('cpf', 'email', 'tel', 'nome', 'level'));
I tried to use Laratrust
App Mymenufilter.php
namespace App;
use Jeroennoten Laraveladminlte Menu Builder; use Jeroennoten Laraveladminlte Menu Filters Filterinterface; use Laratrust;
class Mymenufilter Implements Filterinterface { public Function Transform($item, Builder $Builder) { if (isset($item['permission']) && ! Laratrust:can($item['permission'])) { Return false; }
    return $item;
}
}
config adminlte.php
'menu' => [ AGENDA [ 'text => 'Settings', 'icon => 'Calendar', 'permission' => 'settings', //here the user does not see 'submenu' => [ [ 'text' => 'Monthly', 'url' => '#', 'icon_color' => 'red', 'submenu' => [ [ 'text' => 'Make available', 'url' => '#', 'icon' => 'Calendar-plus-o', ], [ 'text => 'Delete', 'url => '#', 'icon' => 'Calendar-Minus-o '
                    ],
                    [
                        'text' => 'Ver',
                        'url'  => '#',
                        'icon' => 'calendar-check-o',
                    ],
                ],
            ],
            [
                'text' => 'Diário',
                'url'  => '#',
                'icon_color' => 'yellow',
                'submenu' => [
                    [
                        'text' => 'Disponibilizar',
                        'url'  => '#',
                        'icon' => 'calendar-plus-o',
                    ],
                    [
                        'text'    => 'Excluir',
                        'url'     => '#',
                        'icon' => 'calendar-minus-o '
                    ],
                    [
                        'text' => 'Ver',
                        'url'  => '#',
                        'icon' => 'calendar-check-o',
                    ],
                ],
            ],
        ],
    ],
    'CONFIGURAÇÕES DE USUÁRIO',
    [
        'text' => 'Administradores',
        'url'  => 'admin/settings',
        'icon' => 'user-secret',
        'submenu' => [
            [
                'text' => 'Criar',
                'url'  => '#',
                'icon' => 'user-plus',
            ],
            [
                'text'    => 'Ver',
                'url'     => '#',
                'icon' => 'users'
            ],
          ],
    ],
    'AVISOS',
    [
        'text'       => 'Agendamentos de hoje',
        'icon_color' => 'red',
        'label' => 2,
        'label_color' => 'success',
    ],
    [
        'text'       => 'Eventos de hoje',
        'icon_color' => 'yellow',
        'label'      =>  4,
    ],
    [
        'text'       => 'Total de Agendamentos',
        'icon_color' => 'aqua',
        'label'      => 2,
    ],
],