【发布时间】:2018-09-17 22:23:15
【问题描述】:
我正在尝试使用“POST”方法提交表单,但得到MethodNotAllowedHttpException 我知道出现此错误的一些可能原因,并且还在互联网上搜索了可能的解决方案。除了这个之外,我的项目的所有其他形式都运行良好。我找不到出现此常见错误的原因。有人可以帮我找出解决方案吗?
表格
<form action="{{ url('admin/checkout') }}" method="POST">
@csrf
<div class="row">
<div class="col-sm-6 offset-sm-3">
<label class="m-t-20">Now time</label>
<div class="input-group">
<input name="outtime" class="form-control" id="single-input" value="" placeholder="Now" required>
<span class="input-group-btn">
<button type="submit" id="check-minutes" class="btn waves-effect waves-light btn-warning">Check Out</button>
</span>
@if ($errors->has('outtime'))
<small class="error">{{ $errors->first('outtime') }}</small>
@endif
</div>
</div>
</div>
<br>
<table id="flow-table" class="display nowrap mytable" cellspacing="0" width="100%">
<thead>
<tr>
<th style="width: 15px;">#</th>
<th class="check">
<div class="checkbox">
<label>
<input type="checkbox" id="flowcheckall" />
<i class="input-helper"></i>
<span><strong> All</strong></span>
</label>
</div>
</th>
<th class="text-left">Name</th>
<th>Cord No</th>
<th>Section</th>
<th>Designation</th>
</tr>
</thead>
<tbody>
@forelse($employees as $employee)
<tr class="text-center">
<td>{{ $loop->index + 1 }}</td>
<td style="max-width: 30px;">
<div class="checkbox text-center">
<label>
<input type="checkbox" name="employee_id[]" class="check" id="checkall" value="{{ $employee->employee_id }}" />
<i class="input-helper"></i>
</label>
</div>
</td>
<td class="text-left">{{ $employee->name }}</td>
<td>{{ $employee->card_no }}</td>
<td>{{ ucwords($employee->section) }}</td>
<td>{{ ucwords($employee->designation) }}</td>
</tr>
@empty
@endforelse
</tbody>
</table>
</form>
web.php
#Admin Routes
Route::get('admin', 'Admin\LoginController@showLoginForm')->name('admin.login');
Route::post('admin', 'Admin\LoginController@login');
Route::post('admin-password/email', 'Admin\ForgotPasswordController@sendResetLinkEmail')->name('admin.password.email');
Route::get('admin-password/reset', 'Admin\ForgotPasswordController@showLinkRequestForm')->name('admin.password.request');
Route::post('admin-password/reset', 'Admin\ResetPasswordController@reset');
Route::get('admin-password/reset/{token}', 'Admin\ResetPasswordController@showResetForm')->name('admin.password.reset');
Route::group(['prefix' => 'admin', 'middleware' => ['auth:admin'], 'as' => 'admin.'], function () {
# Dashboard / Index
Route::get('home', array('as' => 'home','uses' => 'Admin\AdminController@index'));
Route::get('change-password', array('as' => 'change-password','uses' => 'Admin\AdminController@changePassword'));
Route::put('change-password', array('as' => 'change-password','uses' => 'Admin\AdminController@updatePassword'));
// HR (Section)
Route::resource('section', 'Admin\HR\SectionController');
// HR (Designation)
Route::resource('designation', 'Admin\HR\DesignationController');
// HR (Salary Grade)
Route::resource('salary-grade', 'Admin\HR\SalaryGradeController');
// HR (Employee)
Route::resource('employees', 'Admin\HR\EmployeeController');
//HR (Employee cv download)
Route::get('cv-download/{id}', 'Admin\HR\EmployeeController@cvDownload');
// HR (Attendance)
Route::resource('attendances', 'Admin\HR\AttendanceController');
Route::post('attendances/searched-employees', 'Admin\HR\AttendanceController@searchedEmployees');
Route::get('today-checked-in', array('as' => 'today-checked-in', 'uses' => 'Admin\HR\AttendanceController@checkedIn'));
Route::post('checkout', 'Admin\HR\AttendanceController@checkout');
//HR (Leave Type)
Route::resource('leave-types', 'Admin\HR\LeaveTypeController');
//HR (Leave Application)
Route::resource('leave-application', 'Admin\HR\LeaveApplicationController');
Route::post('leave-application/searched-employees', 'Admin\HR\LeaveApplicationController@searchedEmployees');
Route::get('leave-application/{id}/create', 'Admin\HR\LeaveApplicationController@create');
Route::get('leave-application-download/{id}', 'Admin\HR\LeaveApplicationController@applicationDownload');
//HR (Holidays)
Route::resource('holidays', 'Admin\HR\HolidayController');
//HR (Promotions)
Route::resource('promotions', 'Admin\HR\PromotionController');
Route::get('promotions/{id}/create', 'Admin\HR\PromotionController@create');
Route::post('promotions/searched-employees', 'Admin\HR\PromotionController@searchedEmployees');
Route::get('promotions/update/{id}', 'Admin\HR\PromotionController@');
//HR (Payroll Provident Fund)
Route::resource('provident-fund', 'Admin\HR\ProvidentFundController');
Route::post('provident-fund/searched-employees', 'Admin\HR\ProvidentFundController@searchedEmployees');
Route::get('provident-fund/{id}/create', 'Admin\HR\ProvidentFundController@create');
//HR (Payroll Advance Salary)
Route::resource('advance-salary', 'Admin\HR\AdvanceSalaryController');
Route::post('advance-salary/searched-employees', 'Admin\HR\AdvanceSalaryController@searchedEmployees');
Route::get('advance-salary/{id}/create', 'Admin\HR\AdvanceSalaryController@create');
//HR (Payroll-Salary)
Route::group(['prefix' => 'salary', 'as' => 'salary.'], function () {
//make salary
Route::get('make-salary', array('as' => 'make-salary', 'uses' => 'Admin\HR\SalaryController@makeSalaryIndex'));
Route::post('make-salary-employees-list', array('as' => 'make-salary-employees-list', 'uses' => 'Admin\HR\SalaryController@getMakeSalaryEmployeeList'));
Route::post('make-salary-save/{id}', array('as' => 'make-salary-save', 'uses' => 'Admin\HR\SalaryController@makeSalarySave'));
//make payment
Route::get('make-payment', array('as' => 'make-payment', 'uses' => 'Admin\HR\SalaryController@makePaymentSearch'));
Route::post('make-payment-employees-list', array('as' => 'make-payment-employees-list', 'uses' => 'Admin\HR\SalaryController@getMakePaymentEmployeeList'));
Route::get('employee/{id}', array('as' => 'employee', 'uses' => 'Admin\HR\SalaryController@makeEmployeeSalary'));
Route::put('change-payment-status/{id}', array('as' => 'change-payment-status', 'uses' => 'Admin\HR\SalaryController@changePaymentStatus'));
//generate payslip
Route::get('payslip', array('as' => 'payslip', 'uses' => 'Admin\HR\SalaryController@generatePayslip'));
Route::post('payslip-search', array('as' => 'payslip-search', 'uses' => 'Admin\HR\SalaryController@payslipSearch'));
});
/*Accounts Part*/
//Accounts (Groups)
Route::resource('groups', 'Admin\Accounts\GroupController');
//Accounts (Groups)
Route::resource('companies', 'Admin\Accounts\CompanyController');
//Accounts (Customers)
Route::resource('customers', 'Admin\Accounts\CustomerController');
//Accounts (Suppliers)
Route::resource('suppliers', 'Admin\Accounts\SupplierController');
});
出勤控制器.php
/**
*
*checkout
**/
public function checkout(Request $request)
{
return $request->all();
}
【问题讨论】:
-
向我们展示您的完整路线
web.php -
更新了 web.php
-
尝试使用 php artisan route:clear 清除路由缓存
-
您是通过正常点击按钮进行提交还是涉及到任何javascript?
-
是的,我正在正常提交。
标签: php laravel methods routes laravel-5.6