-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupgrade.php
More file actions
65 lines (57 loc) · 1.93 KB
/
Copy pathupgrade.php
File metadata and controls
65 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
use App\Helpers\Classes\InstallationHelper;
use App\Models\OpenAIGenerator;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use App\Services\Theme\ThemeService;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
function beforeUpdate(): bool
{
return true;
}
function afterUpdate(): bool
{
/*
Yeni gelen tabloları migrate ediyoruz.
--force because the environment in production mode, are you sure? diye bir uyarı veriyor bunu atlamak
*/
Artisan::call('migrate', [
'--force' => true,
]);
$packagesToRemove = ['pcinaglia/laraupdater', 'rachidlaasri/laravel-installer'];
foreach ($packagesToRemove as $package) {
$vendorPackagePath = base_path("vendor/$package");
$packagePath = base_path("packages/$package");
if (!is_link($vendorPackagePath)) {
if (File::exists($vendorPackagePath)) {
// Check if the path exists and is not a symbolic link. If rachidlaasri/laravel-installer then remove rachidlaasri and etc
$mainFolder = dirname($vendorPackagePath, 1);
Log::info("Removing package: $vendorPackagePath");
File::deleteDirectory($mainFolder);
Log::info("Package removed: $vendorPackagePath");
// Create symlink if the target directory exists
if (!file_exists($packagePath)) {
Log::error("Package not found: $packagePath");
} else {
// Ensure the parent directory exists
$parentDirectory = dirname($vendorPackagePath);
if (!file_exists($parentDirectory)) {
mkdir($parentDirectory, 0777, true);
}
// Create the symlink
symlink($packagePath, $vendorPackagePath);
Log::info("Symlink created: $vendorPackagePath --> $packagePath");
}
} else {
Log::error("Package not found");
}
} else {
Log::error("Package is a symbolic link");
}
}
# run installation & seeds
InstallationHelper::runInstallation();
return true;
}