listeners/SendSmsFired.php

use App/Event/SendSms;

public function handle(SendSms $event)
    {     
        $ch = curl_init(Config('sms.dialogmobile.api_url').'&destination='.$event->destination.'&message='.$event->message);

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        $out = curl_exec($ch);
        curl_close($ch);

        return $out;
    }



app/events/SendSms.php

  public function __construct($destination, $message)
    {
        $this->destination = $destination;
        $this->message = $message;
    }

    public function broadcastOn()
    {
        return [];
    }

EventServiceProvider

listner array

'App\Events\SendSms' => [
            'App\Listeners\SendSmsFired',
        ],



use Event;
use App\Event\SendSms;

Event::fire(new SendSms($mobile, urlencode($smsmessage)));

Comments

Popular posts from this blog

Laravel with MongoDB CURD operations - part 2

Laravel with MongoDB CURD operations - part 1

Laravel with MongoDB CURD operations - part 3