Merge branch 'master' of https://github.com/livindra/api_sijentik
|
|
@ -16,6 +16,8 @@
|
||||||
/public/build
|
/public/build
|
||||||
/public/hot
|
/public/hot
|
||||||
/public/storage
|
/public/storage
|
||||||
|
/public/profile
|
||||||
|
/public/laporan
|
||||||
/storage/*.key
|
/storage/*.key
|
||||||
/storage/pail
|
/storage/pail
|
||||||
/vendor
|
/vendor
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class StorageLinkSafe extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'storage:link-safe';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create symbolic links for storage without failing if they already exist';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$links = config('filesystems.links', [
|
||||||
|
public_path('storage') => storage_path('app/public'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($links as $link => $target) {
|
||||||
|
if (is_link($link)) {
|
||||||
|
$this->line("The [{$link}] link already exists. Skipping.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_dir($link)) {
|
||||||
|
$this->warn("A directory already exists at [{$link}]. Removing it before creating the symlink.");
|
||||||
|
$this->removeDirectory($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_exists($link)) {
|
||||||
|
$this->warn("A file already exists at [{$link}]. Removing it before creating the symlink.");
|
||||||
|
unlink($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_dir($target)) {
|
||||||
|
mkdir($target, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
symlink($target, $link);
|
||||||
|
$this->info("The [{$link}] link has been connected to [{$target}].");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Storage links created successfully.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively remove a directory and its contents.
|
||||||
|
*/
|
||||||
|
protected function removeDirectory(string $dir): void
|
||||||
|
{
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = array_diff(scandir($dir), ['.', '..']);
|
||||||
|
|
||||||
|
foreach ($items as $item) {
|
||||||
|
$path = $dir . DIRECTORY_SEPARATOR . $item;
|
||||||
|
if (is_dir($path) && !is_link($path)) {
|
||||||
|
$this->removeDirectory($path);
|
||||||
|
} else {
|
||||||
|
unlink($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rmdir($dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 6.2 MiB |
|
Before Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 448 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 448 KiB |
|
Before Width: | Height: | Size: 344 KiB |
|
Before Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 1.9 MiB |
|
Before Width: | Height: | Size: 448 KiB |
|
|
@ -1,2 +1,8 @@
|
||||||
*
|
*
|
||||||
!.gitignore
|
!.gitignore
|
||||||
|
!profile/
|
||||||
|
!laporan/
|
||||||
|
profile/*
|
||||||
|
!profile/.gitkeep
|
||||||
|
laporan/*
|
||||||
|
!laporan/.gitkeep
|
||||||
|
|
|
||||||