I have a button that deletes the record in table, and it works on purpose. But I need to add a message after deleting (not alert). When I was doing that in Laravel only, it worked perfectly. But now I have Vue.js in my project and it doesn't work.
It should return a green box that says 'successfully deleted record', when I write the same code in Laravel, it was working amazing. But with Vue.js, it doesn't work.
My blade file, it extends vue component. The message is before that in code.
<body>
<div id="app">
<div class="container">
@if(session('alert_delete'))
<div class="alert alert-success">
{{ session('alert_delete') }}
</div>
@endif
<students>
</students>
</div>
</div>
<script src="{{asset('js/app.js')}}">
</script>
My Controller
public function destroy($id)
{
$student = Student::findOrFail($id);
$student->delete();
return redirect('/')->with('alert_delete', 'Selected query is deleted successfully.');
}
Vue method to delete record
deleteStudent(id){
axios.delete(`api/student/`+id)
location.reload();
},
I was also using that to show validation errors. But now, it doesn't even show simple success message.
It's reloading the page by location.reload();
function on Vue method. But it doesn't work when I try to redirect from controller.