This doesn’t work (nothing is displayed):
echo Auth::user()->is_admin;
This, however, works fine (the column value is displayed):
echo DB::table('users')->where('id', Auth::id())->value('is_admin');
When having just echo Auth::user() then this is displayed:
{“id”:19,”name”:”peeter”,”email”:”[email protected]”,”is_admin”:false}
As you can see it returns all the other column values just fine but “is_admin” column value is for some reason “false”, no matter what the column value or type is set in phpmyadmin.
For example this is my full code that I put in web.php to test this:
Route::get('/testing', function(){
echo Auth::user()->is_admin;
echo DB::table('users')->where('id', auth::id())->value('is_admin');
});
I expected echo Auth::user()->is_admin; or echo Auth::user() to return the value of the “is_admin” column instead of displaying nothing or FALSE.