1 year ago

Display Data based on user role

Posted 1 year ago by Prathamesh6921

Greetings, i am novice in laravel ,I am trying to fetch all the data on admin profile .On the admin page he want to see the requests made by all users. Login function for role check while sign in.

 public function loginProcess(Request $request)
            if(Auth::attempt(['email' => $request->email, 'password' => $request->password, 'status'=>1])){
                if((Auth::user()->role == 'admin')){
                     return url('showallrequest');
                } else {
                        return $this->saveRequest($request);
                    } else {
                        return url('displayLegal');
                return 'true';
            return "false";

This is the user controller in which admin will logged-in and after login he will be redirected to the dashboard where he will see all the user's requests.

    <div class="row" style="padding-left: 35px;padding-right: 35px;" >
        <div class="col-md-12" style="margin-bottom: 20px">
            <button class="btn btn-success pull-right" style="background: red;border: none;"><a href="submit_query">New Request <i class="fa fa-plus" style="margin-left: 10px;"></i></a></button>
        <div class="col-md-12" id="user_request_div">

        <!--end .card -->

            success: function (result) {
                for(var i = 0;i<result.length;i++){
                    if(result[i].service_package.default_price == null){
                        result[i].service_package.default_price = 0;
                    $("<div class='card'> " +
                        "<div class='card-body text-default-light' style='padding: 15px;' > " +
                            "<div class='row'>" +
                                    "<div class='col-md-2' style='text-align: left' >"+
                                    "<div class='col-md-3' style='text-align: left' >" +
                                        "<h4 style='padding: 0px'>"+result[i]"</h4>" +
                                        "<h5>"+result[i].title+"</h5>" +
                                    "</div>" +
                                    "<div class='col-md-3' style='text-align: center'> " +
                                        "<h4>Resolution method:</h4> " +
                                        "<h5>"+result[i].service_package.title+ " (" + result[i].service_package.default_price + " SGD)" +"</h5> " +
                                    "</div>" +
                                    "<div class='col-md-2' style='text-align: center'>" +
                                        "<h4>Not yet assigned</h4>" +
                                    "</div>" +
                                    "<div class='col-md-2' style='text-align: center'>" +
                                        "<h4>New</h4> " +
                                        "<h5>"+result[i].created_at+"</h5>" +
                                    "</div>" +
                            "</div>" +
                        "</div>" +

In this blade page i have written the code to append the data


Route::get('showAllReqToAdmin', '[email protected]');

I am not getting any error,don't know where is the exact probelm with laravel 5.7 i am using jQuery and ajax,please help me

Please sign in or create an account to participate in this conversation.