1. 의존성 설치

composer require realrashid/sweet-alert



2. 마스터 레이아웃에 넣는다.

@include('sweetalert::alert')

3. 터미널에서 입력한다. vendor에서 public로 복사

php artisan vendor:publish --provider="RealRashid\SweetAlert\SweetAlertServiceProvider"


4.아래소스를 해당 controller 에 삽입한다.

use RealRashid\SweetAlert\Facades\Alert;


5. 넣은 위치에 다가 아래의 소스를 삽입한다.

Alert::success('저장', '저장이 완료 되었습니다.');


6.요런 신박한 것!



7. 필요한 레이아웃을 골라사용하자.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 Alert::alert('Title', 'Message', 'Type');
 
 Alert::success('Success Title', 'Success Message');
 
 Alert::info('Info Title', 'Info Message');
 
 Alert::warning('Warning Title', 'Warning Message');
 
 Alert::error('Error Title', 'Error Message');
 
 Alert::question('Question Title', 'Question Message');
 
 Alert::image('Image Title!','Image Description','Image URL','Image Width','Image Height');
 
 Alert::html('Html Title', 'Html Code', 'Type');
 
 Alert::toast('Toast Message', 'Toast Type');
cs



info


warning


error


question


image

htmlcode


toast



▶패스워드변경완료 경고창 설정

\vendor\laravel\framework\src\Illuminate\Auth\Notifications\ResetPassword.php

or

/vendor/laravel/framework/src/Illuminate/Foundation/Auth/ResetsPasswords.php

1
2
3
4
5
6
7
8
9
10
11
12
    protected function resetPassword($user, $password)
    {
        $user->password = Hash::make($password);
 
        $user->setRememberToken(Str::random(60));
 
        $user->save();
 
        event(new PasswordReset($user));
        Alert::success('비밀번호 변경 완료', '');
        $this->guard()->login($user);
    }
cs



▶패스워드 재설정 이메일 보내고 경고창 설정

\vendor\laravel\framework\src\Illuminate\Auth\Notifications\SendsPasswordResetEmails.php

or

/vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    public function sendResetLinkEmail(Request $request)
    {
        $this->validateEmail($request);
 
        // We will send the password reset link to this user. Once we have attempted
        // to send the link, we will examine the response then see the message we
        // need to show to the user. Finally, we'll send out a proper response.
        $response = $this->broker()->sendResetLink(
            $this->credentials($request)
        );
         Alert::success('이메일 전송 완료', '재설정 이메일을 확인해 주세요.');
        return $response == Password::RESET_LINK_SENT
                    ? $this->sendResetLinkResponse($request, $response)
                    : $this->sendResetLinkFailedResponse($request, $response);
    }
cs





+ Recent posts