Closed antonkomarev closed 5 years ago
$owner = NotUserModel::first(); OwnableModel::withDefaultOwner($owner)->create([ 'title' => 'Test title', ]); OwnableModel::create([ 'title' => 'Test title', ])->withDefaultOwner($owner);
Both of this variants wouldn't work.
To set owners on creation this variants could be used:
$owner = NotUserModel::first(); $model = OwnableModel::create([ 'title' => 'Test title', ]); $model->withDefaultOwner($owner); $model->save();
$owner = NotUserModel::first(); $model = (new OwnableModel([ 'title' => 'Test title', ]))->withDefaultOwner($owner)->save();
Both of this variants wouldn't work.
To set owners on creation this variants could be used: