%7B%7B%20route%20(
。我试图将id与路径一起传递。
这是我的代码
<?php
foreach ($requests as $newRequests){
echo '<td>' .$newRequests->company_name. '</td>';
echo '<td>'.$newRequests->fname, $newRequests->lname.'</td>';
echo '<td>'.$newRequests->job_position.'</td>';
echo '<td>'.$newRequests->email.'</td>';
echo '<td>'.$newRequests->contact_no.'</td>';
if($newRequests->status == 'Pending'){
echo "<td> <a href = '{{ route ('Admin.RequestsPage', $newRequests->id) }}' class='btn btn-primary btn-rounded'>Accept</a>
<a class='btn btn-danger btn-rounded'>Decline</a> <input type = 'hidden' name='requestID value='.$newRequests->id.'>
</td>";
} else if ($newRequests->status == 'Accepted'){
echo "<td><span class='label label-table label-success'>Accepted</span></td>";
} else{
echo "<td><span class='label label-table label-danger'>Declined</span>
</td>";
}
}
?>
答案 0 :(得分:1)
在href中尝试这个
href="{{ route ('Admin.RequestsPage', ['id' => $newRequests->id]) }}"
并且您的路线应该是GET并使用您的路线名称而不是此“Admin.RequestsPage”
答案 1 :(得分:0)
您可以在此处按照laravel + blade模板的说明进行操作 https://laravel.com/docs/5.5/blade#displaying-data
在你的控制器中输入这样的东西:
return view('some-blade-template', ['url' => 'some/route']);
和这样的简单刀片模板:
<a href="{{ route($url) }}">Click me</a>