PHP code example of digitalcloud / multilingual-notification

1. Go to this page and download the library: Download digitalcloud/multilingual-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/ */

    

digitalcloud / multilingual-notification example snippets




namespace App;

use Digitalcloud\ReactiveNotification\Traits\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;
}



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Digitalcloud\ReactiveNotification\Channels\DatabaseChannel;

class InvoicePaid extends Notification implements ShouldQueue
{
    use Queueable;

    public function via($notifiable)
    {
        return [DatabaseChannel::class,'.../'];
    }
    
    
    public function toDatabase($notifiable){
        return [
          "title"=> trans("invoice_title"),
          "details"=> trans("invoice_details"),
        ];
    }
}

$user->notify(new InvoicePaid($invoice));

\App::setLocale("en");
$result = $user->notifications()->first()->data;

\App::setLocale("ar");
$result = $user->notifications()->first()->data;
bash
php artisan vendor:publish --provider="Digitalcloud\ReactiveNotification\ReactiveNotificationServiceProvider"
bash
php artisan migrate