azhovan/sms1000

SMS1000 Notifications channel for Laravel

v0.1 2019-02-11 18:32 UTC

This package is auto-updated.

Last update: 2021-11-13 21:35:42 UTC


README

This implementation is just for sms10000.

How to install

download it with composer like : composer require azhovan/sms1000 Or

{
      "require": {
        "azhovan/sms1000": "^0.1"
    }
}
  1. Add to service provider list (config/app.php)
'providers' => [

...

\Sms1000\SmsChannelServiceProvider::class

...
...

]
  1. add configuration (config/services.php)
 'sms' => [
        'username' => env('SMS1000_USER'),
        'password' => env('SMS1000_PASSWORD'),
        'local' => 'farsi',
        'url' => 'https://sms1000.ir/url/send.aspx',
        'from' => env('SMS1000_FROM')
    ]

3.Add credential to your .env file

SMS1000_USER=
SMS1000_PASSWORD=
SMS1000_FROM=
  1. finally, configure the Notifiable. you need to specify routeNotificationForSms function at your Notifiable model
 /**
     * Route notification for sms
     *
     * @param \Illuminate\Notifications\Notification $notification
     * @return mixed
     */
    public function routeNotificationForSms($notification)
    {
        return $this->mobile;
    }

Usage

Now you can use the channel in your via() method inside the notification:

use Sms1000\Channels\SmsChannel;
use Sms1000\Messages\SmsMessage;

class AccountApproved extends Notification
{
   /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return SmsMessage
     */
    public function toSms($notifiable)
    {
        return  (new SmsMessage)
            ->content('put your text here')
            ->from(config('services.sms.from'));
            ->to(...)
    }
    
    
    ...
}

you can also use toSms function like below:

  public function toSms($notifiable)
    {
        return  'your text here';
    }