Giter Club home page Giter Club logo

alert's Introduction

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

alert's People

Contributors

bpocallaghan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.