SmsTemplateController.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Http\Request;
  5. use App\Models\SmsTemplate;
  6. class SmsTemplateController extends Controller
  7. {
  8. /**
  9. * Display a listing of the resource.
  10. *
  11. * @return \Illuminate\Http\Response
  12. */
  13. public function index()
  14. {
  15. $sms_templates = SmsTemplate::all();
  16. return view('otp_systems.configurations.sms_templates', compact('sms_templates'));
  17. }
  18. /**
  19. * Show the form for creating a new resource.
  20. *
  21. * @return \Illuminate\Http\Response
  22. */
  23. public function create()
  24. {
  25. //
  26. }
  27. /**
  28. * Store a newly created resource in storage.
  29. *
  30. * @param \Illuminate\Http\Request $request
  31. * @return \Illuminate\Http\Response
  32. */
  33. public function store(Request $request)
  34. {
  35. //
  36. }
  37. /**
  38. * Display the specified resource.
  39. *
  40. * @param int $id
  41. * @return \Illuminate\Http\Response
  42. */
  43. public function show($id)
  44. {
  45. //
  46. }
  47. /**
  48. * Show the form for editing the specified resource.
  49. *
  50. * @param int $id
  51. * @return \Illuminate\Http\Response
  52. */
  53. public function edit($id)
  54. {
  55. //
  56. }
  57. /**
  58. * Update the specified resource in storage.
  59. *
  60. * @param \Illuminate\Http\Request $request
  61. * @param int $id
  62. * @return \Illuminate\Http\Response
  63. */
  64. public function update(Request $request, $id)
  65. {
  66. $sms_template = SmsTemplate::where('id', $id)->first();
  67. $sms_template->sms_body = str_replace("\r\n",'',$request->body);
  68. $sms_template->template_id = $request->template_id;
  69. if ($request->status == 1) {
  70. $sms_template->status = 1;
  71. }
  72. else{
  73. $sms_template->status = 0;
  74. }
  75. if($sms_template->save()){
  76. flash(translate('SMS Template has been updated successfully'))->success();
  77. return back();
  78. } else {
  79. flash(translate('Sorry! Something went wrong.'))->error();
  80. return back();
  81. }
  82. }
  83. /**
  84. * Remove the specified resource from storage.
  85. *
  86. * @param int $id
  87. * @return \Illuminate\Http\Response
  88. */
  89. public function destroy($id)
  90. {
  91. //
  92. }
  93. }