Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #328
    dan
    Participant

    I get a status 404 Not Found.

    The route exists on the route list via php artisan route:list

    Also tried php artisan route:cache and php artisan route:clear

    web.php

    Route::get(‘/posts/{postid}’, [PostController::class, ‘show’])-> name(‘posts.show’);

    Route::get(‘/posts/create’, [PostController::class, ‘show’])-> name(‘posts.create’);

    PostController:

    public function create(Request $request) {

    return view(‘posts.reate’);

    ;
    }

    #329

    In your web.php interchange the order of create and show method.

    Route::get(‘/posts/create’, [PostController::class, ‘show’])-> name(‘posts.create’);

    Route::get(‘/posts/{postid}’, [PostController::class, ‘show’])-> name(‘posts.show’);

    Since since the route posts/{postid} comes before /posts/create , it will treat the string ‘create’ as an id thats why will not be able to find the file and throw 404 Not Found

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.