我正在尝试获取管理员个人资料中的所有数据。在管理员页面上 他想查看所有用户的请求。 登录功能可在登录时进行角色检查
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 {
if($request->session()->has('request_cache')){
return $this->saveRequest($request);
} else {
return url('displayLegal');
}
}
return 'true';
}
return "false";
}
管理员将在其中登录的用户控制器,登录后将被重定向到仪表板,在该仪表板上他将看到所有用户的请求。
@section('content')
<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>
<div class="col-md-12" id="user_request_div">
</div>
<!--end .card -->
</div>
@endsection
@section('side_bar')
@include('backend_template.includes.side_bar')
@endsection
@section('jsses')
@include('frontend_template.includes.foot')
<script>
$.ajax({
url:"showAllReqToAdmin",
type:"POST",
data:{_token:csrf_token},
success: function (result) {
$('#user_request_div').html('');
console.log(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' >"+
"<h4>" +result[i].user.firstname "</h4>" +
"<h5>"+result[i].user.lastname"</h5>"+
"</div>"+
"<div class='col-md-3' style='text-align: left' >" +
"<h4 style='padding: 0px'>"+result[i].request_type.aop.name+"</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>" +
"</div>").appendTo('#user_request_div');
}
}
});
</script>
@endsection
在此刀片页面中,我编写了代码以附加数据
** Route.php **
Route::get('showAllReqToAdmin', 'UserController@showAllReqToAdmin');
我没有收到任何错误,不知道确切的位置 问题。