File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,23 @@ public function map(callable $callback)
280280 }) ? $ result ->toBase () : $ result ;
281281 }
282282
283+ /**
284+ * Run an associative map over each of the items.
285+ *
286+ * The callback should return an associative array with a single key / value pair.
287+ *
288+ * @param callable $callback
289+ * @return \Illuminate\Support\Collection|static
290+ */
291+ public function mapWithKeys (callable $ callback )
292+ {
293+ $ result = parent ::mapWithKeys ($ callback );
294+
295+ return $ result ->contains (function ($ item ) {
296+ return ! $ item instanceof Model;
297+ }) ? $ result ->toBase () : $ result ;
298+ }
299+
283300 /**
284301 * Reload a fresh model instance from the database for all the entities.
285302 *
Original file line number Diff line number Diff line change @@ -286,6 +286,8 @@ public function newQueryForRestoration($ids)
286286 */
287287 protected function newQueryForCollectionRestoration (array $ ids )
288288 {
289+ $ ids = array_values ($ ids );
290+
289291 if (! Str::contains ($ ids [0 ], ': ' )) {
290292 return parent ::newQueryForRestoration ($ ids );
291293 }
Original file line number Diff line number Diff line change @@ -139,6 +139,8 @@ public function newQueryForRestoration($ids)
139139 */
140140 protected function newQueryForCollectionRestoration (array $ ids )
141141 {
142+ $ ids = array_values ($ ids );
143+
142144 if (! Str::contains ($ ids [0 ], ': ' )) {
143145 return parent ::newQueryForRestoration ($ ids );
144146 }
You can’t perform that action at this time.
0 commit comments