PHP code example of abather / model-notification

1. Go to this page and download the library: Download abather/model-notification library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

abather / model-notification example snippets


return [
    "fallback_lang" => env("MODEL_NOTIFICATION_FALLBACK_LANG", "ar"),

    "variable_starter" => "[",

    "variable_ender" => "]",

    "relationship_variable_symbol" => "->",

    "file_name" => "file",

    "prevent_including_file" => false,

    "file_variables" => [
        "file",
        "file_path",
        "attachment"
    ]
];

public static $prevent_including_file = true;

public static $file_variables = ["document"];

namespace App\Models;

use Abather\ModelNotification\Contracts\Notifier;
use Illuminate\Database\Eloquent\Model;

class Bill extends Model implements Notifier
{
    use \Abather\ModelNotification\Notifier;
}

Bill::makeTemplateMessage()
    ->key("new")
    ->channel("sms")
    ->lang("ar")
    ->template("You have a new bill [id], with an amount of: [amount]")
    ->save();

Bill::makeTemplateMessage()
    ->

Bill::makeTemplateMessage()
    ->prob(["title" => "New bill generated with number [id]", "icon" => "bill"]);

Bill::getTemplateMessages();

Bill::notificationTemplates()
    ->forChannel("sms")
    ->forLang("ar")
    ->get();

Bill::getTemplateMessage("anyKey", "ar", "sms");

Bill::getTemplateMessageText("anyKey", "ar", "sms");

Bill::getTemplateMessageProb("anyKey", "ar", "sms");

Bill::getTemplateMessageProb("anyKey", "ar", "sms", "title");

Bill::getFile("anyKey", "ar", "sms");

Bill::getFile("anyKey", "ar", "sms", false);
bash
php artisan vendor:publish --tag="model-notification-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="model-notification-config"