-
Notifications
You must be signed in to change notification settings - Fork 4
Sticky
Emeka Mbah edited this page May 20, 2023
·
9 revisions
The type of alert sticks to the page throughout page refreshes or on different pages until its forget method is called.
If you prefer to add a title to Sticky, call the title method
In the application
Alert::sticky('Your subscription has expired and we are unable to charge your credit card')
->title('Billing')
->flash();
In the blade
<x-alert-sticky />
You can pass a message directly in the sticky method
Alert::sticky('Your subscription has expired and we are unable to charge your credit card')
->flash()
or via the message method
Alert::sticky()
->message('Your subscription has expired and we are unable to charge your credit card')
->flash()
Sometimes we want to have an action button on the sticky.
Alert::modal('Your subscription has expired and we are unable to charge your credit card')
->title('Billing')
->action('Pay', route('billing.subscriptions.payment'))
->flash();
The sticky level is the color of the sticky title. Choose from any of the following.
Alert::sticky(...)->primary();
Alert::sticky(...)->secondary();
Alert::sticky(...)->success();
Alert::sticky(...)->info();
Alert::sticky(...)->error();
Alert::sticky(...)->warning();
Alert::sticky(...)->light();
Alert::sticky(...)->dark();
Since Stickies are very persistent, you can use the forget method to remove when necessary.
This will remove an untagged sticky
Alert::stickForget();
This will remove a sticky tagged billing
Alert::stickForget('billing');
In the application
Alert::sticky('Your subscription has expired and we are unable to charge your credit card')
->title('Billing')
->action('Pay', '/billing/subscription/payment')
->tag('billing')
->warning()
->flash();
Alert::sticky('Your trial period will expire in 4 days')
->title('Membership')
->action('Upgrade', '/memberships/upgrade')
->tag('membership')
->info()
->flash();
In the blade
<x-alert-sticky tag="billing" />
<x-alert-sticky tag="membership" />
Result
Somewhere later, ideally, after a successful action
<?php
namespace App\Http\Controllers;
use Digitlimit\Alert\Facades\Alert;
class BillingController extends Controller
{
public function payment()
{
// payment completed
// etc
Alert::stickyForget('billing');
}
}