AbdulBazith
1 year ago
5882
13
Laravel

How to use sweet alert in laravel?

Posted 1 year ago by AbdulBazith

guys iam working with a project

iam using flash message in my controller

this is my controller

Session::flash('success','Location Data Entered succesfully');

 return redirect()->route('Location_details.create');

this is my message

@if(Session::has('success'))

<div class="alert alert-success">

<strong>Success: </strong>{{ Session::get('success') }}

</div>

@endif

But now i need to use sweet alert instead of flash messages.

How to use that,

i did this


composer require uxweb/sweet-alert


'providers' => [

    ....

    UxWeb\SweetAlert\SweetAlertServiceProvider::class,

],

'aliases' => [

    ....

    'Alert' => UxWeb\SweetAlert\SweetAlert::class,

]


And atlast i changed my controller to

  Alert::message('Location data entered succesfully!');

            return redirect()->route('Location_details.create');

in the header i added

use Alert

But its not working.

whats the problem how can i use sweet alerts in my controller

Kindly some one suggest

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