数据库列不会更新 Laravel Eloquent

Database column won't update Laravel Eloquent

我的专栏“conversion_rate”不会更新,我的“iso”专栏更新没有任何问题。我尝试更改模型中列的类型但没有任何帮助。

    $feed = simpleXML_load_file($url,LIBXML_NOCDATA);
        foreach ($feed->list->currency as $currency) {
            if (Currency::all()->contains('iso', $currency['iso_code'])) {
                Currency::where("iso", $currency['iso_code'])->get()->first()->update(['conversion_rate' => 2.00]);
            }
        }

编辑: 我的数据库结构

    Schema::create('currencies', function (Blueprint $table) {
        $table->id();
        $table->string('iso');
        $table->decimal('conversion_rate');
        $table->timestamps();
    });

您应该在模型 fillable 属性.

中添加字段
    class Currency extends Model
    {
        use HasFactory;
    
        /**
         * @var string
         */
        protected $table = 'currencies';
    
        /**
         * @var string[]
         */
        protected $fillable = ['iso', 'conversion_rate'];
     }