softon / sms

Simple SMS Gateway Package for sending short text messages from your Application. Facade for Laravel 5(Updated to work with Laravel 5.5).Currently supported Gateways Clickatell, MVaayoo, Gupshup, SmsAchariya, SmsCountry, SmsLane, Nexmo, Mocker / Any HTTP/s based Gateways are supported by Custom Gateway. Log gateway can be used for testing.
http://softon.github.io/sms/
MIT License
45 stars 27 forks source link

How to send SMS instead of Template? #13

Closed yoursantu closed 4 years ago

yoursantu commented 6 years ago

Hi, This utilizes blade view templates to send SMS. ie.

// Params: [MobileNumber,Blade View Location,SMS Params If Required] 

but how to send sms using HTML form instead of blade view template!? i have tried to put some text or variable instead of blade template, that is throwing error like:

"View [This is sms!] not found." 
Sms::send('9090909090','sms.test',['param1'=>'Name 1']);

the above method works fine with blade view template. but i would like to use POST method.

rajasekar-d commented 5 years ago

@yoursantu

Use send_raw method instead of send Sms::send_raw('9090909090','Thank you for registering.');

yoursantu commented 5 years ago

@rajasekar-d

i would like to use custom class instead of default predefined template, that should able to send the SMS from input text box or textarea using POST method!!

yoursantu commented 5 years ago

For Laravel

On Wed, 1 Aug 2018 at 23:52, Rajasekar D notifications@github.com wrote:

Using traditional php or laravel?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/softon/sms/issues/13#issuecomment-409673503, or mute the thread https://github.com/notifications/unsubscribe-auth/ANbVa_lCIOsvKMVyFiyYUqDsfghIgytmks5uMfHugaJpZM4UPnrI .

-- Santosh Hegde

9980230884

rajasekar-d commented 5 years ago

Required prerequisite package:

composer require softon/sms:dev-master
composer require "laravelcollective/html":"^5.2.0"

routes/routes.php

Route::get('sms','SMSController@sms')->name('sms');
Route::post('send-sms','SMSController@sendSMS')->name('sendSMS');

resources/views/sms.php

{{ Form::open(['route' => ['sendSMS']]) }} 
    <div class="form-group row">
        {{ Form::label('mobile','Mobile No',['class' => 'col-md-3 col-form-label required']) }}
        <div class="col-md-9">
            {{ Form::text('mobile',null,['class' => 'form-control', 'autofocus' => 'autofocus']) }}
        </div>
    </div>
    <div class="form-group row">
        {{ Form::label('message','Message',['class' => 'col-md-3 col-form-label required']) }}
        <div class="col-md-9">
            {{ Form::text('message',null,['class' => 'form-control']) }}
        </div>
    </div>
    <div class="form-group row">
        <div class="col-md-9 ml-md-auto">
            {{ Form::button('Save',['class'=>'btn btn-primary mr-3','type'=>'submit']) }}
        </div>
    </div>
{{ Form::close() }}

http/controllers/SMSController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Softon\Sms\Facades\Sms;

class SMSController extends Controller{

    public function sms(){
        return view('sms');
    }

    public function sendSMS(Request $request){
        $mobile = $request->get('mobile');
                $message = $request->get('message');
                Sms::send_raw($mobile,$message);
        return redirect()->route(' sms')->with('success','SMS sent successfully');
    }
}
yoursantu commented 5 years ago

Hello... Thank you very much for your post, i will check it out...!!

On Sun, 5 Aug 2018 at 20:05, Rajasekar D notifications@github.com wrote:

Required prerequisite package:

composer require softon/sms:dev-master composer require "laravelcollective/html":"^5.2.0"

routes/routes.php

Route::get('sms','SMSController@sms')->name('sms'); Route::post('send-sms','SMSController@sendSMS')->name('sendSMS');

resources/views/sms.php

{{ Form::open(['route' => ['sendSMS']]) }}

{{ Form::label('mobile','Mobile No',['class' => 'col-md-3 col-form-label required']) }}
{{ Form::text('mobile',null,['class' => 'form-control', 'autofocus' => 'autofocus']) }}
{{ Form::label('message','Message',['class' => 'col-md-3 col-form-label required']) }}
{{ Form::text('message',null,['class' => 'form-control']) }}
{{ Form::button('Save',['class'=>'btn btn-primary mr-3','type'=>'submit']) }}

{{ Form::close() }}

http/controllers/SMSController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use Softon\Sms\Facades\Sms;

class SMSController extends Controller{

public function sms(){ return view('sms'); }

public function sendSMS(Request $request){ $mobile = $request->get('mobile'); $message = $request->get('message'); Sms::send_raw($mobile,$message); return redirect()->route(' sms')->with('success','SMS sent successfully'); } }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/softon/sms/issues/13#issuecomment-410524297, or mute the thread https://github.com/notifications/unsubscribe-auth/ANbVa8bTX5dE9vuHUNvAXVuV4Jib_P3Iks5uNwLEgaJpZM4UPnrI .

-- Santosh Hegde

9980230884

yoursantu commented 5 years ago

@rajasekar-d Hi, that method, which you suggested in previous post worked for me, and one more thig i need is, config from database i mean, i need dynamic config for app/config/sms.php so how can do it so!?

rajasekar-d commented 5 years ago

Try this,

You have to place the below code into AppServiceProvider Boot section

foreach (Setting::pluck('key','name') as $value => $key) {
   config()->set('nexmo.'.$key, $value);
 }
yoursantu commented 5 years ago

@rajasekar-d Thank you for your responce, and in above code example the Setting table should be serialized right!? and the method config()->set(); overrided the config/sms.php!?