Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Alternate implementation to allow "safe" objects to be used by Eloquent models (without breaking mass assignment protection) #50218

Draft
wants to merge 9 commits into
base: 11.x
Choose a base branch
from
Prev Previous commit
Next Next commit
Updated forceCreate for MorphMany
  • Loading branch information
x7ryan committed Feb 23, 2024
commit b7489581a83c42aa421d19c2d694f9e7a5a793db
8 changes: 4 additions & 4 deletions src/Illuminate/Database/Eloquent/Relations/MorphMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public function match(array $models, Collection $results, $relation)
/**
* Create a new instance of the related model. Allow mass-assignment.
*
* @param array $attributes
* @param array|\Illuminate\Support\ValidatedInput $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
public function forceCreate(array $attributes = [])
public function forceCreate($attributes = [])
{
$attributes[$this->getMorphType()] = $this->morphClass;

Expand All @@ -80,10 +80,10 @@ public function forceCreate(array $attributes = [])
/**
* Create a new instance of the related model with mass assignment without raising model events.
*
* @param array $attributes
* @param array|\Illuminate\Support\ValidatedInput $attributes
* @return \Illuminate\Database\Eloquent\Model
*/
public function forceCreateQuietly(array $attributes = [])
public function forceCreateQuietly($attributes = [])
{
return Model::withoutEvents(fn () => $this->forceCreate($attributes));
}
Expand Down