/** * Delete the media from the database and from the server. * @return bool * @throws \Exception */ public function delete() { // Delete any files, including sizes. try { if ($this->sizes) { foreach ($this->sizes as $key => $url) { unlink($this->path($key)); } } unlink($this->path()); } catch (\ErrorException $e) { // File probably doesn't exist, so delete anyway. } Relationship::clear($this); return parent::delete(); }