Multiple Sender ID use case
Closed this issue · 3 comments
As I've multiple sender ID in my textlocal account, I want to use these sender ID dynamically when sending SMS. How to achieve this with this package by using TextLocal as default SMS Gateway.
Thanks.
@mohdfayeem
In the config/sms.php
file add another configuration for Text Local. And add a handler map for that custom driver to TextLocal class.
'drivers' => [
...
'backup' => [...]
...
],
'map' => [
...
'backup' => \Tzsk\Sms\Drivers\Textlocal::class,
...
],
// Now send using
Sms::via('backup')->send("Hello")->to([******])->dispatch();
Keep the backup
driver settings the same as textlocal with your necessary changes.
Thanks for your help. It really helpful.
For the record, if one wants to have dynamic configuration that doesn't require to edit config, the Tzsk\Sms\Sms class accepts config as constructor parameter.
You need to create your own App\Channels\SmsChannel
:
(new Sms($smsOptions))
->send($msg)
->to([$phone])
->dispatch();
You can them store your custom $smsOptions in the options column of your businesses table or equivalent.