Download the PHP package abather/model-notification without Composer

On this page you can find all versions of the php package abather/model-notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package model-notification

Add notifications Template into Models

Latest Version on Packagist Total Downloads

This package helps you organized and save template messages for each model that included it. each message depends upon key, language, and channel.

Installation

You can install the package via composer:

You can publish and run the migrations with:

You can publish the config file with:

This is the contents of the published config file:

Override Global Configuration:

You can prevent including files for specific models if you wish by adding the variable prevent_including_file in the model:

If you want to use specific file variables for the model, you can add the file_variables variable:

Usage

You can use this package with any Model by implementing the Notifier interface and using the Notifier trait:

Now you can create, call, or update message templates as described below.

Create new template for a model:

To create a new template for any model, you can use the makeTemplateMessage() method. You must specify key, lang, channel, and template:

Including variables in the template text:

The template() method can include any attribute present in the model. The attribute value will replace the attribute name. For example, [amount] will retrieve the value of the attribute named amount. To change the symbols representing the variable names, you can modify the variable_starter and variable_ender in the config file.

Including attributes from relationships:

The template() method can also include values from supported relationships, such as [user->name]. It behaves like including attributes and supports belongsTo and hasOne relationships.

Including file path in the template text:

You can include the file URL in the template by adding any key defined in the config("model-notification.file_variables") or defined in the model $file_variables. Additionally, you need to use includeFile() when creating the template message:

You can change the URL returned by overriding the getFilePath() method in your model.

Adding extra data for the template message:

You can pass any extra data to prob([$key => $value]). Each value will go through the same process as the template to replace the attributes with data for attributes, relationship attributes, or file URLs.

Getting Template Messages:

You can use the getTemplateMessages() method to get all messages related to the model:

If you want to get messages for a specific channel, language, or key, you can use the forChannel($channel), forLang($lang), or forKey($key) scopes with the notificationTemplates() query builder:

This will return a collection of NotificationTemplate.

If you want to get a specific Template Message, you can use the getTemplateMessage method by passing key, lang, and channel:

This method will return a NotificationTemplate instance.

If you want to get the text message, you can use the getTemplateMessageText() method by passing key, lang, and channel:

This will return a string ready to use with your notification, with all variables, relationship variables, and file paths replaced.

To get prob for a specific template, you can use the getTemplateMessageProb() method and pass key, lang, and channel:

This will return an array with each prob ready to use and handled. If you want to get the value of a specific prob, you can pass a fourth parameter, prob:

This will return a string of the value of the given prob or an empty string if it does not exist.

If the file is included with the template, you can get the file URL or the file object by using the () method and passing key, lang, and channel:

This will return the file URL. If you want to get the file parameter, you have to pass a fourth parameter as false:

This will return a file parameter. Keep in mind that you have to configure the getFileObject() method inside your model.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of model-notification with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package abather/model-notification contains the following files

Loading the files please wait ....