简体   繁体   English

为什么在Laravel中删除用户帐户时没有注销

[英]why did not logout when I delete user accounts in Laravel

I need redirect logout My app when user delete Accounts. 用户删除帐户时,我需要重定向注销我的应用程序。 using this UserController 使用此UserController

public function destroy($id) {
    $users = User::findOrFail($id);
    $users->delete();

    Auth::logout();

    return Auth::logout();
    //redirect()->back()->with('info','Your Account has beed deleted successfully');
}

My delete button is this in index.blade.php 我的删除按钮是index.blade.php中的这个按钮

<button class="btn btn-circle btn-danger delete"
                      data-action="{{ url('users/' . $use->id) }}"
                      data-token="{{csrf_token()}}">
                <i class="fa fa-trash-o"></i>Delete
</button>

how can I fix this? 我怎样才能解决这个问题?

updated answer 更新的答案

 @if(isset($users))
                        @foreach($users as $use)
                        <h1>{{$use->username}}</h1>
                        <h1>{{$use->email}}</h1>
                        @endforeach
                        @endif

Try this it will work for you: 试试这个,它将为您工作:

<button class="btn btn-circle btn-danger delete"
   data-action="{{url('users')}}/{{$use->id}}"
   data-token="{{csrf_token()}}">
  <i class="fa fa-trash-o"></i>Delete
</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM