From: Vincent Vanwaelscappel Date: Wed, 4 Oct 2023 14:55:12 +0000 (+0200) Subject: wip #6344 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=91dac1e15bf416ac380e8f8d55c735afaab27598;p=cubist_cms-back.git wip #6344 @0.5 --- diff --git a/src/app/Http/Controllers/Base/XSendFileController.php b/src/app/Http/Controllers/Base/XSendFileController.php index ac36032..81968eb 100644 --- a/src/app/Http/Controllers/Base/XSendFileController.php +++ b/src/app/Http/Controllers/Base/XSendFileController.php @@ -12,12 +12,12 @@ class XSendFileController extends Controller return self::sendfile($path); } - public static function sendfile($path, $maxage = 86400) + public static function sendfile($path, $maxage = 86400, $headers = []) { $response = response(null); $request = request(); if (!file_exists($path)) { - abort(404,'File not found'); + abort(404, 'File not found'); } $mtime = filemtime($path); $fsize = filesize($path); @@ -32,6 +32,9 @@ class XSendFileController extends Controller } else { $response->header('Cache-Control', 'no-store'); } + foreach ($headers as $key => $value) { + $response->header($key, $value); + } return $response->header('X-Sendfile', $path); } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 9248c80..df20e33 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -37,6 +37,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection; @@ -863,13 +864,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia $cloned->model_id = $newId; $cloned->push(); // Copy files - $from = public_path('storage/' . $media->id); - $to = public_path('storage/' . $cloned->id); - if (file_exists($to)) { - `rm -rf $to`; - } - $cp = "cp -R $from $to"; - `$cp`; + $from = storage_path('app/public/' . $media->id); + $to = storage_path('app/public/' . $cloned->id); + \Cubist\Util\Files\Files::mirrorDir($from, $to); } } diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index 80afbdd..d6aba02 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -7,6 +7,9 @@ if(null===$o || $o==='null'){ return false; } + if(\Cubist\Util\Json::isJson($o)){ + $o=json_decode($o); + } if(is_scalar($o)){ return $o==$key; } @@ -22,21 +25,21 @@ if($ajax){ } @endphp - + @include('crud::fields.inc.wrapper_start') @if (isset($field['allows_multiple']) && $field['allows_multiple']==true) @endif