22
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel MassAssignmentException が出るときの対処法

Posted at

MassAssignmentException

新しく独自でモデルクラスを作ってデータをSaveしようとすると遭遇しやすいです。

Modele クラスには、必ず 下記のいずれか片方が必要になります。

Contact.php
class Contact extends Model
{
    /**
     * create()やupdate()で入力を受け付ける ホワイトリスト
     */
    protected $fillable = ['name', 'email'];

    // or

    /**
     * create()やupdate()で入力させない ブラックリスト
     */
    protected $guarded = ['id', 'is_admin', 'created_at'];
}
22
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?