/** * Execute the console command. * * @return mixed */ public function handle() { clearstatcache(); $records = 0; $deleted = 0; foreach (File::with('item')->get() as $fileOb) { $file = $fileOb->getFilepath(); if ($this->checkExistance($file) || fileinode($file) !== $fileOb->inode) { $fileOb->delete(); $deleted++; } $records++; } foreach (Item::doesntHave('files')->get() as $item) { $file = $item->path; if ($this->checkExistance($file)) { $item->delete(); $deleted++; } $records++; } $this->line("{$records} processed"); $this->line("{$deleted} deleted"); }