Skip to content

Commit

Permalink
Include parent model in withDefault method example
Browse files Browse the repository at this point in the history
  • Loading branch information
mpskovvang committed Aug 5, 2019
1 parent a12edc9 commit 3146e5b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion eloquent-relationships.md
Expand Up @@ -1344,7 +1344,7 @@ To populate the default model with attributes, you may pass an array or Closure
*/
public function user()
{
return $this->belongsTo('App\User')->withDefault(function ($user) {
return $this->belongsTo('App\User')->withDefault(function ($user, $post) {
$user->name = 'Guest Author';
});
}
Expand Down

0 comments on commit 3146e5b

Please sign in to comment.