introduction 字段无法被更新

introduction字段使用update方法更新失败,查看手册后发现批量操作必须定义$fillable属性,$fillable属性定义了哪些字段可以被批量更新,经过测试去除name字段后用户名也更新失败,$fillable属性里面应该加上introduction字段

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail as MustVerifyEmailContract;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Auth\MustVerifyEmail as MustVerifyEmailTrait;

class User extends Authenticatable implements MustVerifyEmailContract
{
    use Notifiable, MustVerifyEmailTrait;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password', 'introduction',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}
附言 1  ·  5年前

?后面的章节讲了这个,找了半天错误在哪????

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

已解决😂😂😂😂

5年前 评论
讨论数量: 5

已解决😂😂😂😂

5年前 评论

之前学了上一课,所以我知道是这里问题

5年前 评论

我也找了半天... 甚至还学会了记录sql日志

5年前 评论
Fan2023 2年前
Ailon 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!