在 bool laravel 8 上调用成员函数 detail()

Call to a member function detail() on bool laravel 8

我的产品型号

    public function detail(){

    return $this->hasOne('App\Models\ProductDetails');
}

我的产品详情模型

protected $table='product_details';
public $timestamps=false;
protected $fillable=['product_id' , 'show_slider','show_opportunity_day','show_featured','show_bestseller','show_discounted'];

public function detail(){

    return $this->belongsTo('App\Models\Products');
}

我的 ProductTableSeeder

       DB::table('products')->truncate();
    DB::table('product_details')->truncate();
    $products=[
        ["product_name"=>"Domates Çorbası", "slug"=>'Domates Çorbası', 'content'=>"en iyi ürün","price"=>20 ],
        ["product_name"=>"Yayla Çorbası", "slug"=>"Yayla Çorbası", "content"=>"en iyi ürün","price"=>30],
        ["product_name"=>"Kelle Paça Çorbası", "slug"=>"Kelle Paça Çorbası", "content"=>"en iyi ürün","price"=>20],
        ["product_name"=>"Tarhana Çorbası","slug"=>"Tarhana Çorbası", "content"=>"en iyi ürün","price"=>40 ],
        ["product_name"=>"Tavuk Çorbası", "slug"=>"Tavuk Çorbası", "content"=>"en iyi ürün","price"=>10  ],
        ["product_name"=>"Mercimek Çorbası", "slug"=>"Mercimek Çorbası", "content"=>"en iyi ürün","price"=>15 ],
        ["product_name"=>"Kereviz Çorbası", "slug"=>"Kereviz Çorbası", "content"=>"en iyi ürün","price"=>25 ],
        ["product_name"=>"Şehriyeli Çorba", "slug"=>"Şehriyeli Çorba", "content"=>"en iyi ürün","price"=>22 ],
        ["product_name"=>"Havuçlu Kabak Çorbası", "slug"=>"Havuçlu Kabak Çorbası", "content"=>"en iyi ürün","price"=>14],
        ["product_name"=>"Ayran Çorbası", "slug"=>"Ayran Çorbası", "content"=>"en iyi ürün","price"=>20 ]
    ];
    foreach($products as $product){
    DB::table('products')->insert($products);
    $detail=$product->detail()->create([
        'show_slider'=>rand(0,1),
        'show_opportunity_day'=>rand(0,1),
        'show_featured'=>rand(0,1),
        'show_bestseller'=>rand(0,1),
        'show_discounted'=>rand(0,1)
    ]);
    }

$ 产品未在播种器部分定义,当我保存并刷新页面时出现错误---> 在 bool

上调用成员函数 detail()

像这样编辑种子文件

 foreach($products as $product){
    $product=Products::create($product);
    $detail=$product->detail()->create([
        'show_slider'=>rand(0,1),
        'show_opportunity_day'=>rand(0,1),
        'show_featured'=>rand(0,1),
        'show_bestseller'=>rand(0,1),
        'show_discounted'=>rand(0,1)