phplaravelcartalyst-sentinel

How find role name and id of a specific user id who is not logged in using Sentinel in laravel


How to find role name and id of a specific user id who is not logged in using Sentinel in Laravel?

// **** I have used this code =>
<?php Sentinel::getUser(4)->inRole('admin'); ?>

But this doesn't work as Sentinel::getUser() works only for logged in user. But I need to find role name and role id of nonlogged user in one of my managament , so what should be the script. I need help on this.


Solution

  • Hi I have got a solution to my problem , and its working in the view page , the code that i have used is given below

    <?php
        $user_id=3;
        $userR = App\User::find($user_id);
        $chk=$userR->inRole('admin');
        if($chk)
        {
            //***** logic comes here ******
        }
    ?>