0

My laravel post works. tested with postman and enters into Database. Everything was working but a slight change is now giving me an 500 (Internal Server Error).

Laravel controller calling from model...my EventController.php(laravel)

 public function store(Request $request) { $event = new Event(); $event->event_title = $request->input('event_title'); $event->event_description = $request->input('event_description'); $event->event_location = $request->input('event_location'); $event->event_date = $request->input('event_date'); $event->event_time = $request->input('event_time'); $event->save(); //return response()->json(['event'=>$event, 'user'=>$user], 201); //return 'Event record successfully created'; } 

Eventform.html(angularjs)

<div ng-controller="FormController"> <ion-header-bar classic="bar-dark" id="formHead"> <h1 class="title">New Event</h1> </ion-header-bar> <ion-view title="Event Form"> <ion-content padding="true" class="has-header"> <form id="eventForm" class="list" role="form"> <label class="item item-input item-stacked-label"> <span class="input-label">Event Name</span> <input type="text" ng-model="newEvent.event_title" required="true" placeholder="Gregs' Birthday!"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Description</span> <input type="text" ng-model="newEvent.event_description" required="true" placeholder="Celebrate his 22nd year."> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Location</span> <input type="text" ng-model="newEvent.event_location" required="true" placeholder="123 Maple Lane"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Date</span> <input type="date" ng-model="newEvent.event_date" required="true" format="yyyy-mm-dd"> </label> <label class="item item-input item-stacked-label"> <span class="input-label">Time</span> <input type="time" ng-model="newEvent.event_time" required="true"> </label> <button type="button" class="button button-full" id="button-save" ng-click="save()">Save</button> </form> </ion-content> </ion-view> </div> 

event.js (angular post method)

 ThesisApp.controller('FormController', ['$scope', '$http', '$location', function($scope, $http, $location) { $scope.newEvent = {}; $scope.save = function() { $scope.newEvent= angular.copy(event); console.log("yes I'm being called"); console.log($scope.newEvent); $http.post('http://thesis-app.dev/events/posts', $scope.newEvent, {headers: {'X-Requested-With': 'XMLHttpRequest'}}).success(function(response) { console.log(response); }) .error(function(response) { console.log(response); }); } }]); 
5
  • If you get a 500 server error, check your error log on the server to find what the actual error message is. Commented Apr 18, 2017 at 5:28
  • please send csrf token in header than post will work check on this link how to add csrf token in post stackoverflow.com/questions/18336699/… Commented Apr 18, 2017 at 7:45
  • @MagnusEriksson where do i find the error log? Commented Apr 18, 2017 at 12:08
  • @MeaghanFlorence <app-root>/storage/log/ Commented Apr 18, 2017 at 12:10
  • @MagnusEriksson the error at the bottom of the file says #57 /Users/Megz/.composer/vendor/laravel/valet/server.php(133): require('/Users/Megz/cod...') #58 {main} Commented Apr 18, 2017 at 12:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.