File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ public function removeOldestIfMoreThan(int $max)
135135 $ current = $ this ->count ();
136136 if ($ current > $ max ) {
137137 $ keepers = $ this ->orderBy ('unix_time ' , 'DESC ' )->take ($ max )->pluck ($ this ->primaryKey )->toArray ();
138- if ($ this ->whereNotIn ($ this ->primaryKey , $ keepers )->get ()-> each -> delete ()) {
138+ if ($ this ->whereNotIn ($ this ->primaryKey , $ keepers )->delete ()) {
139139 return true ;
140140 }
141141 }
@@ -163,14 +163,8 @@ public function removeOlderThen(string $datetime)
163163 public function removeOlderThan (string $ datetime )
164164 {
165165 $ unixtime = strtotime ($ datetime );
166- $ deletes = $ this ->where ('unix_time ' , '<= ' , $ unixtime )->get ();
166+ $ count = $ this ->where ('unix_time ' , '<= ' , $ unixtime )->delete ();
167167
168- if (!$ deletes ->isEmpty ()) {
169- if ($ deletes ->each ->delete ()) {
170- return true ;
171- }
172- }
173-
174- return false ;
168+ return $ count > 0 ;
175169 }
176170}
You can’t perform that action at this time.
0 commit comments