App\Console\Commands\RemoveOrphanedDocuments::fire PHP Method

fire() public method

public fire ( )
    public function fire()
    {
        $this->info(date('Y-m-d') . ' Running RemoveOrphanedDocuments...');
        $documents = Document::whereRaw('invoice_id IS NULL AND expense_id IS NULL AND updated_at <= ?', [new DateTime('-1 hour')])->get();
        $this->info(count($documents) . ' orphaned document(s) found');
        foreach ($documents as $document) {
            $document->delete();
        }
        $this->info('Done');
    }
RemoveOrphanedDocuments