/** * Return the output path. * * @param $collection * @return string */ public function outputPath($collection) { /** * If the path is already public * then just use it as it is. */ if (str_contains($collection, public_path())) { return str_replace(public_path(), '', $collection); } /** * Get the real path relative to our installation. */ $path = str_replace(base_path(), '', $this->realPath($collection)); /** * Build out path parts. */ $directory = ltrim(dirname($path), '/\\') . '/'; $application = $this->application->getReference(); $filename = basename($path, $this->extension($path)) . $this->hint($path); if (starts_with($directory, 'vendor/')) { $directory = substr($directory, 7); } if (starts_with($directory, './')) { $directory = in_array($this->request->segment(1), ['admin', 'installer']) ? 'admin/' : 'public/'; } return "/app/{$application}/assets/{$directory}{$filename}"; }
/** * Return all application addon paths in a given folder. * * @return bool */ public function application() { $path = base_path('addons/' . $this->application->getReference()); if (!is_dir($path)) { return false; } return $this->vendorAddons(glob("{$path}/*", GLOB_ONLYDIR)); }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $shared = $this->command->option('shared') ? 'shared' : $application->getReference(); $path = base_path("addons/{$shared}/{$this->vendor}/{$this->slug}-{$this->type}"); $config = "{$path}/resources/config"; $views = "{$path}/resources/views"; $filesystem->makeDirectory($path, 0755, true, true); $filesystem->makeDirectory($views, 0755, true, true); $filesystem->makeDirectory($config, 0755, true, true); return $path; }
/** * Handle the command. * * @param Filesystem $filesystem * @param Application $application * @return string */ public function handle(Filesystem $filesystem, Application $application) { $reference = $this->command->option('shared') ? 'shared' : $application->getReference(); $path = base_path("addons/{$reference}/{$this->vendor}/{$this->slug}-{$this->type}"); $modulePath = __DIR__ . '/../../../resources/assets/module'; $data = $this->getTemplateData(); /* Make module's folder */ $filesystem->makeDirectory($path, 0755, true, true); /* Copy module template files */ $filesystem->parseDirectory($modulePath . "/template", $path . '/', $data); return $path; }
/** * Return the output path for an image. * * @param $path * @return string */ public function outputPath(Image $image) { $path = $image->getImage(); if ($path instanceof FileInterface) { $path = $path->path(); } /** * If the path is already public * then just use it as it is. */ if (str_contains($path, public_path())) { return str_replace(public_path(), '', $path); } /** * If the path is a file or file path then * put it in /app/{$application}/files/disk/folder/filename.ext */ if (is_string($path) && str_is('*://*', $path)) { $application = $this->application->getReference(); list($disk, $folder, $filename) = explode('/', str_replace('://', '/', $path)); if ($rename = $image->getFilename()) { $filename = $rename; if (strpos($filename, DIRECTORY_SEPARATOR)) { $directory = null; } } return "/app/{$application}/files/{$disk}/{$folder}/{$filename}"; } /** * Get the real path relative to our installation. */ $path = str_replace(base_path(), '', $this->realPath($path)); /** * Build out path parts. */ $filename = basename($path); $directory = ltrim(dirname($path), '/\\') . '/'; $application = $this->application->getReference(); if ($image->getAlterations() || $image->getQuality()) { $filename = md5(var_export([$path, $image->getAlterations()], true) . $image->getQuality()) . '.' . $image->getExtension(); } if ($rename = $image->getFilename()) { $directory = null; $filename = ltrim($rename, '/\\'); } return "/app/{$application}/assets/{$directory}{$filename}"; }