Bump to Laravel 9
This commit is contained in:
parent
aa29234e55
commit
0d95c8bbfd
68 changed files with 2296 additions and 2167 deletions
|
|
@ -18,7 +18,7 @@ DB_PASSWORD=secret
|
|||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
|
@ -56,3 +56,5 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
|
|||
ELASTICSEARCH_HOSTS=
|
||||
|
||||
MAIL_LIST_SERVICEWEB=
|
||||
|
||||
PROJECT_UUID=
|
||||
|
|
|
|||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -27,7 +27,6 @@ public/uploads/*
|
|||
/vendor
|
||||
.env
|
||||
.phpunit.result.cache
|
||||
docker-compose.override.yml
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
npm-debug.log
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
php:
|
||||
preset: laravel
|
||||
version: 8
|
||||
disabled:
|
||||
- unused_use
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
- server.php
|
||||
js:
|
||||
finder:
|
||||
not-name:
|
||||
|
|
|
|||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -18,5 +18,6 @@
|
|||
"titleBar.inactiveBackground": "#51440399",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"peacock.remoteColor": "#514403"
|
||||
"peacock.remoteColor": "#514403",
|
||||
"intelephense.environment.phpVersion": "8.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,3 +27,5 @@ php artisan key:generate
|
|||
|
||||
# BUMP LARAVEL MEP
|
||||
.env => remplacer MAIL_DRIVER par MAIL_MAILER
|
||||
.env => remplacer FILESYSTEM_DRIVER par FILESYSTEM_DISK
|
||||
.env rajouter PROJECT_UUID=
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\Sujet;
|
||||
use App\Models\Media;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DeleteMediaArchive extends Command
|
||||
{
|
||||
|
|
@ -20,19 +21,10 @@ class DeleteMediaArchive extends Command
|
|||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*/
|
||||
protected $description = 'Suppression définitive de tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete)';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -40,6 +32,7 @@ class DeleteMediaArchive extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$this->info('Vous allez supprimer définitivement tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete).');
|
||||
|
||||
$choice = $this->choice('Etes-vous sûr de vouloir lancer ce traitement ?', ['y', 'n'], 'y');
|
||||
|
|
@ -82,12 +75,14 @@ class DeleteMediaArchive extends Command
|
|||
$bar->start();
|
||||
|
||||
foreach ($medias as $media) {
|
||||
// supprime les fichiers médias stockés sur disque
|
||||
// * supprime les fichiers médias stockés sur disque
|
||||
$files = Storage::files($media->folder . "/");
|
||||
$filepath = preg_quote($media->folder . $media->uid, '/');
|
||||
$matchingFiles = preg_grep('/^' . $filepath . '/', $files);
|
||||
Storage::delete($matchingFiles);
|
||||
// supprime le media en bdd
|
||||
if (\is_array($matchingFiles)) {
|
||||
$this->deleteFiles($matchingFiles);
|
||||
}
|
||||
// * supprime le media en bdd
|
||||
$media->forceDelete();
|
||||
$bar->advance();
|
||||
}
|
||||
|
|
@ -96,4 +91,19 @@ class DeleteMediaArchive extends Command
|
|||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete files
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFiles(array $files)
|
||||
{
|
||||
collect($files)->map(function (string $filename) {
|
||||
if (!Storage::delete($filename)) {
|
||||
Log::warning("Could not delete $filename from storage.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,19 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Societe;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Article;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Site;
|
||||
use App\Models\Societe;
|
||||
use App\Models\Sujet;
|
||||
use App\Models\Typemedia;
|
||||
use App\Models\Typevue;
|
||||
use App\Models\Site;
|
||||
use App\Models\Variante;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ImportArcadiaFiles extends Command
|
||||
{
|
||||
|
|
@ -32,25 +34,18 @@ class ImportArcadiaFiles extends Command
|
|||
*/
|
||||
protected $description = 'Import des fichiers xml Arcadia';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Démarrage du traitement');
|
||||
$files = Storage::disk('arcadia')->files();
|
||||
$files = collect(Storage::disk('arcadia')->files());
|
||||
$bar = $this->output->createProgressBar(count($files) - 1);
|
||||
$bar->start();
|
||||
|
||||
|
|
@ -61,182 +56,306 @@ class ImportArcadiaFiles extends Command
|
|||
}
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$files = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($files);
|
||||
if (!($fileContent = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($fileContent))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
if (substr($filename, 0, 11) == "DAM_ARTICLE") {
|
||||
foreach ($fileContent->dam as $row) {
|
||||
$record = Article::where('noArt', $row->noArt)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Article();
|
||||
$record->noArt = $row->noArt;
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->save();
|
||||
}//end if
|
||||
}//end foreach
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 10) == "DAM_MARQUE") {
|
||||
foreach ($fileContent->dam as $row) {
|
||||
$record = Marque::where('codMarq', $row->codMarq)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Marque();
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 15) == "DAM_MEDIA_SUJET") {
|
||||
foreach ($fileContent->mediaSujet as $row) {
|
||||
$record = Sujet::where('codeSujet', $row->code)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Sujet();
|
||||
$record->codeSujet = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 20) == "DAM_MEDIA_TYPE_MEDIA") {
|
||||
foreach ($fileContent->mediatypemedia as $row) {
|
||||
$record = Typemedia::where('codeTypemedia', $row->code)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Typemedia();
|
||||
$record->codeTypemedia = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 17) == "DAM_MEDIA_TYPEVUE") {
|
||||
foreach ($fileContent->mediatypesvue as $row) {
|
||||
$record = Typevue::where('codeTypevue', $row->code)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Typevue();
|
||||
$record->codeTypevue = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 18) == "DAM_MEDIA_VARIANTE") {
|
||||
foreach ($fileContent->mediavariante as $row) {
|
||||
$record = Variante::where('codeVariante', $row->code)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Variante();
|
||||
$record->codeVariante = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 20) == "DAM_SITE_PROD_GROUPE") {
|
||||
foreach ($fileContent->SITE_PROD_GRP as $row) {
|
||||
$record = Site::where('id', $row->code)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Site();
|
||||
$record->id = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
} elseif (substr($filename, 0, 11) == "DAM_SOCIETE") {
|
||||
foreach ($fileContent->dam as $row) {
|
||||
$record = Societe::where('id', $row->codSociete)->first();
|
||||
if ($record) {
|
||||
// Update record
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->save();
|
||||
} else {
|
||||
// Insert new record
|
||||
$record = new Societe();
|
||||
$record->id = $row->codSociete;
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}//end if
|
||||
switch (true) {
|
||||
case substr($filename, 0, 11) == 'DAM_ARTICLE':
|
||||
$this->insertDamArticle($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 10) == 'DAM_MARQUE':
|
||||
$this->insertDamMarque($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 15) == 'DAM_MEDIA_SUJET':
|
||||
$this->insertDamMediaSujet($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 20) == 'DAM_MEDIA_TYPE_MEDIA':
|
||||
$this->insertDamMediaTypeMedia($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 17) == 'DAM_MEDIA_TYPEVUE':
|
||||
$this->insertDamMediaTypeVue($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 18) == 'DAM_MEDIA_VARIANTE':
|
||||
$this->insertDamMediaVariante($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 20) == 'DAM_SITE_PROD_GROUPE':
|
||||
$this->insertDamSiteProdGroupe($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 11) == 'DAM_SOCIETE':
|
||||
$this->insertDamSociete($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException("Unhandled file $filename");
|
||||
} //end switch
|
||||
$bar->advance();
|
||||
}//end foreach
|
||||
} //end foreach
|
||||
|
||||
$bar->finish();
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Article
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamArticle(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Article|null $record */
|
||||
$record = Article::where('noArt', $row->noArt)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Article();
|
||||
$record->noArt = $row->noArt;
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->saveOrFail();
|
||||
} //end if
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Marque
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMarque(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Marque|null $record */
|
||||
$record = Marque::where('codMarq', $row->codMarq)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Marque();
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Sujet
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaSujet(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaSujet as $row) {
|
||||
/** @var \App\Models\Sujet|null $record */
|
||||
$record = Sujet::where('codeSujet', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Sujet();
|
||||
$record->codeSujet = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Type Media
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaTypeMedia(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediatypemedia as $row) {
|
||||
/** @var \App\Models\Typemedia|null $record */
|
||||
$record = Typemedia::where('codeTypemedia', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Typemedia();
|
||||
$record->codeTypemedia = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Type Vue
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaTypeVue(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediatypesvue as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Typevue::where('codeTypevue', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Typevue();
|
||||
$record->codeTypevue = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Variante
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaVariante(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediavariante as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Variante::where('codeVariante', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Variante();
|
||||
$record->codeVariante = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Site Prod Groupe
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamSiteProdGroupe(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->SITE_PROD_GRP as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Site::where('id', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Site();
|
||||
$record->id = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Societe
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamSociete(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Societe::where('id', $row->codSociete)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Societe();
|
||||
$record->id = $row->codSociete;
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFile(string $filename)
|
||||
{
|
||||
if (!Storage::disk('arcadia')->delete($filename)) {
|
||||
Log::warning("Could not delete $filename from arcadia storage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Article;
|
||||
use App\Models\Dossier;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Media;
|
||||
use App\Models\Dossier;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ImportMedia extends Command
|
||||
{
|
||||
|
|
@ -29,16 +33,6 @@ class ImportMedia extends Command
|
|||
*/
|
||||
protected $description = 'Import des fichiers xml Média Visuel Arcadia';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -48,25 +42,233 @@ class ImportMedia extends Command
|
|||
{
|
||||
$this->info('Démarrage du traitement');
|
||||
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_MEDIA_VISUEL_*.*");
|
||||
$files = File::glob(storage_path('export_arcadia') . '/DAM_MEDIA_VISUEL_*.*');
|
||||
|
||||
$this->line("-> Import du fichier DAM_MEDIA_VISUEL");
|
||||
// ---- Traitement de l'import des XML Visuel
|
||||
|
||||
$this->xmlVisuels($files);
|
||||
$this->associateMediasArticles($files);
|
||||
$this->associateMediasMarques($files);
|
||||
$this->associateMediasSocietes($files);
|
||||
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> societe
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
*/
|
||||
private function associateMediasSocietes(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_SOCIETE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_SOCIETE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassosociete) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassosociete as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
// * attache la societe au média
|
||||
$record->societes()->attach($row->codSociete);
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_SOCIETE : le media n°$row->codeVisuel n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> marque
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
*/
|
||||
private function associateMediasMarques(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_MARQUE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_MARQUE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassomarque) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassomarque as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
if ($record->marques->contains($row->codMarq)) {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°$row->codeVisuel est déjà associé à cette marque.");
|
||||
} else {
|
||||
// * attache la marque au média
|
||||
$record->marques()->attach($row->codMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°$row->codeVisuel n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> article
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException If a model cant be found on transaction.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \Throwable If saving fails.
|
||||
* @phpcs:disable Generic.Metrics.NestingLevel.TooHigh
|
||||
* @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
|
||||
*/
|
||||
private function associateMediasArticles(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_ARTICLE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_ARTICLE");
|
||||
/** @var string $filename */
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassoarticle as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
/** @var \App\Models\Article|null */
|
||||
$article = Article::where('noArt', $row->noArt)->first();
|
||||
if ($article) {
|
||||
// * attache l'article au média
|
||||
$record->articles()->syncWithoutDetaching($article->id);
|
||||
// * recherche un dossier lié à la marque de l'article
|
||||
$marque_id = $article->codMarq;
|
||||
/** @var \App\Models\Dossier|null */
|
||||
$dossier = Dossier::whereHas("marques", function ($query) use ($marque_id) {
|
||||
$query->where("codMarq", $marque_id);
|
||||
})->first();
|
||||
|
||||
if ($dossier) {
|
||||
// * attache le dossier marque au Média
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
$this->line("Liason media n°$row->codeVisuel à la marque n°$article->libMarq");
|
||||
} else {
|
||||
DB::transaction(function () use ($record, $marque_id) {
|
||||
/** @var \App\Models\Marque */
|
||||
$marque = Marque::where('codMarq', '=', $marque_id)->firstOrFail();
|
||||
// * On cree le dossier
|
||||
$dossier = new Dossier();
|
||||
$dossier->libelle = $marque->libMarq;
|
||||
$dossier->sujet_id = 1;
|
||||
$dossier->system = false;
|
||||
$dossier->saveOrFail();
|
||||
$dossier->marques()->syncWithoutDetaching($marque_id);
|
||||
$dossier->saveOrFail();
|
||||
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->saveOrFail();
|
||||
});
|
||||
} //end if
|
||||
} else {
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°$row->codeVisuel ne peut être lié à l'article n°$row->noArt");
|
||||
} //end if
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°$row->codeVisuel n'existe pas");
|
||||
} //end if
|
||||
$bar->advance();
|
||||
} //end foreach
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'import des XML Visuel
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
*/
|
||||
private function xmlVisuels(array $files): void
|
||||
{
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->MEDIA_VISUEL) - 1);
|
||||
$bar->start();
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->MEDIA_VISUEL as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->code)->first();
|
||||
if (!$record) {
|
||||
// Insert new record
|
||||
// * Insert new record
|
||||
$record = new Media();
|
||||
$record->arcadia_id = $row->code;
|
||||
if ($row->extension != "") {
|
||||
|
|
@ -90,7 +292,9 @@ class ImportMedia extends Command
|
|||
} else {
|
||||
$record->typemedia_id = 1;
|
||||
}
|
||||
if ($row->codeTypeVue != "") {
|
||||
if (
|
||||
$row->codeTypeVue != ""
|
||||
) {
|
||||
$record->typevue_id = $row->codeTypeVue;
|
||||
}
|
||||
$record->commentaire = $row->commentaire;
|
||||
|
|
@ -123,177 +327,67 @@ class ImportMedia extends Command
|
|||
}
|
||||
$record->statut = config('services.statut.public_etendu');
|
||||
|
||||
// Affectation d'un dossier et d'un uid
|
||||
// Affectation d'un dossier et d'un uid.
|
||||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
$record->folder = $destinationPath;
|
||||
$record->uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
$record->uid = Str::uuid();
|
||||
|
||||
$mediaFile = "/images/{$record->arcadia_id}.{$record->extension}";
|
||||
if (Storage::disk('arcadia')->exists($mediaFile)) {
|
||||
// * déplacement du média et renommage du fichier
|
||||
if (!($fileContent = Storage::disk('arcadia')->get($mediaFile))) {
|
||||
throw new \ErrorException("Could not read $mediaFile from arcadia storage.");
|
||||
}
|
||||
// * According to config, should throw exception on failure.
|
||||
Storage::disk('local')->put(
|
||||
$fileContent,
|
||||
"{$destinationPath}{$record->uid}.$record->extension"
|
||||
);
|
||||
|
||||
$mediaFile = "/images/" . $record->arcadia_id . "." . $record->extension;
|
||||
$fileExists = Storage::disk('arcadia')->exists($mediaFile);
|
||||
if ($fileExists) {
|
||||
// déplacement du média et renommage du fichier
|
||||
$file = Storage::disk('arcadia')->get($mediaFile);
|
||||
$full_path_source = Storage::disk('arcadia')->getDriver()->getAdapter()->applyPathPrefix($mediaFile);
|
||||
$full_path_dest = Storage::disk('local')->getDriver()->getAdapter()->applyPathPrefix($destinationPath . $record->uid . '.' . $record->extension);
|
||||
File::move($full_path_source, $full_path_dest);
|
||||
|
||||
// calcul de la taille du média
|
||||
$record->taille = $this->formatBytes($this->getFileSize($full_path_dest));
|
||||
// * calcul de la taille du média
|
||||
$record->taille = $this->formatBytes(Storage::disk('local')
|
||||
->size("{$destinationPath}{$record->uid}.$record->extension"));
|
||||
} else {
|
||||
// on applique une image par défaut
|
||||
// * on applique une image par défaut
|
||||
$record->extension = "jpg";
|
||||
Storage::disk('local')->copy("assets/images/default.jpg", $destinationPath . $record->uid . '.' . $record->extension);
|
||||
Storage::disk('local')->copy(
|
||||
"assets/images/default.jpg",
|
||||
"{$destinationPath}{$record->uid}.{$record->extension}"
|
||||
);
|
||||
|
||||
// calcul de la taille du média
|
||||
$record->taille = $this->formatBytes($this->getFileSize("public/" . $destinationPath . $record->uid . '.' . $record->extension));
|
||||
}
|
||||
// * calcul de la taille du média
|
||||
$record->taille = $this->formatBytes(Storage::disk('local')
|
||||
->size("{$destinationPath}{$record->uid}.{$record->extension}"));
|
||||
} //end if
|
||||
|
||||
|
||||
$record->save();
|
||||
$record->saveOrFail();
|
||||
|
||||
// ---- Creation des vignettes de base
|
||||
$this->createSysThumb($record);
|
||||
// ---- Creation des vignettes en lien avec le sujet du média
|
||||
$this->createThumb($record);
|
||||
} else {
|
||||
$this->line("\nDAM_MEDIA_VISUEL : le media n°" . $row->code . " existe déjà en base");
|
||||
}//end if
|
||||
$this->line("\nDAM_MEDIA_VISUEL : le media n°$row->code existe déjà en base");
|
||||
} //end if
|
||||
$bar->advance();
|
||||
}//end foreach
|
||||
} //end foreach
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}//end foreach
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
|
||||
// ---- Traitement de l'association media <-> article
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_ARTICLE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_ARTICLE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle) - 1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassoarticle as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
$article = Article::where('noArt', $row->noArt)->first();
|
||||
if ($article) {
|
||||
// attache l'article au média
|
||||
$record->articles()->syncWithoutDetaching($article->id);
|
||||
// recherche un dossier lié à la marque de l'article
|
||||
$marque_id = $article->codMarq;
|
||||
$dossier = Dossier::whereHas("marques", function ($query) use ($marque_id) {
|
||||
$query->where("codMarq", $marque_id);
|
||||
})->first();
|
||||
|
||||
if ($dossier) {
|
||||
// attache le dossier marque au Média
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
$this->line("Liason media n°" . $row->codeVisuel . " à la marque n°" . $article->libMarq);
|
||||
} else {
|
||||
$marque = Marque::where('codMarq', '=', $marque_id)->first();
|
||||
// On cree le dossier
|
||||
$dossier = new Dossier();
|
||||
$dossier->libelle = $marque->libMarq;
|
||||
$dossier->sujet_id = 1;
|
||||
$dossier->system = false;
|
||||
$dossier->save();
|
||||
$dossier->marques()->syncWithoutDetaching($marque_id);
|
||||
$dossier->save();
|
||||
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
// $this->line("Liason media n°" . $row->codeVisuel . " à la marque n°" . $article->libMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°" . $row->codeVisuel . " ne peut être lié à l'article n°" . $row->noArt);
|
||||
}//end if
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}//end if
|
||||
$bar->advance();
|
||||
}//end foreach
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}//end foreach
|
||||
|
||||
// ---- Traitement de l'association media <-> marque
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_MARQUE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_MARQUE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassomarque) - 1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassomarque as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
if ($record->marques->contains($row->codMarq)) {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°" . $row->codeVisuel . " est déjà associé à cette marque.");
|
||||
} else {
|
||||
// attache la marque au média
|
||||
$record->marques()->attach($row->codMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}//end foreach
|
||||
|
||||
// ---- Traitement de l'association media <-> societe
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_SOCIETE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_SOCIETE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassosociete) - 1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassosociete as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
// attache la societe au média
|
||||
$record->societes()->attach($row->codSociete);
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_SOCIETE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}//end foreach
|
||||
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFile(string $filename): void
|
||||
{
|
||||
if (!Storage::disk('arcadia')->delete($filename)) {
|
||||
Log::warning("Could not delete $filename from arcadia storage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Command Name: LDC Web Status Checker
|
||||
* Description: Envoi des infos Serveur/Laravel vers LDC Web
|
||||
* Version: 1.0
|
||||
* Author: Vincent BRIDIER
|
||||
* Author URI: vincent.bridier@ldc.fr
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class LDCWebStatusChecker extends Command
|
||||
/**
|
||||
* Command Name: LDC Web Status Checker
|
||||
* Description: Envoi des infos Serveur/Laravel vers LDC Web
|
||||
* Version: 1.1
|
||||
* Author: Vincent BRIDIER
|
||||
* Author URI: vincent.bridier@ldc.fr
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class LdcWebStatusChecker extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -28,16 +29,6 @@ class LDCWebStatusChecker extends Command
|
|||
*/
|
||||
protected $description = 'Envoi des infos Serveur/Laravel vers LDC Web';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -46,7 +37,7 @@ class LDCWebStatusChecker extends Command
|
|||
public function handle()
|
||||
{
|
||||
$data = [];
|
||||
$data['uuid'] = env('PROJECT_UUID');
|
||||
$data['uuid'] = config('ldcweb.project_uuid');
|
||||
|
||||
// Sitemap.xml ?
|
||||
if (file_exists(public_path() . '/sitemap.xml')) {
|
||||
|
|
@ -62,7 +53,7 @@ class LDCWebStatusChecker extends Command
|
|||
$data['robots'] = 'false';
|
||||
}
|
||||
|
||||
// Check logs
|
||||
// Check logs.
|
||||
$data['logs'] = 0;
|
||||
$patherror = storage_path('/logs');
|
||||
$files = glob($patherror . '/*.log');
|
||||
|
|
@ -74,13 +65,14 @@ class LDCWebStatusChecker extends Command
|
|||
|
||||
$data['code']['version'] = app()->version();
|
||||
|
||||
// Send by cURL
|
||||
// Send by cURL.
|
||||
$url = 'https://ldc-web.ldc.fr/api/status-checker';
|
||||
$ch = curl_init($url);
|
||||
$payload = ['token' => 'CE8S52Qq7stf5k8frF4T', 'datas' => json_encode($data)];
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Sujet;
|
||||
use App\Models\Media;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Media;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RegenerateThumbnails extends Command
|
||||
{
|
||||
|
|
@ -25,16 +25,6 @@ class RegenerateThumbnails extends Command
|
|||
*/
|
||||
protected $description = 'Regénération de toutes les vignettes des médias';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ReindexElasticMedia extends Command
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class reindexElasticOneMedia extends Command
|
||||
class ReindexElasticOneMedia extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -21,16 +21,6 @@ class reindexElasticOneMedia extends Command
|
|||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -21,16 +21,6 @@ class SendMediasModificationsReport extends Command
|
|||
*/
|
||||
protected $description = 'Run the SendMediasModificationsReport Manually';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* En attente phpcs merge
|
||||
* https://github.com/squizlabs/PHP_CodeSniffer/pull/3478
|
||||
*/
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* @method static self debug()
|
||||
* @method static self log()
|
||||
* @method static self warning()
|
||||
* @method static self info()
|
||||
* @method static self error()
|
||||
* @method static self critical()
|
||||
*/
|
||||
final class LogType extends BaseEnumRoutable
|
||||
enum LogType: int
|
||||
{
|
||||
case debug = 0;
|
||||
case log = 1;
|
||||
case warning = 2;
|
||||
case info = 3;
|
||||
case error = 4;
|
||||
case critical = 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class AbortXmlImportException extends ErrorException
|
||||
class AbortXmlImportException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ElasticSearchException extends ErrorException
|
||||
class ElasticSearchException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,17 @@ use Throwable;
|
|||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<Throwable>>
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class InvalidXmlException extends ErrorException
|
||||
class InvalidXmlException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -903,14 +903,17 @@ class MediaController extends Controller
|
|||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
$uid = Str::uuid();
|
||||
$filename = $uid . ".jpg";
|
||||
Storage::copy("assets/images/default.jpg", $destinationPath . $filename);
|
||||
|
||||
if (!(Storage::copy("assets/images/default.jpg", $destinationPath . $filename))) {
|
||||
throw new \ErrorException("Failed to copy $filename on storage");
|
||||
}
|
||||
|
||||
$n->arcadia_id = null;
|
||||
$n->libelle = (strlen($n->libelle) + 5) >= 50 ? substr($n->libelle, 0, - ((strlen($n->libelle) - 50) + 5)) . '_copy' : $n->libelle . '_copy';
|
||||
$n->folder = $destinationPath;
|
||||
$n->uid = $uid;
|
||||
$n->extension = 'jpg';
|
||||
$n->taille = $this->formatBytes($this->getFileSize($destinationPath . $filename));
|
||||
$n->taille = $this->formatBytes(Storage::size($destinationPath . $filename));
|
||||
|
||||
$im = new \imagick($destinationPath . $filename);
|
||||
// pour dev sous windows (pour cause de bug sur imagick avec les chemins relatifs)
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ class PanierController extends Controller
|
|||
/** @var \App\Models\Panier $basket */
|
||||
$basket = Panier::whereId($request->basket_id)->firstOrFail();
|
||||
|
||||
// TODO: Replace this with deleteOrFail after laravel bump.
|
||||
$basket->delete();
|
||||
$basket->deleteOrFail();
|
||||
|
||||
return response()->json();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Historique;
|
||||
use App\Models\Media;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Media;
|
||||
use App\Models\Site;
|
||||
use App\Models\Historique;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
|
|
@ -46,9 +47,10 @@ class UploadController extends Controller
|
|||
|
||||
if ($request->hasFile('files')) {
|
||||
$filesa = [];
|
||||
$file = $request->file('files');
|
||||
/** @var array<\Illuminate\Http\UploadedFile> */
|
||||
$files = $request->file('files');
|
||||
|
||||
foreach ($file as $files) {
|
||||
foreach ($files as $file) {
|
||||
$is_last_chunk = false;
|
||||
$is_chunked_upload = !empty($headers['content-range']);
|
||||
if ($is_chunked_upload) {
|
||||
|
|
@ -59,8 +61,8 @@ class UploadController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$extension = strtolower($files->getClientOriginalExtension());
|
||||
$originalName = str_replace("." . $extension, "", $files->getClientOriginalName());
|
||||
$extension = strtolower($file->getClientOriginalExtension());
|
||||
$originalName = str_replace("." . $extension, "", $file->getClientOriginalName());
|
||||
if (!in_array($extension, $acceptFileTypes)) {
|
||||
return array("false");
|
||||
}
|
||||
|
|
@ -72,24 +74,28 @@ class UploadController extends Controller
|
|||
}
|
||||
|
||||
$uploadPath = public_path() . '/uploads/';
|
||||
$files->move($uploadPath, $filename);
|
||||
$file->move($uploadPath, $filename);
|
||||
|
||||
// si c'est le dernier morceux d'un fichier
|
||||
// * si c'est le dernier morceux d'un fichier
|
||||
if ($is_last_chunk) {
|
||||
if ($dossier = opendir($uploadPath)) {
|
||||
$dirFiles = array();
|
||||
// on compile tous les chunk du fichier
|
||||
// * on compile tous les chunk du fichier
|
||||
while (false !== ($fichier = readdir($dossier))) {
|
||||
if ($fichier != '.' && $fichier != '..') {
|
||||
if (strpos($fichier, $uid) !== false) {
|
||||
$dirFiles[$fichier] = str_replace("." . $extension, "", str_replace($uid . "_", "", $fichier));
|
||||
$dirFiles[$fichier] = str_replace(
|
||||
".{$extension}",
|
||||
"",
|
||||
str_replace("{$uid}_", "", $fichier)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dossier);
|
||||
// on les trie pour les assembler dans le bon ordre
|
||||
// * on les trie pour les assembler dans le bon ordre
|
||||
asort($dirFiles, SORT_NUMERIC);
|
||||
// on les assemble dans un fichier final
|
||||
// * on les assemble dans un fichier final
|
||||
$filename = $uid . '.' . $extension;
|
||||
foreach ($dirFiles as $key => $fichier) {
|
||||
$file = fopen($uploadPath . $key, 'rb');
|
||||
|
|
@ -105,20 +111,24 @@ class UploadController extends Controller
|
|||
}//end if
|
||||
}//end if
|
||||
|
||||
// si c'est le dernier morceau d'un fichier ou que c'est un envoi simple
|
||||
// * si c'est le dernier morceau d'un fichier ou que c'est un envoi simple
|
||||
if ($is_last_chunk || !$is_chunked_upload) {
|
||||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
|
||||
// si on upload un média pour remplacer un fichier par un autre
|
||||
// * si on upload un média pour remplacer un fichier par un autre
|
||||
if ($replaceMediaId != 0) {
|
||||
// on récupère le média à modifier
|
||||
// * on récupère le média à modifier
|
||||
/** @var \App\Models\Media|null */
|
||||
$media = Media::where('id', $replaceMediaId)->first();
|
||||
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
if (!Storage::move("uploads/{$filename}", $destinationPath . $filename)) {
|
||||
throw new \ErrorException(
|
||||
"Could not move uploaded file $filename into {$destinationPath}{$filename}"
|
||||
);
|
||||
}
|
||||
|
||||
// supprime les fichiers médias stockés sur disque
|
||||
// * supprime les fichiers médias stockés sur disque
|
||||
$filesfF = Storage::files($media->folder . "/");
|
||||
$filepath = preg_quote($media->folder . $media->uid, '/');
|
||||
$matchingFiles = preg_grep('/^' . $filepath . '/', $filesfF);
|
||||
|
|
@ -127,16 +137,20 @@ class UploadController extends Controller
|
|||
$media->isDefault = 0;
|
||||
$media->save();
|
||||
} else {
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
if (!Storage::move("uploads/{$filename}", $destinationPath . $filename)) {
|
||||
throw new \ErrorException(
|
||||
"Could not move uploaded file $filename into {$destinationPath}{$filename}"
|
||||
);
|
||||
}
|
||||
|
||||
// on créé un média en bdd
|
||||
// * on créé un média en bdd
|
||||
$media = new Media();
|
||||
$media->dossier_id = $dossier_id;
|
||||
$media->sujet_id = $sujet_id;
|
||||
// Par défaut FR
|
||||
// * Par défaut FR
|
||||
$media->langue_id = 1;
|
||||
// Par défaut propriété de la marque
|
||||
// * Par défaut propriété de la marque
|
||||
$media->copyright_id = 3;
|
||||
}//end if
|
||||
|
||||
|
|
@ -147,10 +161,10 @@ class UploadController extends Controller
|
|||
$media->created_by = Auth::user()->id;
|
||||
}
|
||||
$media->uid = $uid;
|
||||
$media->taille = $this->formatBytes($this->getFileSize($destinationPath . $filename));
|
||||
$media->taille = $this->formatBytes(Storage::size($destinationPath . $filename));
|
||||
|
||||
switch ($extension) {
|
||||
// Photo (1)
|
||||
// * Photo (1)
|
||||
case 'gif':
|
||||
case 'jpeg':
|
||||
case 'jpg':
|
||||
|
|
@ -159,7 +173,7 @@ class UploadController extends Controller
|
|||
case 'pdf':
|
||||
case 'psd':
|
||||
$media->typemedia_id = 1;
|
||||
$im = new \imagick($destinationPath . $filename);
|
||||
$im = new \Imagick($destinationPath . $filename);
|
||||
|
||||
if (in_array($extension, array("pdf", "ai", "psd", "gif"))) {
|
||||
$im->setIteratorIndex(0);
|
||||
|
|
@ -188,12 +202,12 @@ class UploadController extends Controller
|
|||
$this->createThumb($media);
|
||||
}
|
||||
break;
|
||||
// Illustration/Vectorielle (2)
|
||||
// * Illustration/Vectorielle (2)
|
||||
case 'svg':
|
||||
$media->typemedia_id = 2;
|
||||
$media->save();
|
||||
break;
|
||||
// Vidéo (3)
|
||||
// * Vidéo (3)
|
||||
case 'mp4':
|
||||
$media->typemedia_id = 3;
|
||||
$getID3 = new \getID3();
|
||||
|
|
@ -204,7 +218,7 @@ class UploadController extends Controller
|
|||
}
|
||||
$media->save();
|
||||
break;
|
||||
// Audio (4)
|
||||
// * Audio (4)
|
||||
case 'mp3':
|
||||
$media->typemedia_id = 4;
|
||||
$getID3 = new \getID3();
|
||||
|
|
@ -222,7 +236,7 @@ class UploadController extends Controller
|
|||
$media->addToIndex();
|
||||
|
||||
// ---- Historique des actions
|
||||
$historique = new historique();
|
||||
$historique = new Historique();
|
||||
if ($user = Auth::user()) {
|
||||
$historique->user_id = $user->id;
|
||||
}
|
||||
|
|
@ -266,7 +280,7 @@ class UploadController extends Controller
|
|||
$acceptFileTypes = array('gif','jpeg', 'jpg','png','mp4','mp3','psd','ai','svg','pdf');
|
||||
|
||||
if (!$uid) {
|
||||
$uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
$uid = Str::uuid();
|
||||
}
|
||||
|
||||
$file = $request->file('files');
|
||||
|
|
@ -281,43 +295,57 @@ class UploadController extends Controller
|
|||
return array("error" => "Ce type de fichier n'est pas accepté.");
|
||||
}
|
||||
|
||||
// check the error status
|
||||
// * check the error status
|
||||
if ($file->getError() != 0) {
|
||||
Log::error('error ' . $file->getError() . ' in file ' . $request->resumableFilename);
|
||||
}
|
||||
|
||||
// init the destination file (format <filename.ext>.part<#chunk>
|
||||
// the file is stored in a temporary directory
|
||||
if (isset($request->resumableIdentifier) && trim($request->resumableIdentifier) != '') {
|
||||
$temp_dir = 'uploads/' . $request->resumableIdentifier;
|
||||
}
|
||||
$dest_file = $temp_dir . '/' . $request->resumableFilename . '.part' . $request->resumableChunkNumber;
|
||||
$temp_dir = 'uploads';
|
||||
|
||||
// create the temporary directory
|
||||
/**
|
||||
* init the destination file (format <filename.ext>.part<#chunk>
|
||||
* the file is stored in a temporary directory
|
||||
*/
|
||||
if (isset($request->resumableIdentifier) && trim($request->resumableIdentifier) != '') {
|
||||
$temp_dir .= "/{$request->resumableIdentifier}";
|
||||
}
|
||||
$dest_file = "{$temp_dir}/{$request->resumableFilename}.part{$request->resumableChunkNumber}";
|
||||
|
||||
// * create the temporary directory
|
||||
if (!is_dir($temp_dir)) {
|
||||
mkdir($temp_dir, 0777, true);
|
||||
}
|
||||
|
||||
// move the temporary file
|
||||
// * move the temporary file
|
||||
if (!move_uploaded_file($file->getPathname(), $dest_file)) {
|
||||
Log::error('Error saving (move_uploaded_file) chunk ' . $request->resumableChunkNumber . ' for file ' . $request->resumableFilename);
|
||||
Log::error(
|
||||
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
"Error saving (move_uploaded_file) chunk $request->resumableChunkNumber for file $request->resumableFilename"
|
||||
);
|
||||
} else {
|
||||
$filename = $uid . '.' . $extension;
|
||||
// check if all the parts present, and create the final destination file
|
||||
$isLast = $this->createFileFromChunks($temp_dir, $request->resumableFilename, $request->resumableChunkSize, $request->resumableTotalSize, $request->resumableTotalChunks, $filename);
|
||||
// * check if all the parts present, and create the final destination file
|
||||
$isLast = $this->createFileFromChunks(
|
||||
$temp_dir,
|
||||
$request->resumableFilename,
|
||||
$request->resumableChunkSize,
|
||||
$request->resumableTotalSize,
|
||||
$request->resumableTotalChunks,
|
||||
$filename
|
||||
);
|
||||
if ($isLast) {
|
||||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
|
||||
// si on upload un média pour remplacer un fichier par un autre
|
||||
// * si on upload un média pour remplacer un fichier par un autre
|
||||
if ($replaceMediaId != 0) {
|
||||
// on récupère le média à modifier
|
||||
/** @var \App\Models\Media|null $media */
|
||||
$media = Media::where('id', $replaceMediaId)->first();
|
||||
// * on récupère le média à modifier
|
||||
/** @var \App\Models\Media $media */
|
||||
$media = Media::where('id', $replaceMediaId)->firstOrFail();
|
||||
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
|
||||
// supprime les fichiers médias stockés sur disque
|
||||
// * supprime les fichiers médias stockés sur disque
|
||||
$filesfF = Storage::files($media->folder . "/");
|
||||
$filepath = preg_quote($media->folder . $media->uid, '/');
|
||||
$matchingFiles = preg_grep('/^' . $filepath . '/', $filesfF);
|
||||
|
|
@ -326,16 +354,16 @@ class UploadController extends Controller
|
|||
$media->isDefault = 0;
|
||||
$media->save();
|
||||
} else {
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
|
||||
// on créé un média en bdd
|
||||
// * on créé un média en bdd
|
||||
$media = new Media();
|
||||
$media->dossier_id = $dossier_id;
|
||||
$media->sujet_id = $sujet_id;
|
||||
// Par défaut FR
|
||||
// * Par défaut FR
|
||||
$media->langue_id = 1;
|
||||
// Par défaut propriété de la marque
|
||||
// * Par défaut propriété de la marque
|
||||
$media->copyright_id = 3;
|
||||
}//end if
|
||||
|
||||
|
|
@ -349,7 +377,7 @@ class UploadController extends Controller
|
|||
$media->taille = $this->formatBytes($this->getFileSize($destinationPath . $filename));
|
||||
|
||||
switch ($extension) {
|
||||
// Photo (1)
|
||||
// * Photo (1)
|
||||
case 'gif':
|
||||
case 'jpeg':
|
||||
case 'jpg':
|
||||
|
|
@ -359,7 +387,6 @@ class UploadController extends Controller
|
|||
case 'psd':
|
||||
$media->typemedia_id = 1;
|
||||
$im = new \imagick($destinationPath . $filename);
|
||||
// $im = new \imagick(realpath($destinationPath.$filename));
|
||||
if (in_array($extension, array("pdf", "ai", "psd", "gif"))) {
|
||||
$im->setIteratorIndex(0);
|
||||
}
|
||||
|
|
@ -387,12 +414,12 @@ class UploadController extends Controller
|
|||
$this->createThumb($media);
|
||||
}
|
||||
break;
|
||||
// Illustration/Vectorielle (2)
|
||||
// * Illustration/Vectorielle (2)
|
||||
case 'svg':
|
||||
$media->typemedia_id = 2;
|
||||
$media->save();
|
||||
break;
|
||||
// Vidéo (3)
|
||||
// * Vidéo (3)
|
||||
case 'mp4':
|
||||
$media->typemedia_id = 3;
|
||||
$getID3 = new \getID3();
|
||||
|
|
@ -403,7 +430,7 @@ class UploadController extends Controller
|
|||
}
|
||||
$media->save();
|
||||
break;
|
||||
// Audio (4)
|
||||
// * Audio (4)
|
||||
case 'mp3':
|
||||
$media->typemedia_id = 4;
|
||||
$getID3 = new \getID3();
|
||||
|
|
@ -421,7 +448,7 @@ class UploadController extends Controller
|
|||
$media->addToIndex();
|
||||
|
||||
// ---- Historique des actions
|
||||
$historique = new historique();
|
||||
$historique = new Historique();
|
||||
if ($user = Auth::user()) {
|
||||
$historique->user_id = $user->id;
|
||||
}
|
||||
|
|
@ -445,16 +472,23 @@ class UploadController extends Controller
|
|||
* Check if all the parts exist, and
|
||||
* gather all the parts of the file together
|
||||
*
|
||||
* @param string $temp_dir - the temporary directory holding all the parts of the file
|
||||
* @param string $fileName - the original file name
|
||||
* @param string $chunkSize - each chunk size (in bytes)
|
||||
* @param string $totalSize - original file size (in bytes)
|
||||
* @param string $temp_dir The temporary directory holding all the parts of the file.
|
||||
* @param string $fileName The original file name.
|
||||
* @param integer $chunkSize Each chunk size (in bytes).
|
||||
* @param integer $totalSize Original file size (in bytes).
|
||||
* @param integer $total_files
|
||||
* @param string $finalName
|
||||
* @return boolean
|
||||
*/
|
||||
private function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize, $total_files, $finalName)
|
||||
{
|
||||
|
||||
// count all the parts of this file
|
||||
private function createFileFromChunks(
|
||||
string $temp_dir,
|
||||
string $fileName,
|
||||
int $chunkSize,
|
||||
int $totalSize,
|
||||
int $total_files,
|
||||
string $finalName
|
||||
): bool {
|
||||
// * count all the parts of this file
|
||||
$total_files_on_server_size = 0;
|
||||
$temp_total = 0;
|
||||
foreach (scandir($temp_dir) as $file) {
|
||||
|
|
@ -462,14 +496,13 @@ class UploadController extends Controller
|
|||
$tempfilesize = filesize($temp_dir . '/' . $file);
|
||||
$total_files_on_server_size = $temp_total + $tempfilesize;
|
||||
}
|
||||
// check that all the parts are present
|
||||
// If the Size of all the chunks on the server is equal to the size of the file uploaded.
|
||||
// * check that all the parts are present
|
||||
// * If the Size of all the chunks on the server is equal to the size of the file uploaded.
|
||||
if ($total_files_on_server_size >= $totalSize) {
|
||||
// create the final destination file
|
||||
if (($fp = fopen('uploads/' . $finalName, 'w')) !== false) {
|
||||
// * create the final destination file
|
||||
if (($fp = fopen("uploads/{$finalName}", 'w')) !== false) {
|
||||
for ($i = 1; $i <= $total_files; $i++) {
|
||||
fwrite($fp, file_get_contents($temp_dir . '/' . $fileName . '.part' . $i));
|
||||
// Log::info('writing chunk '.$i);
|
||||
fwrite($fp, file_get_contents("{$temp_dir}/{$fileName}.part{$i}"));
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -477,8 +510,8 @@ class UploadController extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
// rename the temporary directory (to avoid access from other
|
||||
// concurrent chunks uploads) and than delete it
|
||||
// * rename the temporary directory (to avoid access from other
|
||||
// * concurrent chunks uploads) and than delete it
|
||||
if (rename($temp_dir, $temp_dir . '_UNUSED')) {
|
||||
$this->rrmdir($temp_dir . '_UNUSED');
|
||||
} else {
|
||||
|
|
@ -492,10 +525,11 @@ class UploadController extends Controller
|
|||
/**
|
||||
* Delete a directory RECURSIVELY
|
||||
*
|
||||
* @param string $dir - directory path
|
||||
* @param string $dir Directory path.
|
||||
* @return void
|
||||
* @link http://php.net/manual/en/function.rmdir.php
|
||||
*/
|
||||
private function rrmdir($dir)
|
||||
private function rrmdir(string $dir): void
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
|
|
|
|||
|
|
@ -276,8 +276,7 @@ class UserController extends Controller
|
|||
$media->owner()->associate($userPourRemplacer);
|
||||
$media->saveOrFail();
|
||||
});
|
||||
// TODO: use deleteOrFail after upgrate to laravel 8.
|
||||
if ($user->delete()) {
|
||||
if ($user->deleteOrFail()) {
|
||||
session()->flash('success', trans('L\'utilisateur à été supprimé'));
|
||||
return redirect(route('user.index'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class Kernel extends HttpKernel
|
|||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
|
|
@ -34,7 +34,6 @@ class Kernel extends HttpKernel
|
|||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
|
|
@ -57,6 +56,7 @@ class Kernel extends HttpKernel
|
|||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class Authenticate extends Middleware
|
|||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ trait MediaTools
|
|||
}
|
||||
|
||||
/**
|
||||
* Create thumbnail for a Media
|
||||
* Create thumbnail image for a Media
|
||||
*
|
||||
* @param Media $media
|
||||
* @return void
|
||||
* @throws \ImagickException On errors.
|
||||
*/
|
||||
public function createThumb(Media $media)
|
||||
{
|
||||
|
|
@ -36,11 +37,11 @@ trait MediaTools
|
|||
foreach ($formats as $format) {
|
||||
$fp = public_path("/{$media->folder}{$media->uid}_{$format->libelle}.{$format->extension}");
|
||||
|
||||
$targetWidth = $format->largeur;
|
||||
if ($format->hauteur == 0) {
|
||||
$targetHeight = floor(($media->hauteur * $format->largeur) / $media->largeur);
|
||||
$targetWidth = \floatval($format->largeur);
|
||||
if (\floatval($format->hauteur) == 0) {
|
||||
$targetHeight = \floatval(floor(($media->hauteur * $format->largeur) / $media->largeur));
|
||||
} else {
|
||||
$targetHeight = $format->hauteur;
|
||||
$targetHeight = \floatval($format->hauteur);
|
||||
}
|
||||
|
||||
$im->setImageFormat($format->extension);
|
||||
|
|
@ -53,9 +54,16 @@ trait MediaTools
|
|||
unset($im);
|
||||
}
|
||||
|
||||
public function createSysThumb($media)
|
||||
/**
|
||||
* Create Sys thumbnail image for a Media.
|
||||
*
|
||||
* @param \App\Models\Media $media
|
||||
* @return void
|
||||
* @throws \ImagickException On errors.
|
||||
*/
|
||||
public function createSysThumb(Media $media)
|
||||
{
|
||||
$mediaPath = public_path() . "/" . $media->folder . $media->uid . "." . $media->extension;
|
||||
$mediaPath = public_path("/{$media->folder}{$media->uid}.{$media->extension}");
|
||||
$im = new \Imagick();
|
||||
$im->readImage($mediaPath);
|
||||
|
||||
|
|
@ -63,18 +71,22 @@ trait MediaTools
|
|||
$extension = "png";
|
||||
$im->setIteratorIndex(0);
|
||||
} else {
|
||||
/** @var string */
|
||||
$extension = $media->extension;
|
||||
}
|
||||
|
||||
/*
|
||||
Handle CMJN - DOESN'T WORK
|
||||
if ($im->getImageColorspace() === \Imagick::COLORSPACE_CMYK){
|
||||
$im->transformImageColorspace(\Imagick::COLORSPACE_RGB);
|
||||
}*/
|
||||
$im->transformImageColorspace(\Imagick::COLORSPACE_RGB);
|
||||
}
|
||||
*/
|
||||
|
||||
// * create preview
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'preview')->first();
|
||||
$fp = public_path() . "/" . $media->folder . $media->uid . '_preview.' . $extension;
|
||||
/** @var \App\Models\Format $format */
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')
|
||||
->where('libelle', '=', 'preview')->firstOrFail();
|
||||
$fp = public_path("/{$media->folder}{$media->uid}_preview.{$extension}");
|
||||
if ($media->extension == "gif") {
|
||||
if ($media->largeur >= $format->largeur || $media->hauteur >= $format->hauteur || $media->largeur == "") {
|
||||
$im = $im->coalesceImages();
|
||||
|
|
@ -94,27 +106,36 @@ trait MediaTools
|
|||
|
||||
|
||||
// * create thumb
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'thumb')->first();
|
||||
/** @var \App\Models\Format $format */
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')
|
||||
->where('libelle', '=', 'thumb')->firstOrFail();
|
||||
if ($extension != "png") {
|
||||
$im->setImageBackgroundColor('#ffffff');
|
||||
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
|
||||
$im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
|
||||
$im->stripImage();
|
||||
}
|
||||
$fp = public_path() . "/" . $media->folder . $media->uid . '_thumb.' . $extension;
|
||||
$fp = public_path("/{$media->folder}{$media->uid}_thumb.{$extension}");
|
||||
$im->thumbnailImage($format->largeur, $format->hauteur, true);
|
||||
$im->writeImage($fp);
|
||||
$im->destroy();
|
||||
unset($im);
|
||||
}
|
||||
|
||||
public function getMediaFolder()
|
||||
/**
|
||||
* Returns the media folder path name
|
||||
*
|
||||
* @return string
|
||||
* @throws \ErrorException If creating the folder fails.
|
||||
*/
|
||||
public function getMediaFolder(): string
|
||||
{
|
||||
$mediaPath = "medias/";
|
||||
$directories = Storage::allDirectories($mediaPath);
|
||||
$selectedFolder = "";
|
||||
|
||||
// * on obtient le dernier dossier créé
|
||||
/** @var string $foldername */
|
||||
foreach ($directories as $key => $foldername) {
|
||||
if ($selectedFolder < $foldername) {
|
||||
$selectedFolder = $foldername;
|
||||
|
|
@ -123,14 +144,18 @@ trait MediaTools
|
|||
// * si on n'a pas de dossier, on le créé
|
||||
if ($selectedFolder == "") {
|
||||
$selectedFolder = $mediaPath . uniqid();
|
||||
Storage::makeDirectory($selectedFolder);
|
||||
if (!Storage::makeDirectory($selectedFolder)) {
|
||||
throw new \ErrorException("Could not create $selectedFolder");
|
||||
}
|
||||
} else {
|
||||
// * on compte le nombre de fichier
|
||||
$files = Storage::allFiles($selectedFolder);
|
||||
// * si on en a plus de 1000, on créé un nouveau dossier
|
||||
if (count($files) > 1000) {
|
||||
$selectedFolder = $mediaPath . uniqid();
|
||||
Storage::makeDirectory($selectedFolder);
|
||||
if (!Storage::makeDirectory($selectedFolder)) {
|
||||
throw new \ErrorException("Could not create $selectedFolder");
|
||||
}
|
||||
}
|
||||
}
|
||||
return $selectedFolder;
|
||||
|
|
@ -144,31 +169,36 @@ trait MediaTools
|
|||
return $size;
|
||||
}
|
||||
|
||||
public function formatBytes($octet, $precision = 2)
|
||||
/**
|
||||
* Convert file size to human readable string
|
||||
*
|
||||
* @param integer $octet
|
||||
* @param integer $precision
|
||||
* @return string
|
||||
*/
|
||||
public function formatBytes(int $octet, int $precision = 2): string
|
||||
{
|
||||
// * Array contenant les differents unités
|
||||
$unite = array('octet', 'Ko', 'Mo', 'Go');
|
||||
|
||||
// * octet
|
||||
if ($octet < 1000) {
|
||||
return $octet . $unite[0];
|
||||
} else {
|
||||
if ($octet < 1000000) {
|
||||
switch (true) {
|
||||
// * octet
|
||||
case $octet < 1000:
|
||||
return $octet . $unite[0];
|
||||
// * ko
|
||||
$ko = round($octet / 1024, 2);
|
||||
return $ko . $unite[1];
|
||||
} else {
|
||||
case $octet < 1000000:
|
||||
return $octet . $unite[1];
|
||||
// * Mo ou Go
|
||||
default:
|
||||
if ($octet < 1000000000) {
|
||||
// * Mo
|
||||
$mo = round($octet / (1024 * 1024), 2);
|
||||
$mo = round($octet / (1024 * 1024), $precision);
|
||||
return $mo . $unite[2];
|
||||
} else {
|
||||
// * Go
|
||||
$go = round($octet / (1024 * 1024 * 1024), 2);
|
||||
$go = round($octet / (1024 * 1024 * 1024), $precision);
|
||||
return $go . $unite[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives (not found)',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -120,7 +120,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
/**
|
||||
* Get the concerned disk
|
||||
*
|
||||
* @return Filesystem
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function getDisk(): Filesystem
|
||||
{
|
||||
|
|
@ -164,38 +164,38 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
/**
|
||||
* Logs data
|
||||
*
|
||||
* @param string $message
|
||||
* @param LogType $logtype
|
||||
* @param string $message
|
||||
* @param LogType|null $logtype
|
||||
* @return void
|
||||
* @throws \ErrorException If logtype is not handled.
|
||||
*/
|
||||
protected function log(string $message, LogType $logtype = null): void
|
||||
{
|
||||
if (!$logtype) {
|
||||
$logtype = LogType::debug();
|
||||
$logtype = LogType::debug;
|
||||
}
|
||||
$message = sprintf('%s : %s', get_class($this), $message);
|
||||
switch ($logtype->value) {
|
||||
case LogType::debug()->value:
|
||||
switch ($logtype) {
|
||||
case LogType::debug:
|
||||
Log::debug($message);
|
||||
break;
|
||||
case LogType::info()->value:
|
||||
case LogType::info:
|
||||
Log::info($message);
|
||||
break;
|
||||
case LogType::log()->value:
|
||||
case LogType::log:
|
||||
Log::log($message);
|
||||
break;
|
||||
case LogType::warning()->value:
|
||||
case LogType::warning:
|
||||
Log::warning($message);
|
||||
break;
|
||||
case LogType::error()->value:
|
||||
case LogType::error:
|
||||
Log::error($message);
|
||||
break;
|
||||
case LogType::critical()->value:
|
||||
case LogType::critical:
|
||||
Log::critical($message);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->name));
|
||||
} //end switch
|
||||
$this->consolePrint($message, $logtype);
|
||||
}
|
||||
|
|
@ -212,21 +212,21 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
{
|
||||
$this->clearProgressBarFromLine();
|
||||
if ($this->console) {
|
||||
switch ($logtype->value) {
|
||||
case LogType::debug()->value:
|
||||
case LogType::info()->value:
|
||||
case LogType::log()->value:
|
||||
switch ($logtype) {
|
||||
case LogType::debug:
|
||||
case LogType::info:
|
||||
case LogType::log:
|
||||
$this->console->info($message);
|
||||
break;
|
||||
case LogType::warning()->value:
|
||||
case LogType::warning:
|
||||
$this->console->comment($message);
|
||||
break;
|
||||
case LogType::error()->value:
|
||||
case LogType::critical()->value:
|
||||
case LogType::error:
|
||||
case LogType::critical:
|
||||
$this->console->error($message);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Jobs\Arcadia;
|
|||
|
||||
use App\Exceptions\AbortXmlImportException;
|
||||
use App\Exceptions\ElasticSearchException;
|
||||
use App\Lib\Utils;
|
||||
use App\Models\ArcadiaLink;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
|
@ -137,10 +136,7 @@ class XmlArcadiaMediasIn extends XmlJobs
|
|||
__LINE__,
|
||||
$e
|
||||
);
|
||||
// ! Someting went wrong
|
||||
report($report);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($report);
|
||||
throw new AbortXmlImportException($report->getMessage());
|
||||
} //end try
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace App\Jobs\Arcadia;
|
|||
use App\Enums\LogType;
|
||||
use App\Exceptions\AbortXmlImportException;
|
||||
use App\Exceptions\InvalidXmlException;
|
||||
use App\Lib\Utils;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -78,7 +78,6 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
callable $saveCallback = null,
|
||||
callable $afterSaveCallback = null
|
||||
): void {
|
||||
/** @var Filesystem */
|
||||
$disk = $this->getDisk();
|
||||
$this->log('Démarrage du traitement');
|
||||
|
||||
|
|
@ -86,7 +85,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
|
||||
$files = $disk->files();
|
||||
|
||||
$total = count(array_filter($files, function ($filename) {
|
||||
$total = count(array_filter($files, function (string $filename) {
|
||||
if ($this->fileHasToBeIgnored($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -95,6 +94,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
|
||||
$this->startProgressBar($total);
|
||||
|
||||
/** @var string $filename */
|
||||
foreach ($files as $filename) {
|
||||
if ($this->fileHasToBeIgnored($filename)) {
|
||||
continue;
|
||||
|
|
@ -121,7 +121,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
throw new InvalidXmlException('XML is Invalid (simplexml_load_string returned false)');
|
||||
}
|
||||
} catch (\ErrorException $e) {
|
||||
throw new InvalidXmlException('XML is Invalid', 0, $e);
|
||||
throw new InvalidXmlException('XML is Invalid', 0, 1, __FILE__, __LINE__, $e);
|
||||
}
|
||||
|
||||
$data = $this->extract($xmlContent);
|
||||
|
|
@ -176,7 +176,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$message,
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::critical()
|
||||
LogType::critical
|
||||
);
|
||||
$this->sendInvalidXmlEmail($filename, $e);
|
||||
$this->moveToInvalid($filename);
|
||||
|
|
@ -189,18 +189,14 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$e->getMessage(),
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::error()
|
||||
LogType::error
|
||||
);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
// * ignore the file
|
||||
} catch (QueryException $e) {
|
||||
$this->log(implode(' ', $e->errorInfo), LogType::critical());
|
||||
$this->log(implode(' ', $e->errorInfo), LogType::critical);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
} catch (FileNotFoundException $e) {
|
||||
// This happens because of concurent xml jobs read.
|
||||
|
|
@ -212,7 +208,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$message,
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::debug()
|
||||
LogType::debug
|
||||
);
|
||||
continue;
|
||||
// * ignore the file
|
||||
|
|
@ -224,11 +220,9 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$e->getMessage(),
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::critical()
|
||||
LogType::critical
|
||||
);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
// * ignore the file
|
||||
} //end try
|
||||
|
|
@ -387,7 +381,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
),
|
||||
'filename' => $filename,
|
||||
'exception' => $e->getPrevious()
|
||||
], function ($m) {
|
||||
], function (Message $m) {
|
||||
$m->to(
|
||||
config('mail.contactsList.invalidXml'),
|
||||
'XML Exception Handler'
|
||||
|
|
@ -409,7 +403,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
'File %s could not be moved to invalid folder name',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Some utilities methods
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* Manually send an exception to team instead of going trough the error handler
|
||||
* (requires package kwaadpepper/exception-handler)
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
public static function sendEmailErrorManually(\Throwable $e)
|
||||
{
|
||||
Mail::send([
|
||||
'html' => 'exception-handler.exception',
|
||||
'text' => 'exception-handler.exception-plain'
|
||||
], [
|
||||
'appName' => config('app.name'),
|
||||
'code' => $e->getCode(),
|
||||
'line' => $e->getLine(),
|
||||
'ename' => \get_class($e),
|
||||
'emessage' => self::getAnonymizedMessage($e->getMessage()),
|
||||
'file' => str_replace(\realpath(\sprintf('%s/../', \app_path())), '', $e->getFile()),
|
||||
'stackTrace' => self::getAnonymizedStackTrace($e),
|
||||
'uri' => app()->runningInConsole() ?
|
||||
'CONSOLE' : (
|
||||
(request() and request()->fullUrl()) ?
|
||||
request()->fullUrl() : 'none')
|
||||
], function ($m) {
|
||||
/** @var \Illuminate\Mail\Message $m */
|
||||
$m->to(
|
||||
config('mail.contactsList.serviceweb'),
|
||||
sprintf('%s Exception Handler', config('app.name'))
|
||||
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
|
||||
});
|
||||
Log::alert(sprintf('Envoie d\'une erreur par mail : %s', json_encode($e)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize at least Sql queries
|
||||
*
|
||||
* @param string $message
|
||||
* @return string
|
||||
*/
|
||||
private static function getAnonymizedMessage(string $message): string
|
||||
{
|
||||
$message = \preg_replace('/^(.*)( \(SQL:.*\))$/', '$1', $message) ?? $message;
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize stack trace
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return string
|
||||
*/
|
||||
private static function getAnonymizedStackTrace(\Throwable $e): string
|
||||
{
|
||||
$projectPath = \realpath(\sprintf('%s/../', \app_path()));
|
||||
$traceStack = $e->getTrace();
|
||||
$traceStr = '';
|
||||
$maxStackStage = 0;
|
||||
foreach ($traceStack as $stackStage => $stack) {
|
||||
$maxStackStage = $stackStage;
|
||||
$traceStr .= \sprintf(
|
||||
'#%s %s(%d): ',
|
||||
$stackStage,
|
||||
str_replace($projectPath, '', $stack['file'] ?? ''),
|
||||
$stack['line'] ?? ''
|
||||
);
|
||||
if (isset($stack['class'])) {
|
||||
$traceStr .= "{$stack['class']}->{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
} elseif (isset($stack['function'])) {
|
||||
$traceStr .= "{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
}
|
||||
}//end foreach
|
||||
$maxStackStage++;
|
||||
$traceStr .= "#$maxStackStage {main}";
|
||||
return $traceStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Args
|
||||
*
|
||||
* @param array $stack
|
||||
* @return string
|
||||
*/
|
||||
private static function handleArgs(array $stack): string
|
||||
{
|
||||
$traceArgs = '';
|
||||
$argsCount = count($stack['args']);
|
||||
for ($i = 0; $i < $argsCount; $i++) {
|
||||
$type = \gettype($stack['args'][$i]);
|
||||
switch ($type) {
|
||||
case 'object':
|
||||
$traceArgs .= sprintf('Object(%s)', \get_class($stack['args'][$i]));
|
||||
break;
|
||||
case 'array':
|
||||
$traceArgs .= sprintf('Array(%d)', \count($stack['args'][$i]));
|
||||
break;
|
||||
case 'string':
|
||||
$traceArgs .= sprintf('String(%d)', \strlen($stack['args'][$i]));
|
||||
break;
|
||||
default:
|
||||
$traceArgs .= \gettype($stack['args'][$i]);
|
||||
}
|
||||
$traceArgs .= ($i !== ($argsCount - 1) ? ',' : '');
|
||||
}
|
||||
return $traceArgs;
|
||||
}
|
||||
}
|
||||
|
|
@ -18,4 +18,14 @@ class EventServiceProvider extends ServiceProvider
|
|||
SendEmailVerificationNotification::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,12 +32,10 @@ class RouteServiceProvider extends ServiceProvider
|
|||
|
||||
$this->routes(function () {
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
});
|
||||
|
||||
|
|
@ -58,7 +56,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,30 +8,27 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.3|^8.0",
|
||||
"php": "^8.1",
|
||||
"ext-json": "*",
|
||||
"adldap2/adldap2-laravel": "^6.0",
|
||||
"adldap2/adldap2-laravel": "^6.1.6",
|
||||
"elasticquent/elasticquent": "dev-master",
|
||||
"fideloper/proxy": "^4.4",
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"james-heinrich/getid3": "^1.9",
|
||||
"kwaadpepper/enum": "^2.1",
|
||||
"laravel/framework": "^8.75",
|
||||
"laravel/sanctum": "^2.11",
|
||||
"laravel/tinker": "^2.5",
|
||||
"laravel/framework": "^9.2",
|
||||
"laravel/sanctum": "^2.14.1",
|
||||
"laravel/tinker": "^2.7",
|
||||
"laravel/ui": "^3.0",
|
||||
"laravelcollective/html": "^6.3",
|
||||
"slevomat/coding-standard": "^7.0"
|
||||
"laravelcollective/html": "^6.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.2",
|
||||
"facade/ignition": "^2.5",
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/sail": "^1.0.1",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^5.10",
|
||||
"phpunit/phpunit": "^9.5.10"
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"phpunit/phpunit": "^9.5.10",
|
||||
"spatie/laravel-ignition": "^1.0",
|
||||
"slevomat/coding-standard": "^7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
@ -66,6 +63,9 @@
|
|||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
|
|
|
|||
2600
composer.lock
generated
2600
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
@ -54,7 +56,7 @@ return [
|
|||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
'asset_url' => env('ASSET_URL', null),
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -189,51 +191,12 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'aliases' => [
|
||||
|
||||
'App' => Illuminate\Support\Facades\App::class,
|
||||
'Arr' => Illuminate\Support\Arr::class,
|
||||
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||
'Config' => Illuminate\Support\Facades\Config::class,
|
||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'Date' => Illuminate\Support\Facades\Date::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Http' => Illuminate\Support\Facades\Http::class,
|
||||
'Js' => Illuminate\Support\Js::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||
'Password' => Illuminate\Support\Facades\Password::class,
|
||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
|
||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||
// 'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
'Request' => Illuminate\Support\Facades\Request::class,
|
||||
'Response' => Illuminate\Support\Facades\Response::class,
|
||||
'Route' => Illuminate\Support\Facades\Route::class,
|
||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||
'Session' => Illuminate\Support\Facades\Session::class,
|
||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||
'Str' => Illuminate\Support\Str::class,
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
'Adldap' => Adldap\Laravel\Facades\Adldap::class,
|
||||
'Form' => Collective\Html\FormFacade::class,
|
||||
'Html' => Collective\Html\HtmlFacade::class,
|
||||
'Es' => Elasticquent\ElasticquentElasticsearchFacade::class,
|
||||
],
|
||||
'Es' => Elasticquent\ElasticquentElasticsearchFacade::class
|
||||
])->toArray(),
|
||||
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ return [
|
|||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => true,
|
||||
],
|
||||
'client_options' => [
|
||||
// * Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -97,12 +97,12 @@ return [
|
|||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing a RAM based store such as APC or Memcached, there might
|
||||
| be other applications utilizing the same cache. So, we'll specify a
|
||||
| value to get prefixed to all our keys so we can avoid collisions.
|
||||
| When utilizing the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'),
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ return [
|
|||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'schema' => 'public',
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
|
|
@ -83,6 +83,8 @@ return [
|
|||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
|
@ -121,14 +123,16 @@ return [
|
|||
|
||||
'default' => [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DRIVER', 'local'),
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -22,7 +22,7 @@ return [
|
|||
|
|
||||
| Here you may configure as many filesystem "disks" as you wish, and you
|
||||
| may even configure multiple disks of the same driver. Defaults have
|
||||
| been setup for each driver as an example of the required options.
|
||||
| been set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
|
|
@ -33,6 +33,7 @@ return [
|
|||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => public_path(),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
|
|
@ -40,20 +41,24 @@ return [
|
|||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'arcadia' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('export_arcadia'),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'arcadia_link_s' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/send'),
|
||||
'throw' => true,
|
||||
],
|
||||
'arcadia_link_r' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/receive'),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
|
|
@ -64,6 +69,7 @@ return [
|
|||
'bucket' => env('AWS_BUCKET'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
],
|
||||
|
|
|
|||
5
config/ldcweb.php
Normal file
5
config/ldcweb.php
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'project_uuid' => env('PROJECT_UUID')
|
||||
];
|
||||
|
|
@ -79,10 +79,11 @@ return [
|
|||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ return [
|
|||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'auth_mode' => null,
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
|
|
@ -59,7 +58,7 @@ return [
|
|||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'),
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|
|
@ -16,7 +18,7 @@ return [
|
|||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
env('APP_URL') ? ',' . parse_url(env('APP_URL'), PHP_URL_HOST) : ''
|
||||
Sanctum::currentApplicationUrlWithPort()
|
||||
))),
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ return [
|
|||
'domain' => env('MAILGUN_DOMAIN'),
|
||||
'secret' => env('MAILGUN_SECRET'),
|
||||
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
|
||||
'scheme' => 'https',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION', null),
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -100,7 +100,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE', null),
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
@ -155,7 +155,7 @@ return [
|
|||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN', null),
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ namespace Database\Factories;
|
|||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
|
|
@ -18,8 +21,8 @@ class UserFactory extends Factory
|
|||
'name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
// * password
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
|
||||
// password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
|
@ -27,7 +30,8 @@ class UserFactory extends Factory
|
|||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||
* @return static
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
||||
*/
|
||||
public function unverified()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -33,4 +33,4 @@ class CreateUsersTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('users');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreatePasswordResetsTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -29,4 +29,4 @@ class CreatePasswordResetsTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('password_resets');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateMarquesTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -29,4 +29,4 @@ class CreateMarquesTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('marques');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateFormatRestrictionsTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -43,4 +43,4 @@ class CreateFormatRestrictionsTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('format_restrictions');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Schema;
|
|||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -21,7 +21,7 @@ class CreateSettingsTable extends Migration
|
|||
$table->timestamps();
|
||||
});
|
||||
|
||||
$seeder = new SettingsSeeder;
|
||||
$seeder = new SettingsSeeder();
|
||||
$seeder->run();
|
||||
}
|
||||
|
||||
|
|
@ -34,4 +34,4 @@ class CreateSettingsTable extends Migration
|
|||
{
|
||||
Schema::dropIfExists('settings');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
|
|
|||
15
lang/en.json
Normal file
15
lang/en.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"error_occured_in_app_check_trace": "An error occured on :appName",
|
||||
"check_trace": "Please check logs in order to fix this.",
|
||||
"uri": "uri",
|
||||
"date": "date",
|
||||
"code": "code",
|
||||
"file": "file",
|
||||
"line": "line",
|
||||
"anonymized_stack_trace": "anonymized stack trace",
|
||||
"The :attribute must contain at least one letter.": "The :attribute must contain at least one letter.",
|
||||
"The :attribute must contain at least one number.": "The :attribute must contain at least one number.",
|
||||
"The :attribute must contain at least one symbol.": "The :attribute must contain at least one symbol.",
|
||||
"The :attribute must contain at least one uppercase and one lowercase letter.": "The :attribute must contain at least one uppercase and one lowercase letter.",
|
||||
"The given :attribute has appeared in a data leak. Please choose a different :attribute.": "The given :attribute has appeared in a data leak. Please choose a different :attribute."
|
||||
}
|
||||
18
phpunit.xml
18
phpunit.xml
|
|
@ -18,14 +18,14 @@
|
|||
</include>
|
||||
</coverage>
|
||||
<php>
|
||||
<server name="APP_ENV" value="testing"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="CACHE_DRIVER" value="array"/>
|
||||
<!-- <server name="DB_CONNECTION" value="sqlite" /> -->
|
||||
<!-- <server name="DB_DATABASE" value=":memory:" /> -->
|
||||
<server name="MAIL_MAILER" value="array" />
|
||||
<server name="QUEUE_CONNECTION" value="sync"/>
|
||||
<server name="SESSION_DRIVER" value="array"/>
|
||||
<server name="TELESCOPE_ENABLED" value="false" />
|
||||
<env name="APP_ENV" value="testing" />
|
||||
<env name="BCRYPT_ROUNDS" value="4" />
|
||||
<env name="CACHE_DRIVER" value="array" />
|
||||
<!-- <env name="DB_CONNECTION" value="sqlite"/> -->
|
||||
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
|
||||
<env name="MAIL_MAILER" value="array" />
|
||||
<env name="QUEUE_CONNECTION" value="sync" />
|
||||
<env name="SESSION_DRIVER" value="array" />
|
||||
<env name="TELESCOPE_ENABLED" value="false" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"error_occured_in_app_check_trace": "An error occured on :appName",
|
||||
"check_trace": "Please check logs in order to fix this.",
|
||||
"uri": "uri",
|
||||
"date": "date",
|
||||
"code": "code",
|
||||
"file": "file",
|
||||
"line": "line",
|
||||
"anonymized_stack_trace": "anonymized stack trace"
|
||||
}
|
||||
21
server.php
21
server.php
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Laravel - A PHP Framework For Web Artisans
|
||||
*
|
||||
* @package Laravel
|
||||
* @author Taylor Otwell <taylor@laravel.com>
|
||||
*/
|
||||
|
||||
$uri = urldecode(
|
||||
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?? ''
|
||||
);
|
||||
|
||||
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
|
||||
// built-in PHP web server. This provides a convenient way to test a Laravel
|
||||
// application without having installed a "real" web server software here.
|
||||
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/public/index.php';
|
||||
Loading…
Add table
Reference in a new issue