Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send SMS instead of Template? #13

Closed
yoursantu opened this issue May 28, 2018 · 8 comments
Closed

How to send SMS instead of Template? #13

yoursantu opened this issue May 28, 2018 · 8 comments

Comments

@yoursantu
Copy link

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
Copy link

@yoursantu

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

@yoursantu
Copy link
Author

@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
Copy link
Author

yoursantu commented Aug 5, 2018 via email

@rajasekar-d
Copy link

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
Copy link
Author

yoursantu commented Aug 7, 2018 via email

@yoursantu
Copy link
Author

@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
Copy link

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
Copy link
Author

@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!?

@softon softon closed this as completed Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants