Home > Blockchain >  page not opening when click the post
page not opening when click the post

Time:12-08

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 Katsarava</td> 
  <td>{{ $ticketinfo->companies->name }}</td>
  <td><a href="/tickets/show/{{ $ticketinfo->id }}">{{ Str::limit($ticketinfo->ticket_title, 50, '...') }}</a></td>
  <td><button  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 App\Http\Controllers\AdminsUserController;
//use App\Http\Controllers\UserController;
//use App\Http\Controllers\CompaniesController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\TicketsController;
//use App\Models\AdminsUser;
//use App\Models\Companies;
use Illuminate\Support\Facades\Route;

/*
|----------------------------------------------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', [App\Http\Controllers\HomeController::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.

CodePudding user response:

I think the problem is with your return in controller

try this

return view('customer', compact('tickets', 'severities', 'ticketsinfos'));

CodePudding user response:

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

  • Related