在我的应用程序中,尝试保存数据时出现错误 302。我在这里发布我的代码,请有人调查一下并帮助我。
HolidayAdd.vue
<template>
<layout>
<div class="container">
<form @submit.prevent="handleSubmit">
<div class="form-group">
<label for="fname">First Name</label>
<input id="fname" type="text" class="form-control" name="ftname" placeholder="Enter your First Name" v-model="holiday.fname">
</div>
<div class="form-group">
<label for="lname">Last Name</label>
<input id="lname" type="text" class="form-control" name="lastname" placeholder="Enter your Last Name" v-model="holiday.lname">
</div>
<div class="form-group">
<label for="sdate">Start Date</label>
<input type="date" class="form-control" name="sdate" v-model="holiday.sdate" id="sdate">
</div>
<div class="form-group">
<label for="edate">End Date</label>
<input type="date" class="form-control" name="edate" v-model="holiday.edate" id="edate">
</div>
<button class="btn btn-info">Apply</button>
</form>
</div>
</layout>
</template>
<script>
import Layout from './../../Shared/Layout'
export default {
components: {
Layout
},
data() {
return {
holiday: {
fname: '',
lname: '',
sdate: '',
edate: ''
}
}
},
methods: {
async handleSubmit() {
let response = await this.$inertia.post('/holiday', this.holiday)
}
}
}
</script>
假日控制器.php
public function store(Request $request)
{
$holiday = $request->validate([
'firstname' => 'required',
'lastname' => 'required',
'startdate' => 'required',
'enddate' => 'required'
]);
Holiday::create($holiday);
return redirect()->route('holiday.index');
}
网页.php
Route::group(['middleware' => 'auth'], function() {
Route::resource('holiday', 'HolidayController');
});
据我所知,没有错误,那为什么我在这里收到302错误?