When I click my ticket it is not opening the specified page. While clicking the link of my ticket it shows in the link the correct ticket id, but the page is not opening. The error is:
404 not found
Ticket.blade.php
<tr>
@foreach ($ticketsinfos as $ticketinfo)
<td>IR-173049</td>
<td>Dito</td>
<td>{{ $ticketinfo->companies->name }}</td>
<td><a href="/tickets/show/{{ $ticketinfo->id }}">{{ Str::limit($ticketinfo->ticket_title, 50, '...') }}</a></td>
<td><button class="btn btn-danger btn-sm" type="button">Action Needed<br></button><br></td>
<td>Tako Kiknadze</td>
<td>{{ $ticketinfo->created_at }}</td>
<td>{{ $ticketinfo->updated_at }}</td>
</tr>
@endforeach
</tr>
web.php
<?php
use AppHttpControllersAdminsUserController;
//use AppHttpControllersUserController;
//use AppHttpControllersCompaniesController;
use AppHttpControllersDashboardController;
use AppHttpControllersTicketsController;
//use AppModelsAdminsUser;
//use AppModelsCompanies;
use IlluminateSupportFacadesRoute;
/*
|----------------------------------------------z----------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::resource('/dashboard', DashboardController::class);
Route::resource('/tickets', TicketsController::class);
Route::resource('/admin/users', AdminsUserController::class);
// Route::resource('/companies', CompaniesController::class);
Auth::routes();
Route::get('/home', [AppHttpControllersHomeController::class, 'index'])->name('home');
Controller
public function show(Tickets $tickets)
{
$tickets = Companies::with('tickets')->get();
$severities = Severities::with('severity')->get();
$ticketsinfos = Tickets::with('companies')->findOrFail(2);
return view('customer.index', compact($tickets))->with(['tickets' => $tickets])->with(['severities' => $severities])->with(['ticketsinfos' => $ticketsinfos]);
//dd($ticketsinfos->toArray());
}
When I use ‘dd’ it works.
2
Answers
I think the problem is with your return in controller
try this
Your having a problem because there is no defined route
tickets/show/{{ $ticket->id }}
. Since you are using route resource if you want to show theticket
with the given id you need to usetickets/{{ $ticket->id }}
or using theroute()
helper. `{{ route(‘tickets.show’, $ticket->id) }}Tip : Its easier to use the
route()
helper than using the the rawurl
of the path when accessingnamed routes
, since you will not be confused when passing a parameter for theroute
. Example{{ route('tickets.show', $ticket->id) }}
will generate theurl
astickets/1