Laravel Illumb\Database\QueryException SQLSTATE[22007]:无效的日期时间格式:1366不正确的双精度值:';必需的';

Laravel Illumb\Database\QueryException SQLSTATE[22007]:无效的日期时间格式:1366不正确的双精度值:';必需的';,laravel,eloquent,model,controller,laravel-8,Laravel,Eloquent,Model,Controller,Laravel 8,当我尝试在模型中写入$fillable时,出现了以下错误。 Illumb\Database\QueryException SQLSTATE[22007]:无效的日期时间格式:1366不正确的双精度值:db\U productmanagementsystemproducts第1行(SQL:insert intoproducts(标题,类型,名字,姓氏,价格,papl,更新,创建) 模型:Product.php <?php namespace App\Models; use Illumin

当我尝试在模型中写入$fillable时,出现了以下错误。 Illumb\Database\QueryException SQLSTATE[22007]:无效的日期时间格式:1366不正确的双精度值:
db\U productmanagementsystem
products
第1行(SQL:insert into
products
标题
类型
名字
姓氏
价格
papl
更新
创建

模型:Product.php

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = ['title', 'type', 'firstname', 'surname', 'price', 'papl'];
    //use HasFactory;
}

您没有为您的产品型号提供正确的价值。

重新检查您的存储方法

Product::create([
        'title' => 'required',
        'type' => 'required',
        'firstname' => 'required',
        'surname' => 'required',
        'price' => 'required', // here you passed a string. but this field type is double in the database schema
        'papl' => 'required'
]);

您应该从请求中获取产品值:

 Product::create([
            'title' => $request->input( 'title'),
            'type' => $request->input('type'),
            'firstname' => $request->input('firstname'),
            'surname' => $request->input('surname'),
            'price' => $request->input('price'),
            'papl' => $request->input('papl')
        ]);
 Product::create([
            'title' => $request->input( 'title'),
            'type' => $request->input('type'),
            'firstname' => $request->input('firstname'),
            'surname' => $request->input('surname'),
            'price' => $request->input('price'),
            'papl' => $request->input('papl')
        ]);