I am newbie in development please help, not judge me. Remember everyone starts from 0.
I want to open my webiste post with specific id, but when I go to this link which is first post page http://localhost:8000/tickets/create/1 its opening correct id(1 is id) but tells me that "404 not found".
There are my codes.
Controller
public function create()
{
$ticketsinfos = Tickets::with('companies')->get();
$tickets = Companies::with('tickets')->get();
$severities = Severities::with('severity')->get();
$ticketscounts = Tickets::count();
//return view('dashboard.index',['ticketscounts'=> $ticketscounts]);
$users = DB::table('tickets')->get();
return view('customer.index')->with(['tickets'=> $tickets])->with(['severities' => $severities])->with(['ticketsinfos' => $ticketsinfos])->with(['ticketscounts'=> $ticketscounts])->with(['users'=>$users]);
//dd($users->toArray());
}
Blade.php
<tr>
@foreach ($ticketsinfos as $ticketinfo)
<td>IR-173049</td>
<td>Dito Katsarava</td>
<td>{{ $ticketinfo->companies->name }}</td>
@foreach($users as $user)
<td><a href="tickets/create/{{ $user->id }}">{{ Str::limit($ticketinfo->ticket_title, 50, '...') }}</a></td>
@endforeach
<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>
My route:
Route::resource('/tickets', TicketsController::class);
What can I do for do this?
Thank you.
CodePudding user response:
there is a problem with your route
try updating your route to be like this:
Route::resource('tickets/create/{id}', TicketsController::class);
and update your function like this:
public function create($id)
{
$ticketsinfos = Tickets::with('companies')->get();
$tickets = Companies::with('tickets')->get();
$severities = Severities::with('severity')->get();
$ticketscounts = Tickets::count();
//return view('dashboard.index',['ticketscounts'=> $ticketscounts]);
$users = DB::table('tickets')->get();
return view('customer.index')->with(['tickets'=> $tickets])->with(['severities' => $severities])->with(['ticketsinfos' => $ticketsinfos])->with(['ticketscounts'=> $ticketscounts])->with(['users'=>$users]);
//dd($users->toArray());
}
CodePudding user response:
What are you trying to do here ? Create a post method or get method ? by your naming it seems that you are trying to create something. can you please describe what you are trying to achieve so we can help you ? Do you want your users to edit the post ? Do you want your users create a comment to the posts ? Do you want your users to create new post ?