LaravelPackages.net
Acme Inc.
Toggle sidebar
airoinfo/laravel-alert

A simple PHP package to show alerts with the Laravel Framework and Vue

419
0
2.0.2
About airoinfo/laravel-alert

airoinfo/laravel-alert is a Laravel package for a simple php package to show alerts with the laravel framework and vue. It currently has 0 GitHub stars and 419 downloads on Packagist (latest version 2.0.2). Install it with composer require airoinfo/laravel-alert. Discover more Laravel packages by airoinfo or browse all Laravel packages to compare alternatives.

Last updated

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', '...']);
	}
}
Comments