Guest User

Untitled

a guest
Jun 23rd, 2018
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. class MailController extends Controller
  2. {
  3. public function sendMessageMail(SendMailRequest $request)
  4. {
  5. $data = [
  6. 'name' => $request->name,
  7. 'email' => $request->email,
  8. 'phone' => $request->phone,
  9. 'date' => $request->date,
  10. 'guests' => $request->guests,
  11. 'budget' => $request->budget,
  12. 'wishes' => $request->wishes,
  13. ];
  14. Mail::send('mails.send-message', $data, function($message)
  15. {
  16. $message->from('verona@palazzoeventi.com', 'PalazzoEventi');
  17. $message->to('verona@palazzoeventi.com')->subject('Новое письмо с сайта palazzoeventi.com');
  18. });
  19. }
  20. }
  21.  
  22. ********************* JQuery **********************
  23. $.ajaxSetup({
  24. headers: {
  25. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  26. }
  27. });
  28. $('.modal-send').click(function () {
  29. var form = $(this).closest('.form');
  30. var url = $(this).closest('.modal-window').data('url');
  31. var windowId = $(this).closest('.modal-window').data('window');
  32. $.when($(this).closest('.modal-window').fadeOut()).done(function () {
  33. sendAjax(form.serialize(), url, windowId);
  34. });
  35. });
  36.  
  37. function sendAjax(formData, url, windowId) {
  38. $.ajax({
  39. url: url,
  40. method: 'POST',
  41. data: formData,
  42. success: function (data) {
  43. showSuccess(windowId);
  44. },
  45. error: function (data) {
  46. let errors = data.responseJSON;
  47. // for (let error in errors) {
  48. // $('.errors').append(errorWrapper(errors[error]))
  49. // }
  50. }
  51. })
  52. }
Add Comment
Please, Sign In to add comment