Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function handle($request, Closure $next, $rotaSolicitada){
- try{
- $usuario = JWTAuth::parseToken()->authenticate();
- }catch (Exception $e){
- return response()->json(['error'=> true, 'mensagem'=> 'Não foi possível autenticar no sistema', 'data'=> null], 500);
- }
- $permissao = Perfil::with('usuario')
- ->where('id', $usuario->id)
- ->where('recursos->links->rota', 'reserva')
- ->get();
- //aqui é só para exibir o retorno (teste)
- dump($permissao);
- return response()->json($permissao);
- $recursoSolicitado = str_replace( '@','',strstr($request->route()->getActionName(), '@'));
- return $next($request);
- }
- public function up()
- {
- Schema::create('perfis', function (Blueprint $table) {
- $table->increments('id');
- $table->string('descricao', 45);
- $table->json('recursos')->nullable();
- $table->char('status',1);
- $table->timestamps();
- });
- }
- {"links":
- [
- {
- "rota": "reserva", "sref": "oQueFazer", "ordem": "1", "recursos": ["index", "show"], "descricao": "Reservar"
- },
- {
- "rota": "reserva", "sref": "oQueFazer", "ordem": "2", "recursos": ["index", "show"], "descricao": "Reservas"
- },
- {
- "rota": "usuario", "sref": "oQueFazer", "ordem": "3", "recursos": ["index", "show"], "descricao": "Usuários"},
- {
- "rota": "feriado", "sref": "oQueFazer", "ordem": "4", "recursos": ["index", "show"], "descricao": "Feriados"},
- {
- "rota": "sala", "sref": "home.sala", "ordem": "5", "recursos": ["index", "show"], "descricao": "Salas"
- }
- ]
- }
- $permissao = Perfil::with('usuario')
- ->where('id', $usuario->id)
- ->where('recursos->links->rota', 'reserva')
- ->get();
Add Comment
Please, Sign In to add comment