I am having an issue with my datatables returning a 404 error when I try to link a string. For my id an years I had no problem because they were ints, but the string is causing problems. I have a list of teams, if click oilers-84, i get teams/oilers-84, but it returns nothing even though I have a teams/show blade. If i leave it as 84 oilers, it returns teams/84 with the info from the 84th id in the table. Instead, I want to return the 84-oilers team page. Not sure if its a routing issue, controller, or if I need to convert the teams to a teams_id column someway. Sorry if that's a lengthy intro, I'm having a hard time understanding the issue exactly. In my web.php i simply have this: Route::resource('/teams', 'TeamsController'); Here is rest of my code:
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: '',
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>
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire