[Vuejs]-500 server internal error in laravel vue

0πŸ‘

βœ…

In you controller your have

$leavedata = LeaveRequest::where('leave_id', $id);

at this point $leavedata is just an instance of the Query Builder therefore any code below that point that tries to access retrieved models properties will fail

Based on your current setup you should add firstOrFail() at the end.

$leavedata = LeaveRequest::where('leave_id', $id)->firstOrFail();

So in case of the record not being found the method would safely abort and return a 404 error.

Leave a comment