Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
490 views
in Technique[技术] by (71.8m points)

laravel - Route keep asking for parameter even if not set to receive any

I'm new to laravel and I'm having trouble with one of my web routes...

I grouped some routes with the auth middleware

Route::middleware(['auth:web'])->group(function ($router) {

    Route::get('/news', [NewsController::class, 'news'])->name('news');
    Route::get('/profile/{user_id}', [ProfileController::class, 'profile'])->name('profile');
    Route::get('/marketplace', [MarketplaceController::class, 'marketplace'])->name('marketplace');

});

Before this issue, I have set a user_id parameter for the news route and then removed it the next day, now the news route keeps returning error saying it needs user_id.

here's my controller:

    <?php

namespace AppHttpControllers;

class NewsController extends Controller
{

    public function news() {

        return view('modules.news.news');

    }
}

and since im using laravel-vue mix, my modules.news.news view looks like this:

@section('content')
    <newsfeed inline-template>
        <div>
            ...
            ...
        </div>
    </newsfeed>
@endsection

I've checked the web route, the controller, the blade, and I really can't see anything that requiring the news route to receive a parameter.

can someone point out where I went wrong?

question from:https://stackoverflow.com/questions/65906828/route-keep-asking-for-parameter-even-if-not-set-to-receive-any

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...