skip to Main Content

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


  1. I think the problem is with your return in controller

    try this

    return view('customer', compact('tickets', 'severities', 'ticketsinfos'));
    
    Login or Signup to reply.
  2. 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 the ticket with the given id you need to use tickets/{{ $ticket->id }} or using the route() helper. `{{ route(‘tickets.show’, $ticket->id) }}

    Tip : Its easier to use the route() helper than using the the raw url of the path when accessing named routes, since you will not be confused when passing a parameter for the route. Example {{ route('tickets.show', $ticket->id) }} will generate the url as tickets/1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search