Bugfix/list clickup issue (#5)
Reviewed-on: #5 Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com> Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -2,16 +2,13 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\FileResit;
|
||||
use Buglinjo\LaravelWebp\Facades\Webp;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\FileResit;
|
||||
use App\Models\LelongBid;
|
||||
use Exception;
|
||||
use Buglinjo\LaravelWebp\Facades\Webp;
|
||||
|
||||
class ResitPhotoService
|
||||
{
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$deleteFile = FileResit::where('id', '=', $request->fileresit_id)->first();
|
||||
@@ -26,7 +23,7 @@ class ResitPhotoService
|
||||
|
||||
$lelongbidmarhun_id = $deleteFile->lelongbidmarhun_id;
|
||||
|
||||
if (!empty($request->lelongbidmarhun_id)) {
|
||||
if (! empty($request->lelongbidmarhun_id)) {
|
||||
$resitImageFileName = "$lelongbidmarhun_id.$imageExtension";
|
||||
}
|
||||
|
||||
@@ -50,7 +47,7 @@ class ResitPhotoService
|
||||
|
||||
// $resitImageFileName = "{$fileresit_id}.{$imageExtension}";
|
||||
|
||||
if (!empty($fileresit_id)) {
|
||||
if (! empty($fileresit_id)) {
|
||||
$resitImageFileName = "$fileresit_id.$imageExtension";
|
||||
// dd($resitImageFileName);
|
||||
}
|
||||
@@ -60,7 +57,7 @@ class ResitPhotoService
|
||||
// dd($filePath);
|
||||
|
||||
// header('Content-Type: ' . mime_content_type($filePath));
|
||||
header('Content-Disposition: inline; filename="' . basename($filePath) . '"');
|
||||
header('Content-Disposition: inline; filename="'.basename($filePath).'"');
|
||||
readfile($filePath);
|
||||
// dd($filePath);
|
||||
}
|
||||
@@ -78,17 +75,16 @@ class ResitPhotoService
|
||||
return Storage::disk('resit')->get("{$directory}${resitImageFileName}");
|
||||
}
|
||||
|
||||
|
||||
private function getWebpCompilerByOS()
|
||||
{
|
||||
$DS = DIRECTORY_SEPARATOR;
|
||||
|
||||
$cwebp_compilers = [
|
||||
'Windows' => 'binaries' . $DS . 'libwebp-1.2.4-windows-x64' . $DS . 'bin' . $DS . 'cwebp',
|
||||
'Linux' => 'binaries' . $DS . 'libwebp-1.2.4-linux-x86-64' . $DS . 'bin' . $DS .'cwebp',
|
||||
'Windows' => 'binaries'.$DS.'libwebp-1.2.4-windows-x64'.$DS.'bin'.$DS.'cwebp',
|
||||
'Linux' => 'binaries'.$DS.'libwebp-1.2.4-linux-x86-64'.$DS.'bin'.$DS.'cwebp',
|
||||
'Darwin' => [
|
||||
'X86-64' => 'binaries' . $DS . 'libwebp-1.2.4-mac-X86-64' . $DS . 'bin' . $DS . 'cwebp',
|
||||
'arm64' => 'binaries' . $DS . 'libwebp-1.2.4-mac-arm64' . $DS . 'bin' . $DS .'cwebp',
|
||||
'X86-64' => 'binaries'.$DS.'libwebp-1.2.4-mac-X86-64'.$DS.'bin'.$DS.'cwebp',
|
||||
'arm64' => 'binaries'.$DS.'libwebp-1.2.4-mac-arm64'.$DS.'bin'.$DS.'cwebp',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -97,7 +93,7 @@ class ResitPhotoService
|
||||
|
||||
if ($server_operating_system === 'Darwin') {
|
||||
return resource_path($cwebp_compilers['Darwin'][$server_processor_architecture]);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($server_operating_system, array_keys($cwebp_compilers))) {
|
||||
return resource_path($cwebp_compilers[$server_operating_system]);
|
||||
@@ -106,11 +102,11 @@ class ResitPhotoService
|
||||
|
||||
public function optimizeImageToWebP($originalFilePath, $directory, $resitImageFileName)
|
||||
{
|
||||
$convertedFilePath = config('filesystems.disks.resit.root') . "{$directory}{$resitImageFileName}.webp";
|
||||
$convertedFilePath = config('filesystems.disks.resit.root')."{$directory}{$resitImageFileName}.webp";
|
||||
|
||||
$webpCompiler = $this->getWebpCompilerByOS();
|
||||
|
||||
exec($webpCompiler . ' -preset photo ' . '-q 10' . ' -mt ' . $originalFilePath . ' -o ' . $convertedFilePath);
|
||||
exec($webpCompiler.' -preset photo '.'-q 10'.' -mt '.$originalFilePath.' -o '.$convertedFilePath);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user