Как перенаправить на другую страницу после отправки формы с моим контроллером. форма работает нормально, но когда я использую такой код, я получаю пустую страницу, и если я использую
return view('leave.signUp');
, она работает, но все еще остается на странице формы, и я хочу, чтобы она была перенаправлена на другая страница.
public function index(Request $request)
{
if($request->isMethod('POST')){
$employee = new Employee;
$employee->lname = $request->input('lname');
$employee->fname = $request->input('fname');
$employee->oname = $request->input('oname');
$employee->employee_id = $request->input('staffId');
$employee->college = $request->input('college');
//$employee->salary_level = $request->input('salaryGradeLevel');
$employee->employee_type = $request->input('staffType');
$employee->employee_category= $request->input('staffCategory');
$employee->date_of_first_appointment= $request->input('dateOfFirstAppointment');
$employee->date_of_last_appointment= $request->input('dateOfLastAppointment');
$employee->country = $request->input('country');
$employee->gender = $request->input('gender');
$employee->title = $request->input('title');
$employee->marital_status = $request->input('maritalStatus');
$employee->email = $request->input('email');
$employee->phone_number = $request->input('phoneNumber');
$employee->date_of_birth = $request->input('dateOfBirth');
$employee->place_of_birth = $request->input('placeOfBirth');
$employee->religion = $request->input('religion');
$employee->origin = $request->input('stateOfOrigin');
$employee->local_government_area = $request->input('localGovernmentArea');
$employee->address = $request->input('address');
$employee->permanent_address = $request->input('permanentAddress');
$employee->extra_curicullar_activities = $request->input('extraCuricularActivities');
$employee->save();
$nextOfKin = new NextOfKin;
$nextOfKin->employee_id = $employee->employee_id;
$nextOfKin->title = $request->input('Ntitle');
$nextOfKin->surname = $request->input('Nsurname');
$nextOfKin->firstname = $request->input('Nfirstname');
$nextOfKin->othername = $request->input('Nothername');
$nextOfKin->relationship = $request->input('Nrelationship');
$nextOfKin->email = $request->input('Nemail');
$nextOfKin->phone_number = $request->input('NphoneNumber');
$nextOfKin->contact_address = $request->input('Naddress');
$nextOfKin->save();
return redirect(route('application'));
}
}
это моя сеть. php
Route::match(['post','get'],'application', 'LeavessController@index');
Route::match(['post','get'],'signUp', 'signUpsController@index');
Route::get('approved', 'LeavesController@getLeaveApproved');
Route::match(['post','get'], 'leaveType', 'LeavesController@getleaveType');
Route::match(['post','get'], 'leaveDepartment', 'LeavesController@getleaveDepartment');
Route::get('allLeave', 'LeavesController@getallLeave');
Route::get('leaveViewDetails', 'LeavesController@getleaveViewDetails');
Route::get('/get-leave-days/{leaveType}', 'LeavesController@getLeaveDays');