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年前

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

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

已解决😂😂😂😂

5年前 评论
讨论数量: 5

已解决😂😂😂😂

5年前 评论

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

5年前 评论

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

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