mody / smsprovider
config your sms gateway provider and start sending sms
Installs: 115
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Language:Blade
Type:package
Requires
- php: >= 5.3.0
README
Introduction
/*
* smsprovider package provides multiple connection with many sms providers.
* just set your provider configuration and start sending messages.
*
* two officially plans:
* [user, group]
* user plan is one user provider, that works only for one user [authenticated user].
* group is multiple user provider, that services a company users maybe,
* that shares the same sms provider.
*
* with group plan, your providers will have an account id number column.
* when calling your SMSProvider::configProvider() method,
* you will need this session to be set: session()->put('group_id', $group_id);
*
* username is your name columns to be displayed.
* if track is true, activities will be saved in sms_provider_track_activity table.
* user_model_namespace is your auth model. used in relationship with track table.
*
* package will create five tables .
* [
* 'sms_providers' => 'container of providers you have',
* 'sms_providers_additional_params' => 'necessary parameters we need for sending sms',
* 'sms_provider_messages' => 'messages you sent either success of failed with error codes',
* 'sms_direct_messages' => 'template messages you created for quick sending'
* 'sms_provider_track_activity' => 'track user activity while using package methods'
* ]
*/
Installation
composer require mody/smsprovider
after installation, do this:
1. config/app.php
a. service provider
mody\smsprovider\SMSGatewayServiceProvider::class,
b. alias
'SMSProvider' => mody\smsprovider\Facades\SMSProvider::class,
2. clear cache
php artisan config:cache
3. publish assets
php artisan vendor:publish
and you may see options, choose this one:
Provider: mody\smsprovider\SMSGatewayServiceProvider
4. config/smsgatewayConfig.php
choose your plan [individual user or group of users]
'plan' => 'user'
choose if you want to track package activity
'track' => true
choose middleware you need
'middleware' => ['web', 'auth']
choose your athentication guard
'guard' => 'web' # auth()->user();
add username [auth userame column]
'username' => 'mahmoud'
add auth model
'user_model_namespace' => 'App\User'
5. run this command to generate necessary tables
php artisan smsprovider:tables
Features:
1. Guard Authentication support. ## 'web', 'api', ....
2. Multi Language support; Currently supports [Arabic and English].
3. you can add one or more sms provider/gateway to your account/group.
4. choose your default sms provider/gateway to send through it.
5. simple view for your account/group sms providers/gateways.
6. simple view for your account/group trash.
7. configuration changing over the recorded providers/gateways.
8. can move items to trash or destroy it for good.
9. can recover trashed items.
10. simple view for adding/updating any provider data.
11. send sms to single number or group of numbers.
12. simple view for messages sent/failed for account/group/provider.
13. call collection of providers/gateways.
14. call collection of trashed providers/gateways.
15. simple view for track activity.
16. add/edit template messages.
17. send template messages.
Very important:
use this session with group plan
session()->put('group_id', $group_id);
How to use SMSProvider:
return new provider setup view: Note: You can use it to return view in new url or use this given one.
SMSProvider::configProvider(); route('smsprovider.providers.setup'); url('smsprovider/setup');
send new sms to number or multiple numbers
SMSProvider::sendSMS($message, $numbers);
Example
SMSProvider::sendSMS('hi, Mahmoud', '20106xxxxxxx');
SMSProvider::sendSMS('hi, group member', '20106xxxxxxx,0120xxxxxxx,20111xxxxxxx');
*** expected response ***
'0: error_code' => 'sending failed, and error code is given',
'1' => 'messege delivered successfully',
'2' => 'no response from destination or connection error',
'3' => 'no provider found'
return a single provider configuartion view/edit view
SMSProvider::editProvider($provider_id); route('smsprovider.providers.edit_provider', $provider_id); url('smsprovider/edit-provider/' . $provider_id);
move provider to trash [soft delete]
SMSProvider::deleteProvider($provider_id');
*** expected response ***
true or false
destroy provider [becareful, deleting provider means that you will lose {configs, messages, ...}]
SMSProvider::destroyProvider($provider_id');
*** expected response ***
true or false
set default provider
SMSProvider::setDefaultProvider($provider_id);
*** expected response ***
true or false
recover deleted provider
SMSProvider::recoverProvider($provider_id);
*** expected response ***
true or false
remove default provider
SMSProvider::removeDefaultProvider();
*** expected response ***
true or false
get providers => [20/page]
return collection for auth user
SMSProvider::myProviders();
return collection for group
SMSProvider::groupProviders();
return view for auth user
SMSProvider::myProvidersView(); route('smsprovider.providers.user-providers'); url('smsprovider/user-providers');
return view for group
SMSProvider::groupProvidersView(); route('smsprovider.providers.group-providers'); url('smsprovider/group-providers');
get trashed providers => [20/page]
return collection for auth user
SMSProvider::myTrashedProviders();
return collection for group
SMSProvider::groupTrashedProviders();
return view for auth user
SMSProvider::myTrashedProvidersView(); route('smsprovider.providers.user-trashed-providers'); url('smsprovider/user-trashed-providers');
return view for group
SMSProvider::groupTrashedProvidersView(); route('smsprovider.providers.group-trashed-providers'); url('smsprovider/group-trashed-providers');
track activity
auth user track [20/page]
SMSProvider::track(); SMSProvider::trackView(); route('smsprovider.providers.user-track'); url('smsprovider/user-track');
group track [20/page]
SMSProvider::groupTrack(); SMSProvider::groupTrackView(); route('smsprovider.providers.group-track'); url('smsprovider/group-track');
messages log activity
auth user log [20/page]
SMSProvider::log(); SMSProvider::logView(); route('smsprovider.providers.user-log'); url('smsprovider/user-log');
group log [20/page]
SMSProvider::groupLog(); SMSProvider::groupLogView(); route('smsprovider.providers.group-log'); url('smsprovider/group-log');
ready templates
Store one or more templates**
$array = [
['title' => 'greets', 'message' => 'hello there'],
['title' => 'bye', 'message' => 'goodbye'],
];
SMSProvider::storeTemplates($array);
also, you can do it with view:
SMSProvider::createTemplates();
Change template status
SMSProvider::changeTemplateStatus($template_id);
trash template
SMSProvider::trashTemplate($template_id);
recover template
SMSProvider::recoverTemplate($template_id);
delete template
SMSProvider::removeTemplate($template_id);
auth user templates [20/page]
SMSProvider::templates(); SMSProvider::trashedTemplates(); SMSProvider::templatesView(); SMSProvider::trashTemplatesView(); route('smsprovider.providers.user-templates'); url('smsprovider/user-templates');
group templates [20/page]
SMSProvider::groupTemplates(); SMSProvider::groupTrashedTemplates(); SMSProvider::groupTemplatesView(); SMSProvider::groupTrashTemplatesView(); route('smsprovider.providers.group-templates'); url('smsprovider/group-templates');