test
This commit is contained in:
@@ -63,15 +63,7 @@ class Update extends FormRequest
|
||||
public function getPoster(Product $product): string
|
||||
{
|
||||
if ($this->hasFile('poster')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->poster);
|
||||
} else {
|
||||
// delete old file
|
||||
$oldPath = public_path($product->poster);
|
||||
if (is_file($oldPath)) unlink($oldPath);
|
||||
}
|
||||
|
||||
Storage::delete($product->poster);
|
||||
$folder = "uploads/posters/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('poster')->store($folder);
|
||||
}
|
||||
@@ -85,13 +77,9 @@ class Update extends FormRequest
|
||||
public function getCalc(Product $product): string|null
|
||||
{
|
||||
if ($this->hasFile('calc')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3' and $product->calc) {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->calc);
|
||||
} elseif($product->calc) {
|
||||
unlink($product->calc);
|
||||
if ($product->calc) {
|
||||
Storage::delete($product->calc);
|
||||
}
|
||||
|
||||
$folder = "uploads/calc/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('calc')->store($folder);
|
||||
}
|
||||
@@ -101,11 +89,9 @@ class Update extends FormRequest
|
||||
public function getDataSheet(Product $product)
|
||||
{
|
||||
if ($this->hasFile('data_sheet')) {
|
||||
|
||||
if (is_file($this->get('data_sheet'))) {
|
||||
unlink($this->get("data_sheet"));
|
||||
if ($product->data_sheet) {
|
||||
Storage::delete($product->data_sheet);
|
||||
}
|
||||
|
||||
$folder = "uploads/datasheet/" . Carbon::now()->format('Y/m/d');
|
||||
return (string) $this->file('data_sheet')->store($folder);
|
||||
}
|
||||
@@ -119,18 +105,8 @@ class Update extends FormRequest
|
||||
public function getPosterThumb(Product $product): string
|
||||
{
|
||||
if ($this->hasFile('poster')) {
|
||||
if (env('FILESYSTEM_DISK') == 's3') {
|
||||
// delete old file from s3
|
||||
Storage::disk('s3')->delete($product->poster_thumb);
|
||||
} else {
|
||||
// delete old file local
|
||||
$oldPath = public_path($product->poster_thumb);
|
||||
if (is_file($oldPath)) unlink($oldPath);
|
||||
}
|
||||
|
||||
$image = $this->file('poster');
|
||||
$tempPath = $image->store('temp', 'public');
|
||||
|
||||
Storage::delete($product->poster_thumb);
|
||||
$tempPath = $this->file('poster')->store('temp', 'public');
|
||||
$resizer = new ImageResize();
|
||||
return $resizer->resize($tempPath, 322, 'posters', true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user