我更改了资源路线,我的锦标赛页面是空的拉维尔 8

问题描述

嗨,在创建 store 方法后,我将所有控制器方法都用作一个方法,因此我在 Route::resource 上更改了它,我想翻译路由名称,因此我使用了 AppService 提供程序并将斯洛伐克语添加到路由中,但现在我遇到了问题和我的路由很好,但它不起作用。我的每个锦标赛页面都是空的,并且也有不用于处理空页面的 slug。在空白页面上是导航栏和我的刀片,没有来自数据库的数据。

感谢您的建议。

例如控制器中的一个我的方法

public function show(Tournament $tournament)
{

    return view('tournaments.show',[
        'tournament' => $tournament,'regions' => Region::where("id","=",$tournament->region_id)->get(),]);
}

我的路线

Route::resource('turnaje',TournamentController::class)
->parameters([
    'tournaments' => 'tournaments:slug'
])->only([
    'create','store','edit','update','destroy'
])->middleware('auth');

Route::resource('turnaje',TournamentController::class)
    ->only([
        'index','show',]);

应用服务提供者

    public function boot()
{
    Route::resourceVerbs([
        'create' => 'pridat','edit' => 'editovat',]);
}

我的刀

div class="container mx-auto">
    <h1 class="title text-center text-4xl pt-8">{{ $tournament->title }}</h1>
    <h2 class="title text-2xl">{{ $tournament->city }}</h2>
    <h3>{{ $tournament->street }}</h3>
    <p class="mt-8">{!! $tournament->text !!}</p>
</div>

解决方法

如果你找到更好的东西,可能是这样的

Route::get('/turnaje',[TournamentController::class,'index']);
Route::get('/turnaj/pridat','create'])
   ->middleware('auth');
Route::get('/turnaj/{tournament}','show']);

Route::resource('turnaje',TournamentController::class)->parameters([
'tournaments' => 'tournaments:slug'
])->except(['index','show','create'])->middleware('auth');