- $targetPath = public_path('favicon.ico');
- $original = public_path('icon.ico');
- if (!is_writeable($targetPath)) {
- return;
+ $permissionItem = file_exists($this->path) ? $this->path : dirname($this->path);
+ if (!is_writeable($permissionItem)) {
+ return false;
+ }
+
+ return copy($this->getOriginalPath(), $this->path);
+ }
+
+ /**
+ * Restore the original favicon image if no favicon image is already in use.
+ * Returns a boolean to indicate if the file exists.
+ */
+ public function restoreOriginalIfNotExists(): bool
+ {
+ if (file_exists($this->path)) {
+ return true;