SmsController.php 796 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Nexmo;
  5. use Twilio\Rest\Client;
  6. use App\Models\OtpConfiguration;
  7. use App\Models\User;
  8. class SmsController extends Controller
  9. {
  10. /**
  11. * Display a listing of the resource.
  12. *
  13. * @return \Illuminate\Http\Response
  14. */
  15. public function index()
  16. {
  17. $users = User::all();
  18. return view('otp_systems.sms.index',compact('users'));
  19. }
  20. //send message to multiple users
  21. public function send(Request $request)
  22. {
  23. foreach ($request->user_phones as $key => $phone) {
  24. sendSMS($phone, env('APP_NAME'), $request->content, $request->template_id);
  25. }
  26. flash(translate('SMS has been sent.'))->success();
  27. return redirect()->route('admin.dashboard');
  28. }
  29. }