Отсутствуют обязательные параметры при использовании привязки модели маршрута - PullRequest
0 голосов
/ 01 апреля 2020

мой код работает нормально, когда я использую {id}, но я получаю ошибку, когда я использую привязку модели маршрута

Missing required parameters for [Route: customs.createCustom] [URI: administrator/customs/createCustom/{product}]. (View: C:\xampp\htdocs\site\resources\views\admin\customField\index.blade.php)

это моя сеть. php

 Route::resource('/customs','CustomController');
 Route::get('/customs/createCustom/{product}', 'CustomController@createCustom')->name('customs.createCustom');
 Route::Post('/customs/store/{id}', 'CustomController@storeCustom')->name('customs.storeCustom');

это CustomController

public function createCustom(Product $product)
    {
        return view('admin.customField.create',compact('product'));
    }
  public function storeCustom(CustomRequest $request,Product $product )
    {
        $customValues = $request->validated();
        $custom = Custom::create([
            'key' => $customValues['key'],
            'type' => $customValues['type'],
            'description' => $customValues['description'],
            'product_id' => $product['id'],
        ]);
        return redirect(route('customs.show',$product_id));
    }
public function show(Product $product)
    {
        $customs = $product->customs;
        return view('admin.customField.index',compact('customs','product'));
    }

это ссылка на вид

 <a href="{{route('customs.createCustom',$product->id)}}" type="button" class="btn btn-primary">create</a>

Может кто-нибудь помочь мне, почему эта ошибка происходит?

...