0

I am given the task to debug a system. I am not familiar with Entrust package.

Other pages that I go to using the sidebar works fine, but certain pages when I view them, the sidebar does not work (The dropdown disappears).

This is how the sidebar looks like when its not working: View post on imgur.com

This is how it looks like when its working: View post on imgur.com

This two block of codes are (I assume) the main culprit for the sidebar malfunction. The navigation on the sidebar that results in this bug is Student Activity->Merit Management and Student Activity->Settings

_sidebar.blade.php

@if(Entrust::can('student_activity_*'))
    <li>
        <a href="#" title="sa_menu">
            <i class="glyph-icon icon-star"></i>
            <span>Student Activity</span>
        </a>
    <div class="sidebar-submenu">
        <ul>
@if(Entrust::can('student_activity_merit_stadd'))
    <li><a href="{{ url('/student_activity/merit2') }}" title="Merit"><span>Merit Management</span></a></li>
@endif

@if(Entrust::can('student_activity_setting_stadd'))
    <li><a href="{{ url('/student_activity/viewprogsoc/merit') }}" title="Settings"><span>Settings</span></a></li>
@endif
        </ul>
    </div><!-- .sidebar-submenu -->
    </li>
@endif

web.php

//settings view
Route::get('/{option}/merit', 'StudentActController@viewMerit');

//merit view
Route::get('/merit2', 'StudentActController@viewMerit2');

StudentActController.php

public function viewMerit($option){
   // Some query ...
   return view('stad_student_activity.sa_settings', compact(...));
}

public function viewMerit2(){

   // Some query ...
   return view ('stad_student_activity.sa_merit', compact(...));
}

The view blade is just a normal blade.

Whenever I change to this two pages, the sidebar does not work. To be honest, I don't know if this is Entrust problem or CSS...

I have already googled the problem and none came out useful.

I have already checked the roles and permission in the database and the user Admin has already assigned the roles for student_activity_merit_stadd and student_activity_setting_stadd.

Thank you in advance.

  • Do you have other pages from the same controller working fine? Make sure that the blade files extend the same layout as the other views that are working. Maybe something is missing there. As far as I can see, there is a permission problem on some of the pages ie the authorization returns false. – nakov May 07 '19 at 03:46
  • There are 5 other submenus that is using the same controller and 3/5 of them works fine while these two does not. All the other blade files extends(layouts.master) and the _sidebar.blade.php is included in the master blade... About the permission problem, how does Entrust handle it and how to know exactly what is the problem? Other blades are somewhat identical and I really do not see any differences. – nazhannasir May 07 '19 at 04:21
  • Can you try removing those two blocks and make sure that the navigation goes back to normal? – nakov May 07 '19 at 04:28
  • Ok. Even after removing the entrust codes, the sidebar still is not working. No dropdown and unclickable. I'll add some more codes for the sidebar blade for you to see more of the problem.. – nazhannasir May 07 '19 at 04:52
  • so it means that you are missing something in your blade file, it is not the same as the ones that work. Most likely the scripts and style files are not being loaded. Do you have any errors in the browser console? – nakov May 07 '19 at 04:53
  • I don't see any console errors. Even in the networks tab it does not show anything... I also think that the style files are not loaded but the content of the blade I'm currently viewing works fine... – nazhannasir May 07 '19 at 04:57

1 Answers1

0

I will continue here as I want to share what you can try next. Even though I doubt that the problem is related to the entrust package. I think that a script from your navigation is not being loaded.

So based on the documentation of the package, if you are using this one.

Instead of using the Facade you can replace it with the blade directives, so instead of

@if(Entrust::can('student_activity_*'))
@endif

Try this:

@permission('student_activity_*')
 // html here
@endpermission
nakov
  • 13,938
  • 12
  • 60
  • 110
  • Is there any other method that does not require to change the entrust? Because other blades are working fine and I don't want to change something thats already working... If I want to try include the stylesheet link directly into the blade, which css file is needed? – nazhannasir May 07 '19 at 05:17
  • I really don't know. Your template is not provided from Entrust it is something else that you use there. – nakov May 07 '19 at 05:18
  • btw, I am not asking you to change it, just to debug it in order to find what causes the issue. – nakov May 07 '19 at 05:19
  • Yes, as I said I doubt that that's the problem. Because it either your permissions are not set, or exist for that user, or the styles and scripts are not loaded. – nakov May 07 '19 at 05:39
  • Thank you for your help. I'll try to figure out the problem with my friends later... – nazhannasir May 07 '19 at 06:42