response()->error('Invalid arguments.'); } try { $path = $this->getFilePath($file); $manager = Admin::extension(); $allNames = $manager->all()->keys()->toArray(); $manager->extract($path); $manager->load(); $newAllNames = $manager->all()->keys()->toArray(); $diff = array_diff($newAllNames, $allNames); if (! $diff) { return $this->response()->error(trans('admin.invalid_extension_package')); } $manager ->updateManager() ->update(current($diff)); return $this->response() ->success(implode('
', $manager->updateManager()->notes)) ->refresh(); } catch (\Throwable $e) { Admin::reportException($e); return $this->response()->error($e->getMessage()); } finally { if (! empty($path)) { @unlink($path); } } } public function form() { $this->file('extension') ->required() ->disk($this->disk()) ->accept('zip,arc,rar,tar.gz', 'application/zip') ->autoUpload(); } protected function getFilePath($file) { $root = config("filesystems.disks.{$this->disk()}.root"); if (! $root) { throw new RuntimeException(sprintf('Missing \'root\' for disk [%s].', $this->disk())); } return rtrim($root, '/').'/'.$file; } protected function disk() { return config('admin.extension.disk') ?: 'local'; } }