, (*1)
Laravel Announcement
A package that simplifies the management of site-wide announcements. With "Laravel Announcement" you can display auto-expiring announcements., (*2)
Installation
1- composer require laravelhungary/announcement
- plz note that the package use predis/predis for all of its operation., (*3)
2- Add the followings to config/app.php, (*4)
'providers' => [
...
LaravelHungary\Announcement\PackageServiceProvider::class,
],
'aliases' => [
...
'Announce' => LaravelHungary\Announcement\Facades\Announce::class,
]
3- run php artisan vendor:publish and you will get, (*5)
/config/announcement.php
/views/vendor/announcement/alert.blade.php
/Events/NewAnnouncement.php
/components/Announcement-bootstrap.vue
/components/Announcement-sweetalert.vue
4- That's it., (*6)
if you need to broadcast the announcements through something like web-sockets please check Event Broadcasting, (*7)
Usage
Normal
Create Announcement
Announce::create($title, $message, $type, $ttl);, (*8)
Params
* title a short message., (*9)
For example: Breaking news!, (*10)
-
message A bit longer message.
For example: Our servers are under a DDoS attack. We are trying hard to mitigate it., (*11)
-
type Type of the announcement.
For example: success,info,danger,warning (or anything you would like to use) , Default is: info, (*12)
-
ttl When should the announcement expire. [Time to live] in seconds.
Default is: 60 seconds, (*13)
Display of Announcements
put {!! Announce::display() !!} anywhere you want your announcement to be visible., (*14)
===, (*15)
Broadcasting
Create Announcement
Announce::broadcast($title, $message, $type, $ttl, $transition, $channel_name);, (*16)
Params
* title,message,type,ttl same as the normal announcement, (*17)
-
transition what is animation type you want.
For example: fade , bounce, etc... Check Vue Transition , Default is: fade, (*18)
-
channel_name change it to override the config value "dont forget to also change it in the component file"
Default is: public-announcement-channel, (*19)
Display of Announcements
- note that the package doesnt care what driver you use
pusher or socket.io , it will just work 🍺.
- we also use VueJs 2, but if you want to use something else then ignore the below and you are free to build your own.
1- put Vue.component('my-announcement', require('./components/Announcement-bootstrap.vue')); into your app.js file, (*20)
2- put <my-announcement></my-announcement> anywhere you want this announcement to show up. For example: your layout.blade.php file, (*21)
if you want to use something like Animate.css follow Custom Transition Classes, (*22)
Package Maintainers
Buy us a coffee :)
, (*23)