PHP code example of 64robots / batch-notifications

1. Go to this page and download the library: Download 64robots/batch-notifications 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/ */

    

64robots / batch-notifications example snippets


class DocumentAssignedEmail extends Notification implements ShouldQueue
{
    use Queueable;

    /** @var Collection $eventables */
    private $eventables;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(Collection $eventables)
    {
        $this->eventables = $eventables;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        if ($this->eventables->count() == 1) {
            return (new MailMessage)->view('mail.documents-assigned', [
                'user' => $notifiable,
                'document' => $this->eventables->first(),
            ])->subject("New Document Assigned");
        }

        return (new MailMessage)->view('mail.documents-assigned', [
            'user' => $notifiable,
            'documents' => $this->eventables,
        ])->subject("New Documents Assigned");
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            //
        ];
    }
}