Skip to content
Emeka Mbah edited this page May 20, 2023 · 9 revisions

Sticky Alert

The type of alert sticks to the page throughout page refreshes or on different pages until its forget method is called.

Features

Sticky title

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 />

Sticky message

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()

Sticky Action Button

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();
image

Sticky levels

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();

Sticky Forget

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');

Examples

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

image

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');
    }
}
Clone this wiki locally