PHP code example of vrajroham / laravel-flock-notification
1. Go to this page and download the library: Download vrajroham/laravel-flock-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/ */
vrajroham / laravel-flock-notification example snippets
public function routeNotificationForFlock()
{
return $this->flock_webhook_url;
}
use Vrajroham\LaravelFlockNotification\FlockChannel;
use Vrajroham\LaravelFlockNotification\FlockMessage;
use Illuminate\Notifications\Notification;
class OderCreated extends Notification
{
public function via($notifiable)
{
return [FlockChannel::class];
}
public function toFlock($notifiable)
{
return FlockMessage::create()
->content('Order created')
->attachments(function ($attachment) {
$attachment->title('View order')
->description('Order description')
->color('#fff000');
});
}
}
// Only 'src' field is mandatory.
[
[
'src' => 'https://vrajroham.me/dl/vrajroham_cv.pdf',
'mime' => 'application/pdf',
'filename' => 'CV.pdf',
'size' => 2000 //bytes
],
...
]
public function toFlock($notifiable)
{
return FlockMessage::create()
->content('This is text notification.');
}
public function toFlock($notifiable)
{
return FlockMessage::create()
->content('This is text notification.')
->sendAs("Vaibhavraj", 'https://avatars1.githubusercontent.com/u/12662173?s=460&v=4');
}
public function toFlock($notifiable)
{
return FlockMessage::create()
->attachments(function ($attachment){
$attachment->title('This is error message.')
->color('#FF0000'); //Red
});
}
public function toFlock($notifiable)
{
return FlockMessage::create()
->notification('You have important message')
->content('This is text notification.');
}
public function toFlock($notifiable)
{
return FlockMessage::create()
->attachments(function ($attachment){
$attachment->title('Website as widget')
->views(function ($view){
$view->widget('https://vrajroham.me', 400, 400);
});
});
}