1. Go to this page and download the library: Download usenoty/noty-laravel 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/ */
usenoty / noty-laravel example snippets
use Noty\Laravel\NotyMessage;
NotyMessage::create('Order Created')
->message('Order #1234 has been created')
->channel('orders')
->priority(NotyMessage::PRIORITY_HIGH)
->action('View Order', route('orders.show', 1234), true)
->tag('order_id', 1234)
->tag('amount', 99.99)
->emoji('🛒')
->send();
namespace App\Notifications;
use Illuminate\Notifications\Notification;
class UserLoggedIn extends Notification
{
public function __construct(private $user) {}
public function via($notifiable)
{
return ['noty'];
}
public function toNoty($notifiable)
{
return [
'title' => 'User logged in: ' . $this->user->email,
'message' => 'User logged in from IP: ' . request()->ip(),
'channel' => 'auth',
'priority' => 'HIGH',
'actions' => [
[
'name' => 'View Profile',
'url' => route('users.show', $this->user),
'browser' => true
]
],
'tags' => [
'ip_address' => request()->ip(),
'user_id' => $this->user->id,
]
];
}
}