Download the PHP package tadasei/backend-trashable-notifications without Composer
On this page you can find all versions of the php package tadasei/backend-trashable-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tadasei/backend-trashable-notifications
More information about tadasei/backend-trashable-notifications
Files in tadasei/backend-trashable-notifications
Package backend-trashable-notifications
Short Description A package that provides stubs for soft deletable database notifications support
License MIT
Informations about the package backend-trashable-notifications
Tadasei/backend-trashable-notifications
This package provides stubs for managing trashable (soft deletable) database notifications in the backend of a Laravel application. It simplifies common Index, Store, Update, and Delete notification operations by providing pre-defined structures.
Features
- Quickly generate trashable database notifications management files and handling logic.
- Customize and extend generated code to fit your project's needs.
- Improve development efficiency by eliminating repetitive tasks.
Installation
Install the package via Composer by running:
Usage
Publishing Trashable Notifications Management Utilities
To publish the utilities, including the supervisord configuration files, run:
This command generates all necessary files, including:
- Notification-related form requests.
- Policies for managing trashable notifications.
- A custom
Notifiable
trait. - Route files for notification management.
- Database migration files.
- Supervisord configuration files for production queue management.
Configuration
After publishing the utilities, follow these steps to complete the configuration:
-
Form Request Configuration: Modify the generated form request (
App\Http\Requests\SendNotificationRequest
) to suit your application's validation rules and logic. -
Policy Configuration: Update the generated policy (
App\Policies\DatabaseNotificationPolicy
) to control access to notification management operations, ensuring it aligns with your project's authorization system. -
Notifiable Trait Replacement: The package provides a custom
Notifiable
trait, which will be published along with the other management utilities. You must replace the built-in LaravelNotifiable
trait with this one in your desired notifiable models. For example:This ensures that your models properly handle trashable notifications.
-
Routes Registration: The
routes/resources/notification.php
file is generated as part of the management utilities. You must register this file in your application's built-inroutes/web.php
orroutes/api.php
to make the package routes available. For example, inroutes/api.php
:The generated routes are protected by the
auth:sanctum
middleware by default. If your project uses a different authentication guard, you may need to update the middleware to fit your authentication system. - Running the Migration: The package generates a migration as part of the utilities. You need to run this migration to set up the necessary database structure for managing trashable notifications. Use the following Artisan command:
These steps are necessary to ensure that the package integrates smoothly with your application's existing structure.
Using Supervisord Configuration Files in Production
The supervisord configuration files, generated by the php artisan trashable-notifications:install
command, are essential for managing queues in production.
-
Copy the Configuration Files:
Move the generated.conf
files to the/etc/supervisor/conf.d
directory in your production server. This allowssupervisord
to pick up the configuration and manage your processes as defined in the files. - Learn More About Supervisor:
For further details on how to configure and manage Laravel queues with Supervisor, refer to the Laravel documentation on Supervisor configuration.
Managing Log Files in Production
When using the package in production, log files generated by the supervisord configuration files must be excluded from source control to prevent unnecessary clutter in your versioning system.
Each generated supervisord configuration file has a name format:
To exclude the associated log files, perform the following steps:
-
Transform the Configuration File Name:
Remove the<app_name_in_lower_snake>_
prefix and replace the.conf
extension with.log
, adding an asterisk (*
) at the end. For example:- If the configuration file is
my_app_worker.conf
, the corresponding log file would beworker*.log
.
- If the configuration file is
- Update Your
.gitignore
:
Add the transformed file name to your.gitignore
file. For the above example, your.gitignore
entry would look like this:
This ensures that log files generated in production do not get included in your source control repository.
Further Customization
The generated code serves as a starting point. You can further extend and customize it to fit your project’s needs.
Contributing
Contributions are welcome! If you have suggestions, bug reports, or feature requests, please open an issue on the GitHub repository.
License
This package is open-source software licensed under the MIT license.
All versions of backend-trashable-notifications with dependencies
illuminate/console Version ^9.0|^10.0|^11.0
illuminate/filesystem Version ^9.0|^10.0|^11.0
illuminate/support Version ^9.0|^10.0|^11.0
illuminate/validation Version ^9.0|^10.0|^11.0