我有问题,我建立了支持系统,当我想进入看票的页面时,会得到404找不到的信息。基本上,路由是数据库中ID的路由。
路线:
Route::get('/viewTickets', 'TicketController@view_MyTickets')->name('viewTickets');
Route::get('/viewTickets/{ticket}', 'TicketController@view_MyTicketUpdate')->name('updateTicket');
Route::post('/viewTickets/{ticket}', 'TicketController@update_MyTicket');
控制器:
public function view_MyTickets() {
$tickets = Ticket::latest()->get();
return view('viewTickets', compact('tickets'));
}
public function view_MyTicketUpdate() {
$tickets = Ticket::latest()->get();
return view('updateTicket', compact('tickets'));
}
查看:
<tbody>
@foreach($tickets as $ticket)
<tr>
<td>{{$ticket->id}}</td>
<td>{{$ticket->user_id}}</td>
<td>{{$ticket->title}}</td>
<td>{{$ticket->category}}</td>
<td>{{$ticket->status}}</td>
<td>
<form>
<a href="{{ $ticket->id }}" class="view" title="View" data-toggle="tooltip"><i class="material-icons"></i></a>
<a href="{{ $ticket->id }}"lass="edit" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>
</td>
</form>
</tr>
@endforeach
</tbody>
我真的不明白问题所在,一种解决方法并且没有收到错误404吗?顺便说一句,我读了其他主题,但找不到解决方案。
答案 0 :(得分:0)
您在href属性中设置的链接仅是工单ID,但应为“ / viewTickets / 1”
试着把这个:
href="{{route('updateTicket', ['ticket' => $ticket->id])}}"
答案 1 :(得分:0)
在您的路线上:
Route::get('/viewTickets', 'TicketController@view_MyTickets')->name('viewTickets');
Route::get('/viewTickets/{ticket}', 'TicketController@view_MyTicketUpdate')->name('updateTicket');
Route::post('/viewTickets/{ticket}', 'TicketController@update_MyTicket');
在您的控制器中:
public function view_MyTickets() {
$tickets = Ticket::latest()->get();
return view('viewTickets', compact('tickets'));
}
public function view_MyTicketUpdate(Request $request, $ticket) {
$tickets = Ticket::find($ticket);
return view('updateTicket', compact('tickets'));
}
在您的刀片中:
<tbody>
@foreach($tickets as $ticket)
<tr>
<td>{{$ticket->id}}</td>
<td>{{$ticket->user_id}}</td>
<td>{{$ticket->title}}</td>
<td>{{$ticket->category}}</td>
<td>{{$ticket->status}}</td>
<td>
<a href="{{ route('viewTickets', ['ticket' => $ticket->id]) }}" class="view" title="View" data-toggle="tooltip"><i class="material-icons"></i></a>
<a href="{{ route('updateTicket', ['ticket' => $ticket->id]) }}"lass="edit" title="Edit" data-toggle="tooltip"><i class="material-icons"></i></a>
</td>
</tr>
@endforeach
</tbody>