stephen waweru99
stephen waweru99

Reputation: 141

404 not found but route and controller exists

i am trying to display a single event page from all the events page in that when a user clicks on a link they are redirected to the event page.the issue am having is am the page returns a 404 page..here is how I have created the link

<a href="{{ url('event/'.Str::slug($eve->eve_name).'/'.$eve->id) }}" class="schedule-btn">View Details</a>

here is my function in the controller

public function singleevent ($event_slug,$id){
        $events = Events::find($id);
        return view('frontend.singleevent',compact('events'));
    }

here is my route

Route::get('event/{slug}/id', [Home_Controller::class,'singleevent'])->name('singleevent');

where might have I gone wrong when writing the code..kindly assist

Upvotes: 0

Views: 24

Answers (1)

Mohammed Naguib
Mohammed Naguib

Reputation: 594

make it

Route::get('event/{slug}/{id}', [Home_Controller::class,'singleevent'])->name('singleevent');

the {} in id the route will always expect a fixed string "/id" in the route

Upvotes: 1

Related Questions