File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ public function get($columns = ['*']): mixed;
2121
2222 public function first ($ columns = ['* ' ]): mixed ;
2323
24+ public function firstWhere (array $ where , $ columns = ['* ' ]): mixed ;
25+
2426 public function firstOrNew (array $ attributes , array $ values = []): mixed ;
2527
2628 public function firstOrCreate (array $ attributes , array $ values = []): mixed ;
Original file line number Diff line number Diff line change @@ -152,6 +152,20 @@ public function first($columns = ['*']): mixed
152152 return $ result ;
153153 }
154154
155+ public function firstWhere (array $ where , $ columns = ['* ' ]): mixed
156+ {
157+ $ this ->applyCriteria ();
158+ $ this ->applyScope ();
159+
160+ $ this ->applyConditions ($ where );
161+
162+ $ result = $ this ->model ->first ($ columns );
163+
164+ $ this ->resetModel ();
165+
166+ return $ result ;
167+ }
168+
155169 public function firstOrNew (array $ attributes , array $ values = []): mixed
156170 {
157171 $ this ->applyCriteria ();
You can’t perform that action at this time.
0 commit comments