o = $o; } public function middleware(): array { return [new WithoutOverlapping($this->uniqueId())]; } /** * Get the unique ID for the job. */ public function uniqueId(): string { return $this->o::config.'|'.$this->o->id; } /** * Execute the job. * * @return void */ public function handle() { if (! $this->o->remove) { Log::warning(sprintf('%s: NOT Deleting [%s] not marked for deletion',__METHOD__,$this->o->file_name_rel(FALSE))); exit; } // Remove tags; if ($this->o->tags->count()) $this->o->tags()->detach(); // Remove People; if ($this->o->people->count()) $this->o->people()->detach(); // Make sure our parent is writable if (! $this->o->isParentWritable(dirname($this->o->file_name_rel(TRUE)))) { Log::warning(sprintf('%s: NOT Deleting [%s] parent directory not writable',__METHOD__,$this->o->file_name(FALSE))); $this->fail(); } // Perform delete if (file_exists($this->o->file_name(FALSE))) unlink($this->o->file_name(FALSE)); Log::warning(sprintf('%s: Deleted [%s]',__METHOD__,$this->o->file_name(FALSE))); $this->o->delete(); } }