PHP code example of nguyentrigiang / laravel-notification

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

    

nguyentrigiang / laravel-notification example snippets


namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use GiangNT\LaravelNotification\HasPlayer;
use GiangNT\LaravelNotification\HasConfiguration;
use GiangNT\LaravelNotification\InteractsWithPlayer;
use GiangNT\LaravelNotification\InteractsWithConfiguration;
use Illuminate\Notifications\Notifiable;

class User extends Model implements HasPlayer, HasConfiguration
{
    use InteractsWithPlayer, InteractsWithConfiguration, Notifiable;
}

use GiangNT\LaravelNotification\BaseNotification;

class UserRegisted extends BaseNotification
{
}

use App\Notifications\InvoicePaid;

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

$user = App\Models\User::find(1);

foreach ($user->notifications as $notification) {
    echo $notification->type;
}

$user->addPlayer('5ea79c81-327f-4d8b-98b1-58dbd22a277b');
$players = $user->players;
$user->deletePlayer('5ea79c81-327f-4d8b-98b1-58dbd22a277b');
$user->clearPlayer();

$data = [
    'start_time' => '5:00',
    'end_time' => '21:59',
    'days_of_the_week' => ['Monday', 'Tuesday']
];
$user->addConfiguration($data);
$user->resetConfiguration();

php artisan migrate
sh
php artisan vendor:publish --tag=config
sh
php artisan make:notification InvoicePaid