Check if user is admin in wrapper

How would I go about checking for if the user has admin? which way should I do this? I'm using a wrapper
Solution:
Check if user is signed in ```php <?php if(Auth::check()) { // do something.....
Jump to solution
3 Replies
Chriss Quartz
Chriss QuartzOP2mo ago
I had tried the way nebula is doing it but that didn't seem to work as root_admin doesn't exist (not surprised)
Solution
Emma
Emma2mo ago
Check if user is signed in
<?php
if(Auth::check()) {
// do something..
}
<?php
if(Auth::check()) {
// do something..
}
@if(Auth::check())
<span>something here</span>
@endif
@if(Auth::check())
<span>something here</span>
@endif
Check if user is admin
<?php
if(Auth::user()->root_admin == 1) {
// do something..
}
<?php
if(Auth::user()->root_admin == 1) {
// do something..
}
@if(Auth::user()->root_admin == 1)
<span>something here</span>
@endif
@if(Auth::user()->root_admin == 1)
<span>something here</span>
@endif
Checking root_admin will error out when the user is not signed in, make sure to wrap it inside of an Auth::check() check.
Chriss Quartz
Chriss QuartzOP2mo ago
ah alr, ty :)

Did you find this page helpful?