laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Add a warning about models being unguarded during seeding. #2430

Open stephan-v opened 3 years ago

stephan-v commented 3 years ago

I think on the following page:

https://laravel.com/docs/8.x/seeding

It would be wise to add a warning about models being unguarded during seeding.

In a lot of cases I simply just dump my validated data into the model like so:

$data = $request->validated();

And then in turn do something like:

User::create($data)

And my $fillable properties will ensure only that data that should be set will get set.

Due to me having some of this logic into my observer it took quite a while to debug this and adding this to a simple documentation page like the seeding page would help out a lot without adding too much overhead.