当我尝试链接字符串时,我的数据表返回404错误时遇到问题。对于我的id多年来我没有问题,因为它们是整数,但字符串导致问题。我有一个团队列表,如果点击oilers-84,我得到团队/油工-84,但即使我有团队/展示刀片也没有返回任何内容。如果我把它留作84个油工,它将返回team / 84,其中包含表格中第84个id的信息。相反,我想返回84-Oilers团队页面。不确定它是否是路由问题,控制器,或者我是否需要将团队转换为teams_id列。很抱歉,如果这是一个冗长的介绍,我很难完全理解这个问题。在我的web.php中,我只需要:Route :: resource(' / teams',' TeamsController');这是我的其余代码:
Controller @show
public function show($id)
{
$teamdatas = GameData::findOrFail($id);
return view('teams/show', compact('teamdatas'));
}
datatables.blade.php-- script
<script type="text/javascript">
$(document).ready(function() {
$('#table').DataTable({
processing: true,
serverSide: true,
order: [],
columnDefs: [
{ "orderable": false, "targets": [10] }
],
ajax: '{{ route('datatable/getdata') }}',
columns: [
{data: 'id', name: 'id', "fnCreatedCell": function (nTd, sData,
oData, iRow, iCol) {
$(nTd).html("<a href=/games/"+oData.id+">"+oData.id+"</a>");
}},
{data: 'year', name: 'year', "fnCreatedCell": function (nTd, sData,
oData, iRow, iCol) {
$(nTd).html("<a href=/games/showyear/"+oData.year+">"+oData.year+"</a>");
}},
{data: 'game', name: 'game'},
{data: 'homeTeam', name: 'homeTeam', "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html("<a href=/teams/"+oData.homeTeam+">"+oData.homeTeam+"</a>");
}},
{data: 'awayTeam', name: 'awayTeam'},
{data: 'homeWin', name: 'homeWin'},
{data: 'awayWin', name: 'awayWin'},
{data: 'tie', name: 'tie'},
{data: 'stage', name: 'stage'},
{data: 'round', name: 'round'},
{data: 'stageSeries', name: 'stageSeries'},
{data: 'seriesGame', name: 'seriesGame'},
{data: 'homeScore', name: 'homeScore'},
{data: 'awayScore', name: 'awayScore'},
]
});
});
</script>
</body>
</html>