刀片代码:
<td><a href="{{ route('employee.show', ['lang' => app()->getLocale(), 'employee' => $employee->id]) }}">{{ $employee->first_name }} {{ $employee->last_name }}</a></td>
<td><a href="{{ route('employee.update', ['lang' => app()->getLocale(), 'employee' => $employee->id]) }}" class="btn btn-primary">{{ __('app-text.indexEdit') }}</a></td>
<td><form action="{{ route('employee.delete', ['lang' => app()->getLocale(), 'employee' => $employee->id]) }}" method="post">
控制器功能:
public function edit(Employee $employee)
{
$companies = Company::get();
return view('employee.edit', compact('employee', 'companies'));
}
错误:
TypeError
Argument 1 passed to App\Http\Controllers\EmployeesController::edit() must be an instance of App\Employee, string given
http://localhost:8000/fr/employee/edit/1
路线:
Route::group(['prefix' => '{lang}'], function() {
Route::prefix('employee')->name('employee.')->group(function() {
Route::get('/edit/{employee}', 'EmployeesController@edit')->name('edit');
Route::patch('/edit/{employee}', 'EmployeesController@update')->name('update');
我正在尝试使应用程序成为多语言应用程序,因此在添加 lang 变量后,路由将不会传递 $employee->id 变量。我应该为 lang 变量添加一个可传递给控制器的变量吗?有什么解决办法吗?非常感谢。
RISEBY
料青山看我应如是
梦里花落0921
慕后森