A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

Related tags

Laravel alert
Overview

Alert Box (Laravel)

A helper package to flash a bootstrap alert to the browser via a Facade or a helper function.

<div class="alert alert-info fade in">
	<i class="fa-fw fa fa-smile-o"></i>
	<strong>Title</strong> Description
</div>

###Want to see the current package in action, have a look at my starter project. ###Laravel Starter Project

Installation

First, pull in the package through Composer.

"require": {
	"bpocallaghan/alert": "1.*"
}

OR

composer require bpocallaghan/alert

Include the service provider within config\app.php.

'providers' => [
	Bpocallaghan\Alert\AlertServiceProvider::class,
];

Add a facade alias or use the globel helper function alert().

'aliases' => [
	'Alert' => Bpocallaghan\Alert\Facades\Alert::class,
];

Usage

Within any view file.

@include('alert::alert')

Within any Controller.

public function index()
{
    // helper function - default to the 'info'
	alert('Title', 'Lorem Ipsum');

	// return object first
	alert()->info('Title', 'Lorem Ipsum');

	// via the facade
    Alert::info('Title', 'Lorem Ipsum');

	return view('home');
}

The different 'levels' are:

  • alert()->info('Title', 'Lorem Ipsum');
  • alert()->success('Title', 'Lorem Ipsum');
  • alert()->warning('Title', 'Lorem Ipsum');
  • alert()->danger('Title', 'Lorem Ipsum');

The different arguments:

  • alert()->info('Title', 'Lorem Ipsum', false); // without the icon
  • alert()->info('Title', 'Lorem Ipsum', 'smile-o'); // specify the icon class
  • alert()->message('Title', 'Lorem Ipsum', 'smile-o', 'info'); // specify the type of level
  • alert()->message('Title', 'Lorem Ipsum', 'smile-o', 'info', false); // do not show the 'close' button

If you need to modify the view partial, you can run:

php artisan vendor:publish --provider="Bpocallaghan\Alert\AlertServiceProvider"

The view partial can be found here resources\views\vendor\alert\alert.blade.

TODO

  • Add an autohide / timeout option

Tank you

Note

Please keep in mind this is for my personal workflow and might not help you. I developed this to help speed up my day to day workflow. Thank you for understanding.

My other Packages

You might also like...
Laravel Dusk provides simple end-to-end testing and browser automation.

Introduction Laravel Dusk provides an expressive, easy-to-use browser automation and testing API. By default, Dusk does not require you to install JDK

In-browser console for Laravel PHP framework.
In-browser console for Laravel PHP framework.

Laravel 4 Console In-browser console for Laravel 4 PHP framework. This bundle executes your code within ConsoleController@postExecute context, and dis

Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css. Requires Livewire and AlpineJS.

Laravel Livewire Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size W

View your Laravel routes on the browser.
View your Laravel routes on the browser.

View your Laravel routes on the browser. This package adds a route to your Laravel application. Once you've installed this package, enter /route-list

Intranet Home Page is a highly-configurable self-hosted browser homepage with integrations for public and local data feeds.
Intranet Home Page is a highly-configurable self-hosted browser homepage with integrations for public and local data feeds.

Intranet-Home-Page Created in response to personal "dashboards" that are little more than pages with a list of frequently accessed links, Intranet Hom

Laravel Abdal Detector - Find info about IP , OS and web browser from your client

Laravel Abdal Detector - Find info about IP , OS and web browser from your client

File & Folders & Media Browser With Code Editor
File & Folders & Media Browser With Code Editor

Filament Browser File & Folders & Media Browser With Code Editor Features File Browser Code Editor with highlights Media Viewer .Env Editor Screenshot

How to get cookies from users' browser and send the information to your email address and telegram bot

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Laravel UI, Auth, & CRUD scaffolding package using Bootstrap & Livewire.
Laravel UI, Auth, & CRUD scaffolding package using Bootstrap & Livewire.

bastinald/ux Laravel UI, Auth, & CRUD scaffolding package using Bootstrap & Livewire. Features Automatic migrations Automatic routing Automatic passwo

Comments
  • added functionality to pass 1 extra parameter to alert() function tha…

    added functionality to pass 1 extra parameter to alert() function tha…

    …t allows the user to limit the alert to the associated request. The reason for the suggested change is due to a problem I encountered where the session key alert.title etc persists over multiple request. I tried to pass the actual request instance but this seems to be inherent to the flash() function. The solution I found in this thread: https://stackoverflow.com/questions/24579580/laravel-session-flash-persists-for-2-requests

    opened by Sylver11 0
Releases(1.2.2)
Owner
Ben-Piet O'Callaghan
Full Stack Developer at GDC Media and Laravel Developer at Bookamat
Ben-Piet O'Callaghan
A package to flash multiple messages using Laravels default session message flashing system

Flash multiple advanced messages with both text, messages and links An opinionated solution for flashing multiple advanced messages from the backend a

Bilfeldt 6 Jan 18, 2022
Laravel 5 Flash Notifications with icons and animations and with a timeout

Notify (Laravel) Notify alert boxes to the browser with sound and font awesome icons and give it a timeout to fly out. Works great to notify the user

Ben-Piet O'Callaghan 31 Oct 8, 2022
🔔 Flasher is a powerful and flexible flash notification system for PHP, Laravel, Symfony

A powerful and flexible flash notifications system for PHP, Laravel, Symfony ?? PHP Flasher helps you to add flash notifications to your PHP projects.

PHP Flasher 158 Jan 4, 2023
Cache-purge-helper - Additional instances where nginx-helper and lscache plugin should be purged.

cache-purge-helper Additional instances where nginx-helper and lscache plugin should be purged. Install Extract the zip file. Upload them to /wp-conte

Jordan 10 Oct 5, 2022
Laravel SEO - This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

ARCHTECH 191 Dec 30, 2022
Laravel package for giving admin-created accounts to users via 'set-password' email.

Invytr When making a website where users are created instead of registering themselves, you are faced with the challenge of safely giving users the ac

GlaivePro 64 Jul 17, 2022
An easy way to get vendor and package data from Packagist via API calls

Laravel Packagist Laravel Packagist (LaravelPackagist) is a package for Laravel 5 to interact with the packagist api quickly and easily. Table of cont

Jeremy Kenedy 5 Jul 18, 2022
LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

Tyler Arbon 437 Nov 17, 2022
Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Tina Hammar 7 Nov 23, 2022
Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Jameson Lopp 28 Dec 19, 2022