Skip to content

Commit c476e45

Browse files
committed
minor fix on firstOrNew and firstOrCreate methods
1 parent 16bdace commit c476e45

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Contracts/RepositoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public function get($columns = ['*']): mixed;
2121

2222
public function first($columns = ['*']): mixed;
2323

24-
public function firstOrNew(array $attributes = []): mixed;
24+
public function firstOrNew(array $attributes, array $values = []): mixed;
2525

26-
public function firstOrCreate(array $attributes = []): mixed;
26+
public function firstOrCreate(array $attributes, array $values = []): mixed;
2727

2828
public function limit($limit, $columns = ['*']): mixed;
2929

src/Eloquent/BaseRepository.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,28 @@ public function first($columns = ['*']): mixed
152152
return $result;
153153
}
154154

155-
public function firstOrNew(array $attributes = []): mixed
155+
public function firstOrNew(array $attributes, array $values = []): mixed
156156
{
157157
$this->applyCriteria();
158158
$this->applyScope();
159159

160-
$model = $this->model->firstOrNew($attributes);
160+
$model = $this->model->firstOrNew($attributes, $values);
161161

162162
$this->resetModel();
163163

164164
return $model;
165165
}
166166

167-
public function firstOrCreate(array $attributes = []): mixed
167+
public function firstOrCreate(array $attributes, array $values = []): mixed
168168
{
169169
$this->applyCriteria();
170170
$this->applyScope();
171171

172-
$model = $this->model->firstOrCreate($attributes);
173-
172+
$model = $this->model->firstOrCreate($attributes, $values);
174173
$this->resetModel();
175174

175+
event(new RepositoryEntityCreated($this, $model));
176+
176177
return $model;
177178
}
178179

0 commit comments

Comments
 (0)