PHP code example of alhoqbani / laravel-mobily-ws-notification

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

    

alhoqbani / laravel-mobily-ws-notification example snippets


        NotificationChannels\MobilyWs\MobilyWsServiceProvider::class,


// config/mobilyws

    // Authentication mode
    'authentication' => 'auto',
    
    // Set yor login credentials to communicate with mobily.ws Api
    'mobile' => env('MOBILY_WS_MOBILE'),
    'password' =>  env('MOBILY_WS_PASSWORD'),
    
    // Or use the generated apiKey from your mobily.ws account
    'apiKey' => env('MOBILY_WS_API_KEY'),
    
    // Name of Sender must be approved by mobily.ws
    'sender' => env('MOBILY_WS_SENDER'),



namespace App\Notifications;

use Illuminate\Notifications\Notification;
use NotificationChannels\MobilyWs\MobilyWsChannel;
use NotificationChannels\MobilyWs\MobilyWsMessage;

class UserRegistered extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [MobilyWsChannel::class];
    }
    
    /**
     * Get the text message representation of the notification
     *
     * @param  mixed      $notifiable
     * @param \NotificationChannels\MobilyWs\MobilyWsMessage $msg
     *
     * @return \NotificationChannels\MobilyWs\MobilyWsMessage|string
     */
    public function toMobilyWs($notifiable, MobilyWsMessage $msg)
    {
        return "Dear $notifiable->name, welcome to our website";
    }
}



    namespace App;

    use Illuminate\Notifications\Notifiable;
    use Illuminate\Foundation\Auth\User as Authenticatable;

    class User extends Authenticatable
    {
        use Notifiable;

        /**
         * Route notifications for the MobilyWs channel.
         *
         * @return string
         */
        public function routeNotificationForMobilyWs()
        {
            return $this->mobile;
        }
    }

use App\Notifications\UserRegistered;

$user = App\User::first();

$user->notify(new UserRegistered());

    public function toMobilyWs($notifiable)
    {
        return (new MobilyWsMessage)
            ->text("Message text")
            ->time(Carbon::parse("+1 week);
    }



use NotificationChannels\MobilyWs\MobilyWsMessage;
            //
    /**
     * Get the text message of the SMS.
     *
     * @param  mixed  $notifiable
     * @return \NotificationChannels\MobilyWs\MobilyWsMessage|string
     */
    public function toMobilyWs($notifiable)
    {
        return MobilyWsMessage::create("Text message");
    }

    public function toMobilyWs($notifiable, MobilyWsMessage $msg)
    {
        return $msg->text($this->message);
    }
bash
php artisan vendor:publish --provider="NotificationChannels\MobilyWs\MobilyWsServiceProvider"
bash
php artisan make:notification UserRegistered
bash
php artisan mobilyws:notification UserRegistered