Download the PHP package rellix/dismissibles-for-laravel without Composer
On this page you can find all versions of the php package rellix/dismissibles-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rellix/dismissibles-for-laravel
More information about rellix/dismissibles-for-laravel
Files in rellix/dismissibles-for-laravel
Package dismissibles-for-laravel
Short Description A Laravel package for easily handling the visibility of dismissible, recurring objects like popups/notifications/modals on the server side.
License MIT
Informations about the package dismissibles-for-laravel
📣 Dismissibles for Laravel
A Laravel package for easily managing the visibility of your recurring, dismissible objects like popups/notifications/modals on the backend. This package does not include frontend components, so it's compatible with any frontend you can use.
📕 Table of Contents
- ✅ What problem does this solve?
- 📦 Installation
- ❓ How to use
- ❗ Good to know
- 💾 Database tables
- ☕ Buy me a coffee
✅ What problem does this solve?
Say you have a popup you want to show to every user, daily for a week. Users can dismiss it and it should not show up again for the rest of the day until the next day.
This packages handles the complex logic regarding whether the (dismissible) popup should be visible to the current user at the current moment. It basically handles the visibility of your dismissible. It's highly customizable, making it very flexible for many scenario's.
Because it's serverside we can easily get statistics like who dismissed what, when and where.
📦 Installation
-
Require the package in your Laravel application
- Run the migrations to create the database tables
❓ How to use
1. Add the interface and trait to any model
2. Create a dismissible (migration)
and run your created migration:
💡 You can also create/fetch a Dismissible inline using the "active"-scope and "firstOrCreate".
3. Check if it should be visible at the current moment
💡 You can also use the individual models.
4. Dismiss it for a specified period
💡 You can also use the individual models.
❗ Good to know
- The facade contains some oneliners by
$name
, but you can also use the scopes/methods in theDismissible
andDismissal
Eloquent models as you wish for ultimate flexibility. - It's recommended to centralize dismissible names in an enum (or config)
- Need extra data regarding the dismissal? All dismiss methods allow you to pass an
$extraData
array as last parameter which will be written to thedismissals
table as json. - Feel free to request more methods/scopes
💾 Database tables
The database structure allows you to easily track activity regarding dismissibles. Due to the extra_data
column it's also very flexible!
dismissibles (popups, notifications, modals)
id | name | active_from | active_until | created_at | updated_at |
---|---|---|---|---|---|
3 | Test Popup | 2024-03-01 00:00:00 | null | 2023-12-15 17:35:54 | 2023-12-15 17:35:54 |
dismissals (activity)
id | dismissible_id | dismisser_type | dismisser_id | dismissed_until | extra_data | created_at | updated_at |
---|---|---|---|---|---|---|---|
15 | 3 | App\Models\User | 328 | 2024-04-29 00:00:00 | "{\"route\":\"home.index\"}" | 2024-04-28 17:35:54 | 2024-04-28 17:35:54 |
☕ Buy me a coffee
If you like this package, consider buying me a coffee :-).