Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
bug fix missing symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
fherryfherry committed Mar 27, 2017
1 parent 1dd607d commit e73305d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/CRUDBoosterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@ class CRUDBoosterServiceProvider extends ServiceProvider
public function boot()
{

//Create symlink for uploads path
if(!file_exists(public_path('uploads'))) {
app('files')->link(storage_path('app'), public_path('uploads'));
}

//Create vendor folder at public
if(!file_exists(public_path('vendor'))) {
mkdir(public_path('vendor'));
}

//Create symlink for uploads path
if(file_exists(public_path('uploads'))) {
if(readlink(public_path('uploads')) == public_path('uploads')) {
rrmdir(public_path('uploads'));
app('files')->link(storage_path('app'), public_path('uploads'));
}
}else{
app('files')->link(storage_path('app'), public_path('uploads'));
}

//Crate symlink for assets
if(!file_exists(public_path('vendor/crudbooster'))) {
if(file_exists(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster'))) {
if(readlink(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster')) == public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster')) {
//Is Directory
rrmdir(public_path('vendor'.DIRECTORY_SEPARATOR.'crudbooster'));
app('files')->link(__DIR__.'/assets',public_path('vendor/crudbooster'));
}
}else{
app('files')->link(__DIR__.'/assets',public_path('vendor/crudbooster'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/commands/CrudboosterInstallationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function handle()

$this->info('Migrating database...');
$this->call('migrate',['--seed'=>true]);
$this->call('config:cache');
$this->call('config:clear');
$this->call('optimize');

$this->info('Install CRUDBooster Is Done !');
Expand Down
2 changes: 1 addition & 1 deletion src/commands/CrudboosterUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function handle()

$this->info('Update database...');
$this->callSilent('migrate',['--seed'=>true]);
$this->call('config:cache');
$this->call('config:clear');

$this->info('Update CRUDBooster Done !');
}
Expand Down
21 changes: 21 additions & 0 deletions src/helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,24 @@ function min_var_export($input) {
return var_export($input, true);
}
}

if(!function_exists('rrmdir')) {
/*
* http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir
*/
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir."/".$object))
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
rmdir($dir);
}
}
}

0 comments on commit e73305d

Please sign in to comment.