PHP code example of susheelbhai / laratsapp

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

    

susheelbhai / laratsapp example snippets


use Susheelbhai\WhatsApp\Support\MockInbox;

MockInbox::all();          // captured messages (newest first)
MockInbox::find($id);      // one message
MockInbox::delete($id);    // delete one
MockInbox::markRead($id);  // mark read
MockInbox::clear();        // empty the inbox

  php artisan vendor:publish --tag="whatsapp" --force 
  

$data = [
            'phone' => '9999999999',
            'message' => 'message content'
        ];
WhatsApp::sendText($data);

$data = [
            'phone' => '9999999999',
            'message' => 'otp'
        ];
WhatsApp::sendOTP($data);

$data = [
            'phone' => '9999999999',
            'message' => 'message content',
            'media_url' => 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
        ];
WhatsApp::sendMedia($data);

public function via(object $notifiable): array
    {
        $channels = [];
        if (config('mail.send_mail') == 1 && isset($notifiable->email)) {
            $channels[] = 'mail';
        }
        if (config('whatsapp.send_msg') == 1 && isset($notifiable->phone)) {
            $channels[] = 'whatsapp';
        }
        return $channels;
    }

 public function toWhatsAppOTP($notifiable)
    {
        return '223344';
    }