我有一个表视图,其中有一个视图按钮,并将其重定向到另一个带有已单击行的id的页面。
<tbody>
<tr>
<?php $hold=0; ?>
@if(!empty($users))
@foreach($users as $user)
@if($user->role == 3)
<?php $hold++; ?>
<td class="py-1">{{ $user->id }}</td>
<td>{{ $user->name }} </td>
<td>{{ $user->Zone }} </td>
<td>{{ $user->Purok }}</td>
<td> Wala pa sa database </td>
<td>
<div class="template-demo">
<button type="button" onclick="location.href=' {{ route ('SupAd.View_PL_Accnt/'.$user->id) }}'" class="btn btn-outline-info btn-icon-text">
<i class="ti-search btn-icon-append"></i>View
</button>
</div>
</td>
</tr>
@endif
@endforeach
<?php if($hold == 0){
echo "<p><font color=red size='4pt'>No purok leader can be found</font></p>";
}
?>
@endif我在web.php路由上有我的代码
Route::group(['prefix'=>'SupAd_Purok_Leader_Account', 'middleware'=>['isSupAd', 'auth', 'PreventBackHistory']], function (){
Route::get('View_PL_Accnt', [SupAdController::class, 'View_PL_Accnt'])->name('SupAd.View_PL_Accnt/{id}'); });我得到了错误:
Symfony\Component\Routing\Exception\RouteNotFoundException路由支持
_PL_Accnt/3未定义.
发布于 2022-04-08 09:36:33
您将路由参数放置在错误的位置。试试这个:
Route::get('View_PL_Accnt/{id}', [SupAdController::class, 'View_PL_Accnt'])->name('SupAd.View_PL_Accnt'); });该名称用于使用route助手调用路由。您可以向数组中的路由助手提供url参数。在您的刀片文件中使用:
{{ route ('SupAd.View_PL_Accnt', [$user->id]) }}发布于 2022-04-08 09:44:01
你可以改变路线,比如
Route::get('View_PL_Accnt/{id}', [SupAdController::class, 'View_PL_Accnt'])->name('SupAd.View_PL_Accnt'); });并更改单击事件的按钮。
<button type="button" onclick="location.href='{!! route('SupAd.View_PL_Accnt', [$user->id]) !!}'" class="btn btn-outline-info btn-icon-text">
<i class="ti-search btn-icon-append"></i>View
</button>https://stackoverflow.com/questions/71794727
复制相似问题