如何发出警报通知

时间:2019-01-17 02:41:38

标签: laravel-5 bootstrap-4

如何使用Bootstrap 4或Javascript发出警报通知。这是我的代码:

public function loginprocess(Request $request) {

    $user = Auth::attempt([
        'email' => $request->email,
        'password' => $request->password
    ]);

    if ($user) {
        if (Auth::user()->role == UserRole::JOB_APPLICANT) {
            return redirect('/');
        } else {
            return redirect('/admin');
        }
    }else{
        return 'Wrong password or this account not approved yet.'; 
        return redirect()->back();
    }

不好。

1 个答案:

答案 0 :(得分:0)

创建新的通知刀片文件并尝试以下代码(注意:请在您的视图文件中包含notification.blade.php)

    @if (count($errors) > 0)
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span>x</span>
        </button>
        @foreach ($errors->all() as $error)
            <span>{{ $error }}</span><br>
        @endforeach
    </div>
@endif

@if(session()->has('message'))
    <div class="alert alert-success">        
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span>x</span>
        </button>        
        <span data-notify="message">{{ session('message') }}</span>
    </div>
@endif