Skip to content

airoinfo/laravel-alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel-alert

This package is base on Laravel Framwork 、Vue and Element UI also optional support vue-notification Easy to create awesome notify view and Laravel Facade to call on backend

Install

Important make sure your larval project’s Vue and Element UI is working fine.

Use composer to install package

$ composer require airoinfo/laravel-alert

notice if your Laravel version is beyond 5.6, package’ll auto register ServiceProvider to app.php. But if your version is above 5.6, you’ve to register by yourself.

config/app.php

'provider' => [
	// package ServiceProvider
	Airo\Alert\AlertServiceProvider::class,
]
'alias' => [
	'Alert' => Airo\Alert\AlertFacade::class,
]

Setup

1. Published vendor

In this package, we already provide blade and Vue component. You can use it by default, or also create your own to catch the message

Publish View Blade to resource\vendor\notify

$ php artisan vendor:publish --tag=views --force

Publish Vue component to resource\js\components

$ php artisan vendor:publish —-tag=components --force

2. Register your Vue component

e.g resource\js\app.js

Vue.component('notify-component', require('./components/NotifyComponent.vue'));

3. Include notify blade to your layout

e.g views\layouts\app.blade.php

@include('alert::notify')

4. Use it in Controller

use Airo\Alert\AlertFacade;
class HomeController
{
	public function login()
	{
		//when Login success
		Alert::success(['message1', 'message2', '...']);

		//when login fail
		Alert::errors(['message1', 'message2', '...']);
	}
}