1

в шаблоне вызываю метод:

@if($worldCup->rounds->count() == 0)
<a type="button" style="margin-right: 3px;" class="btn btn-xs btn-info" href="{{action('WorldCupsController@resort_stage_1'  ,$worldCup->id)}}"><i class="fa fa-connectdevelop"></i> Shuffle</a>

Но в контроллере:

public function resort_stage_1(WorldCup $worldCup)
    {
        $worldCup->load('teams');
        return view('wc.admin.resort_stage_1',compact('worldCup'));
    }

переменная $worldcup пустая, а не из шаблона. Почему не передает переменную в контроллер?

В файле routes:

Route::get( 'wc/{worldCups}/resort_stage_1',              
          ['as' => 'admin.wc.resort.get',         
          'uses' =>  'WorldCupsController@resort_stage_1']);

2 ответа 2

2

Имя переменной и параметра вроде как должно совпадать чтобы каст сработал.

Route::get('wc/{worldCup}/resort_stage_1','WorldCupsController@resort_stage_1')
    ->name('admin.wc.resort.get');

Route Model Binding Laravel Docs

0

Не прописал $router->model('worldCup', 'App\WorldCup');в RouteServiceProvider.php

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.