Advertisement
majweb

Untitled

Jun 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. //Controller and method
  2.  
  3. public function store(Request $request)
  4. {
  5. $user = Sentinel::getUser();
  6. $plan = new Plan();
  7. $plan->plan_start = $request->plan_start;
  8. $plan->part_id = $request->part_id;
  9. $plan->exercise_id = $request->exercise_id;
  10. $plan->weight = $request->weight;
  11. $plan->series = $request->series;
  12. $plan->repeat = $request->repeat;
  13. $plan->time = $request->time;
  14.  
  15. $user->plans()->save($plan);
  16. return response()->json(['plan' => $plan], 202);
  17. }
  18.  
  19. //app.js
  20.  
  21. validation working when send form is problem
  22. POST http://localhost:3000/klient/plany/zapisz 500 (Internal Server Error)
  23.  
  24. validateBeforeSubmit: function() {
  25. this.$validator.updateDictionary({
  26. pl: {
  27. attributes: {
  28. repeat: 'powtórzenia',
  29. weight: 'ciężar',
  30. time: 'czas',
  31. }
  32. }
  33. })
  34. this.$validator.setLocale('pl')
  35.  
  36. // this could be error
  37.  
  38. this.$validator.validateAll().then(() => {
  39. // Data is valid, so we can submit the form.
  40. this.submitForm()
  41. }).catch(() => {
  42. return false
  43. })
  44.  
  45. //
  46. },
  47. submitForm:function(){
  48. axios.post('/klient/plany/zapisz')
  49. .then(function (response) {
  50. console.log(response);
  51. })
  52. .catch(function (error) {
  53. console.log(error);
  54. });
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement