Exemple #1
0
 public function clean()
 {
     $pages = Page::onlyTrashed();
     $pageIds = $pages->get(['id'])->pluck('id', 'id');
     $trough = PageUpdate::withTrashed()->get(['id', 'entity_id'])->all();
     $same = array_filter(array_map(function ($e) use($pageIds) {
         return isset($pageIds[$e->entity_id]) ? $e->id : false;
     }, $trough));
     $updates = Update::withTrashed()->whereIn('id', $same);
     $updateIds = $updates->get(['id'])->pluck('id');
     $updates->forceDelete();
     $pages->forceDelete();
     $this->stats = ['pages' => $pageIds->toArray(), 'updates' => $updateIds->toArray()];
     return $this->stats;
 }