-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
582 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Importers\GDXP; | ||
|
||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Str; | ||
|
||
use App\Product; | ||
|
||
class Attachments extends GDXPImporter | ||
{ | ||
public static function readXML($xml) | ||
{ | ||
return null; | ||
} | ||
|
||
public static function importXML($xml, $replace) | ||
{ | ||
return null; | ||
} | ||
|
||
public static function readJSON($json) | ||
{ | ||
return null; | ||
} | ||
|
||
public static function importJSON($target, $json) | ||
{ | ||
$contents = base64_decode($json->contents); | ||
|
||
if (is_a($target, Product::class)) { | ||
$filename = Str::random(30); | ||
$fullpath = sprintf('%s/%s', gas_storage_path('app'), $filename); | ||
file_put_contents($fullpath, $contents); | ||
|
||
$mime = mime_content_type($fullpath); | ||
if (str_starts_with($mime, 'image')) { | ||
$target->picture = $fullpath; | ||
} | ||
else { | ||
/* | ||
TODO: al momento non viene gestito nessun altro file | ||
allegato ai prodotti oltre all'immagine | ||
*/ | ||
@unlink($fullpath); | ||
} | ||
|
||
return null; | ||
} | ||
else { | ||
$existing = $target->attachments()->where('name', $json->name)->first(); | ||
return $target->attachByContents($json->name, $contents, $existing ? $existing->id : null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.