示例#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;
 }
示例#2
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $update = PageUpdate::withTrashed()->find($this->update);
     $page = $update->relatedPage();
     $version = $page->version($update->created_at);
     Log::info("Checking page " . $page->id . "...");
     $compare = with(new Comparator())->compareLast($version);
     if ($compare === false) {
         throw new \Exception("Page {$page->id} check failed");
     }
     if ($compare->equals()) {
         Log::info("Page {$page->id} check found no differences");
     } else {
         $update->restore();
     }
 }