Add wabot setup in env.exam, fix ResitPhotoService
This commit is contained in:
@@ -300,3 +300,7 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
MARHUN_CAMERAS = "Doccamera"
|
||||
|
||||
WABOT_API=https://md.wabot.my/api/send.php
|
||||
WABOT_INSTANCES_ID=63C26B7AAD21A
|
||||
WABOT_TOKEN_KEYS=cbee7e95cf3ffbfa0531d5fddfd44f87
|
||||
@@ -1245,7 +1245,7 @@ class LelongMobileController extends Controller
|
||||
foreach($file_resit as $index => $resit)
|
||||
{
|
||||
$date_convert = strtotime($resit->created_at);
|
||||
$updatedDateTime = date("d-m-Y H:i", $date_convert);
|
||||
$updatedDateTime = date("d-m-Y H:i:s", $date_convert);
|
||||
$file_resit[$index]['masa_upload'] = $updatedDateTime;
|
||||
}
|
||||
|
||||
@@ -1277,6 +1277,25 @@ class LelongMobileController extends Controller
|
||||
$resitImageFileName = $addfile->id;
|
||||
|
||||
Storage::disk('resit')->putFileAs($directory, $request->gambarResit, "${resitImageFileName}.${imageExtension}");
|
||||
$stored_path = Storage::disk('resit')->path("{$directory}{$resitImageFileName}.${imageExtension}");
|
||||
$resitPhotoService = new ResitPhotoService();
|
||||
|
||||
// try {
|
||||
|
||||
$convertToWebP = $resitPhotoService->optimizeImageToWebP($stored_path, $directory, $resitImageFileName);
|
||||
|
||||
// } catch (\Exception $e)
|
||||
|
||||
// {
|
||||
// return $e;
|
||||
// }
|
||||
|
||||
|
||||
Storage::disk('resit')->delete("{$directory}${resitImageFileName}.${imageExtension}");
|
||||
|
||||
$addfile->update([
|
||||
'file_type' => 'webp',
|
||||
]);
|
||||
|
||||
return response()->json(['success' => true]);
|
||||
}
|
||||
|
||||
@@ -12,53 +12,6 @@ use Buglinjo\LaravelWebp\Facades\Webp;
|
||||
class ResitPhotoService
|
||||
{
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
|
||||
try {
|
||||
$file_type = $request->gambarMarhun->getClientOriginalExtension();
|
||||
} catch (Exception $exception) {
|
||||
$file_type = 'PNG';
|
||||
logger($exception);
|
||||
}
|
||||
|
||||
$addfile = new FileResit();
|
||||
$addfile->lelong_id = $request->lelong_id;
|
||||
$addfile->file_type = $file_type;
|
||||
if ($request->photo_type == 1) {
|
||||
$addfile->photo_type = 1;
|
||||
$addfile->save();
|
||||
} elseif ($request->photo_type == 2) {
|
||||
$addfile->photo_type = 2;
|
||||
$addfile->lelong_id = $request->lelong_id;
|
||||
$addfile->save();
|
||||
}
|
||||
|
||||
$user_id = LelongBid::select('norujukan')->where('id', $request->lelongbid_id)->first()->norujukan;
|
||||
$photo_type_name = $request->photo_type === '1' ? 'overall_photo' : 'by_marhun_photo';
|
||||
|
||||
$directory = "/{$user_id}/{$photo_type_name}/";
|
||||
$imageExtension = $file_type;
|
||||
|
||||
$resitImageFileName = "overall";
|
||||
|
||||
|
||||
if (!empty($request->lelongbidmarhun_id)) {
|
||||
$resitImageFileName = "$request->lelongbidmarhun_id";
|
||||
}
|
||||
|
||||
Storage::disk('resit')->putFileAs($directory, $request->gambarMarhun, "${resitImageFileName}.${imageExtension}");
|
||||
$stored_path = Storage::disk('marhun')->path("{$directory}{$resitImageFileName}.${imageExtension}");
|
||||
|
||||
$this->optimizeImageToWebP($stored_path, $directory, $resitImageFileName);
|
||||
|
||||
Storage::disk('resit')->delete("{$directory}${resitImageFileName}.${imageExtension}");
|
||||
|
||||
$addfile->update([
|
||||
'file_type' => 'webp',
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$deleteFile = FileResit::where('id', '=', $request->fileresit_id)->first();
|
||||
@@ -151,12 +104,13 @@ class ResitPhotoService
|
||||
}
|
||||
}
|
||||
|
||||
private function optimizeImageToWebP($originalFilePath, $directory, $lelongbidmarhun_id)
|
||||
public function optimizeImageToWebP($originalFilePath, $directory, $resitImageFileName)
|
||||
{
|
||||
$convertedFilePath = config('filesystems.disks.resit.root') . '/' . "{$directory}{$lelongbidmarhun_id}.webp";
|
||||
$convertedFilePath = config('filesystems.disks.resit.root') . "{$directory}{$resitImageFileName}.webp";
|
||||
|
||||
$webpCompiler = $this->getWebpCompilerByOS();
|
||||
|
||||
exec($webpCompiler . ' -preset photo ' . ' -resize 1280 720 ' . ' -mt ' . $originalFilePath . ' -o ' . $convertedFilePath);
|
||||
exec($webpCompiler . ' -preset photo ' . '-q 10' . ' -mt ' . $originalFilePath . ' -o ' . $convertedFilePath);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user