more storage fixes
This commit is contained in:
parent
0b45e4ed70
commit
02881945f8
@ -4,7 +4,6 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class StorageTempClear extends Command
|
class StorageTempClear extends Command
|
||||||
{
|
{
|
||||||
@ -32,7 +31,7 @@ class StorageTempClear extends Command
|
|||||||
{
|
{
|
||||||
$filesystem = app(Filesystem::class);
|
$filesystem = app(Filesystem::class);
|
||||||
|
|
||||||
$path = Storage::path('app/temp');
|
$path = get_storage_path('app/temp');
|
||||||
|
|
||||||
foreach ($filesystem->glob("{$path}/*") as $file) {
|
foreach ($filesystem->glob("{$path}/*") as $file) {
|
||||||
$filesystem->delete($file);
|
$filesystem->delete($file);
|
||||||
|
@ -5,7 +5,6 @@ namespace App\Jobs\Install;
|
|||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class CopyFiles extends Job
|
class CopyFiles extends Job
|
||||||
{
|
{
|
||||||
@ -36,7 +35,7 @@ class CopyFiles extends Job
|
|||||||
throw new \Exception(trans('modules.errors.file_copy', ['module' => $this->alias]));
|
throw new \Exception(trans('modules.errors.file_copy', ['module' => $this->alias]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$source = Storage::path('app/temp/' . $this->path);
|
$source = storage_path('app/temp/' . $this->path);
|
||||||
|
|
||||||
$destination = $this->getDestination($source);
|
$destination = $this->getDestination($source);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ use App\Abstracts\Job;
|
|||||||
use App\Traits\SiteApi;
|
use App\Traits\SiteApi;
|
||||||
use App\Utilities\Info;
|
use App\Utilities\Info;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
class DownloadFile extends Job
|
class DownloadFile extends Job
|
||||||
{
|
{
|
||||||
@ -48,7 +47,7 @@ class DownloadFile extends Job
|
|||||||
}
|
}
|
||||||
|
|
||||||
$path = 'temp-' . md5(mt_rand());
|
$path = 'temp-' . md5(mt_rand());
|
||||||
$temp_path = Storage::path('app/temp/' . $path);
|
$temp_path = storage_path('app/temp/' . $path);
|
||||||
|
|
||||||
$file_path = $temp_path . '/upload.zip';
|
$file_path = $temp_path . '/upload.zip';
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ namespace App\Jobs\Install;
|
|||||||
|
|
||||||
use App\Abstracts\Job;
|
use App\Abstracts\Job;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use ZipArchive;
|
use ZipArchive;
|
||||||
|
|
||||||
class UnzipFile extends Job
|
class UnzipFile extends Job
|
||||||
@ -36,7 +35,7 @@ class UnzipFile extends Job
|
|||||||
throw new \Exception(trans('modules.errors.unzip', ['module' => $this->alias]));
|
throw new \Exception(trans('modules.errors.unzip', ['module' => $this->alias]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp_path = Storage::path('app/temp/' . $this->path);
|
$temp_path = storage_path('app/temp/' . $this->path);
|
||||||
|
|
||||||
$file = $temp_path . '/upload.zip';
|
$file = $temp_path . '/upload.zip';
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ use App\Abstracts\Notification;
|
|||||||
use App\Models\Banking\Transaction as Model;
|
use App\Models\Banking\Transaction as Model;
|
||||||
use App\Models\Setting\EmailTemplate;
|
use App\Models\Setting\EmailTemplate;
|
||||||
use App\Traits\Transactions;
|
use App\Traits\Transactions;
|
||||||
|
use Illuminate\Mail\Attachment;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class Transaction extends Notification
|
class Transaction extends Notification
|
||||||
{
|
{
|
||||||
@ -63,9 +63,12 @@ class Transaction extends Notification
|
|||||||
|
|
||||||
// Attach the PDF file
|
// Attach the PDF file
|
||||||
if ($this->attach_pdf) {
|
if ($this->attach_pdf) {
|
||||||
$message->attach($this->storeTransactionPdfAndGetPath($this->transaction), [
|
$func = is_local_storage() ? 'fromPath' : 'fromStorage';
|
||||||
'mime' => 'application/pdf',
|
|
||||||
]);
|
$path = $this->storeTransactionPdfAndGetPath($this->transaction);
|
||||||
|
$file = Attachment::$func($path)->withMime('application/pdf');
|
||||||
|
|
||||||
|
$message->attach($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
|
@ -7,9 +7,9 @@ use App\Models\Banking\Transaction;
|
|||||||
use App\Models\Setting\EmailTemplate;
|
use App\Models\Setting\EmailTemplate;
|
||||||
use App\Models\Document\Document;
|
use App\Models\Document\Document;
|
||||||
use App\Traits\Documents;
|
use App\Traits\Documents;
|
||||||
|
use Illuminate\Mail\Attachment;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class PaymentReceived extends Notification
|
class PaymentReceived extends Notification
|
||||||
{
|
{
|
||||||
@ -67,9 +67,12 @@ class PaymentReceived extends Notification
|
|||||||
|
|
||||||
// Attach the PDF file
|
// Attach the PDF file
|
||||||
if ($this->attach_pdf) {
|
if ($this->attach_pdf) {
|
||||||
$message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
|
$func = is_local_storage() ? 'fromPath' : 'fromStorage';
|
||||||
'mime' => 'application/pdf',
|
|
||||||
]);
|
$path = $this->storeDocumentPdfAndGetPath($this->invoice);
|
||||||
|
$file = Attachment::$func($path)->withMime('application/pdf');
|
||||||
|
|
||||||
|
$message->attach($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
|
@ -6,9 +6,9 @@ use App\Abstracts\Notification;
|
|||||||
use App\Models\Setting\EmailTemplate;
|
use App\Models\Setting\EmailTemplate;
|
||||||
use App\Models\Document\Document;
|
use App\Models\Document\Document;
|
||||||
use App\Traits\Documents;
|
use App\Traits\Documents;
|
||||||
|
use Illuminate\Mail\Attachment;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class Invoice extends Notification
|
class Invoice extends Notification
|
||||||
{
|
{
|
||||||
@ -69,21 +69,27 @@ class Invoice extends Notification
|
|||||||
|
|
||||||
$message = $this->initMailMessage();
|
$message = $this->initMailMessage();
|
||||||
|
|
||||||
|
$func = is_local_storage() ? 'fromPath' : 'fromStorage';
|
||||||
|
|
||||||
// Attach the PDF file
|
// Attach the PDF file
|
||||||
if ($this->attach_pdf) {
|
if ($this->attach_pdf) {
|
||||||
$message->attach($this->storeDocumentPdfAndGetPath($this->invoice), [
|
$path = $this->storeDocumentPdfAndGetPath($this->invoice);
|
||||||
'mime' => 'application/pdf',
|
$file = Attachment::$func($path)->withMime('application/pdf');
|
||||||
]);
|
|
||||||
|
$message->attach($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach selected attachments
|
// Attach selected attachments
|
||||||
if (! empty($this->invoice->attachment)) {
|
if (! empty($this->invoice->attachment)) {
|
||||||
foreach ($this->invoice->attachment as $attachment) {
|
foreach ($this->invoice->attachment as $attachment) {
|
||||||
if (in_array($attachment->id, $this->attachments)) {
|
if (! in_array($attachment->id, $this->attachments)) {
|
||||||
$message->attach($attachment->getAbsolutePath(), [
|
continue;
|
||||||
'mime' => $attachment->mime_type,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$path = is_local_storage() ? $attachment->getAbsolutePath() : $attachment->getDiskPath();
|
||||||
|
$file = Attachment::$func($path)->withMime($attachment->mime_type);
|
||||||
|
|
||||||
|
$message->attach($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ use Egulias\EmailValidator\Validation\MultipleValidationWithAnd;
|
|||||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
trait Documents
|
trait Documents
|
||||||
{
|
{
|
||||||
@ -188,7 +187,7 @@ trait Documents
|
|||||||
|
|
||||||
$file_name = $this->getDocumentFileName($document);
|
$file_name = $this->getDocumentFileName($document);
|
||||||
|
|
||||||
$pdf_path = Storage::path('app/temp/' . $file_name);
|
$pdf_path = get_storage_path('app/temp/' . $file_name);
|
||||||
|
|
||||||
// Save the PDF file into temp folder
|
// Save the PDF file into temp folder
|
||||||
$pdf->save($pdf_path);
|
$pdf->save($pdf_path);
|
||||||
|
@ -6,7 +6,6 @@ use App\Events\Banking\TransactionPrinting;
|
|||||||
use App\Models\Banking\Transaction;
|
use App\Models\Banking\Transaction;
|
||||||
use App\Interfaces\Utility\TransactionNumber;
|
use App\Interfaces\Utility\TransactionNumber;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
|
|
||||||
trait Transactions
|
trait Transactions
|
||||||
{
|
{
|
||||||
@ -162,7 +161,7 @@ trait Transactions
|
|||||||
|
|
||||||
$file_name = $this->getTransactionFileName($transaction);
|
$file_name = $this->getTransactionFileName($transaction);
|
||||||
|
|
||||||
$pdf_path = Storage::path('app/temp/' . $file_name);
|
$pdf_path = get_storage_path('app/temp/' . $file_name);
|
||||||
|
|
||||||
// Save the PDF file into temp folder
|
// Save the PDF file into temp folder
|
||||||
$pdf->save($pdf_path);
|
$pdf->save($pdf_path);
|
||||||
|
@ -6,6 +6,7 @@ use App\Traits\Sources;
|
|||||||
use App\Traits\Modules;
|
use App\Traits\Modules;
|
||||||
use App\Utilities\Date;
|
use App\Utilities\Date;
|
||||||
use App\Utilities\Widgets;
|
use App\Utilities\Widgets;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
if (! function_exists('user')) {
|
if (! function_exists('user')) {
|
||||||
/**
|
/**
|
||||||
@ -248,3 +249,37 @@ if (! function_exists('env_is_testing')) {
|
|||||||
return config('app.env') === 'testing';
|
return config('app.env') === 'testing';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('is_local_storage')) {
|
||||||
|
/**
|
||||||
|
* Determine if the storage is local.
|
||||||
|
*/
|
||||||
|
function is_local_storage(): bool
|
||||||
|
{
|
||||||
|
$driver = config('filesystems.disks.' . config('filesystems.default') . '.driver');
|
||||||
|
|
||||||
|
return $driver == 'local';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('is_cloud_storage')) {
|
||||||
|
/**
|
||||||
|
* Determine if the storage is cloud.
|
||||||
|
*/
|
||||||
|
function is_cloud_storage(): bool
|
||||||
|
{
|
||||||
|
return ! is_local_storage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('get_storage_path')) {
|
||||||
|
/**
|
||||||
|
* Get the path from the storage.
|
||||||
|
*/
|
||||||
|
function get_storage_path(string $path = ''): string
|
||||||
|
{
|
||||||
|
return is_local_storage()
|
||||||
|
? storage_path($path)
|
||||||
|
: Storage::path($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
|
'disk' => env('DOMPDF_DISK', null),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Settings
|
| Settings
|
||||||
|
@ -81,6 +81,7 @@ return [
|
|||||||
'local' => [
|
'local' => [
|
||||||
'driver' => 'local',
|
'driver' => 'local',
|
||||||
'root' => storage_path('app'),
|
'root' => storage_path('app'),
|
||||||
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'public' => [
|
'public' => [
|
||||||
@ -88,6 +89,7 @@ return [
|
|||||||
'root' => storage_path('app/public'),
|
'root' => storage_path('app/public'),
|
||||||
'url' => app()->runningInConsole() ? '' : url('/') . '/storage',
|
'url' => app()->runningInConsole() ? '' : url('/') . '/storage',
|
||||||
'visibility' => 'public',
|
'visibility' => 'public',
|
||||||
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'temp' => [
|
'temp' => [
|
||||||
@ -95,6 +97,7 @@ return [
|
|||||||
'root' => storage_path('app/temp'),
|
'root' => storage_path('app/temp'),
|
||||||
'url' => app()->runningInConsole() ? '' : url('/') . '/temp',
|
'url' => app()->runningInConsole() ? '' : url('/') . '/temp',
|
||||||
'visibility' => 'private',
|
'visibility' => 'private',
|
||||||
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
'uploads' => [
|
'uploads' => [
|
||||||
@ -102,6 +105,7 @@ return [
|
|||||||
'root' => storage_path('app/uploads'),
|
'root' => storage_path('app/uploads'),
|
||||||
'url' => app()->runningInConsole() ? '' : url('/') . '/uploads',
|
'url' => app()->runningInConsole() ? '' : url('/') . '/uploads',
|
||||||
'visibility' => 'private',
|
'visibility' => 'private',
|
||||||
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
's3' => [
|
's3' => [
|
||||||
@ -115,6 +119,7 @@ return [
|
|||||||
'endpoint' => env('AWS_ENDPOINT'),
|
'endpoint' => env('AWS_ENDPOINT'),
|
||||||
'visibility' => env('AWS_VISIBILITY', 'private'),
|
'visibility' => env('AWS_VISIBILITY', 'private'),
|
||||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||||
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user