From aa29234e5546f9de0778e1e15176f849bb2b7ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Tue, 19 Apr 2022 16:07:27 +0200 Subject: [PATCH] PHPCS pass + some refactor --- app/Console/Commands/DeleteMediaArchive.php | 88 ++-- app/Console/Commands/ImportArcadiaFiles.php | 327 ++++++------ app/Console/Commands/ImportMedia.php | 102 ++-- app/Console/Commands/LDCWebStatusChecker.php | 31 +- app/Console/Commands/RegenerateThumbnails.php | 78 ++- .../SendMediasModificationsReport.php | 2 +- .../Commands/reindexElasticOneMedia.php | 4 +- app/Console/Kernel.php | 1 - app/Exceptions/Handler.php | 1 - .../Controllers/ArcadiaLinkController.php | 4 +- app/Http/Controllers/CommunController.php | 87 ++-- app/Http/Controllers/DossierController.php | 118 ++--- app/Http/Controllers/MediaController.php | 488 +++++++++--------- app/Http/Controllers/PanierController.php | 2 +- app/Http/Controllers/RecoveryController.php | 7 +- app/Http/Controllers/UploadController.php | 479 +++++++++-------- app/Http/Controllers/UserController.php | 4 +- app/Http/Middleware/Authenticate.php | 2 +- app/Http/Traits/ArcadiaLink.php | 119 +++-- app/Http/Traits/ElasticTrait.php | 15 +- app/Http/Traits/MediaTools.php | 328 ++++++------ app/Jobs/SendMediasModificationsReport.php | 24 +- app/Lib/Utils.php | 10 +- app/Mail/{contact.php => Contact.php} | 23 +- app/Mail/SendMediaReportMail.php | 12 +- app/Models/Article.php | 14 +- app/Models/Copyright.php | 12 +- app/Models/Etiquette.php | 26 +- app/Models/Format.php | 32 +- app/Models/FormatRestriction.php | 1 - app/Models/Historique.php | 28 +- app/Models/Langue.php | 12 +- app/Models/Marque.php | 44 +- app/Models/Media.php | 1 - app/Models/Recherche.php | 30 +- app/Models/Setting.php | 1 - app/Models/Site.php | 1 - app/Models/Societe.php | 14 +- app/Models/Sujet.php | 103 ++-- app/Models/Tag.php | 18 +- app/Models/Typemedia.php | 28 +- app/Models/Typevue.php | 42 +- app/Models/Variante.php | 29 +- app/Scopes/OpenLdapScope.php | 3 +- app/Scopes/SystemScope.php | 9 +- config/app.php | 190 +++---- config/auth.php | 116 ++--- config/broadcasting.php | 36 +- config/cache.php | 56 +- config/cors.php | 20 +- config/database.php | 74 +-- config/elasticquent.php | 28 +- config/filesystems.php | 62 +-- config/hashing.php | 52 +- config/ldap.php | 306 +++++------ config/ldap_auth.php | 393 +++++++------- config/logging.php | 56 +- config/queue.php | 52 +- config/sanctum.php | 66 +-- config/services.php | 18 +- config/session.php | 240 ++++----- config/view.php | 32 +- database/factories/UserFactory.php | 3 +- routes/web.php | 1 - tests/CreatesApplication.php | 2 +- tests/Feature/ExampleTest.php | 3 +- tests/Unit/ExampleTest.php | 3 +- 67 files changed, 2319 insertions(+), 2294 deletions(-) rename app/Mail/{contact.php => Contact.php} (69%) diff --git a/app/Console/Commands/DeleteMediaArchive.php b/app/Console/Commands/DeleteMediaArchive.php index 8bc5e51..c275d3b 100644 --- a/app/Console/Commands/DeleteMediaArchive.php +++ b/app/Console/Commands/DeleteMediaArchive.php @@ -40,60 +40,60 @@ class DeleteMediaArchive extends Command */ public function handle() { - $this->info('Vous allez supprimer définitivement tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete).'); + $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'); + $choice = $this->choice('Etes-vous sûr de vouloir lancer ce traitement ?', ['y', 'n'], 'y'); - if($choice != "y"){ - $this->error('Choix incorrect'); - die(); - } + if ($choice != "y") { + $this->error('Choix incorrect'); + die(); + } - $sujets = Sujet::where('sujet_dam', 1)->get(); + $sujets = Sujet::where('sujet_dam', 1)->get(); - $this->line(""); - $this->line("Liste des sujets disponibles"); - $this->line("----------------------------"); - foreach ($sujets as $key => $sujet) { - $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); - } - $this->line("[0] Tous les sujets"); + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[" . $sujet->codeSujet . "] " . $sujet->libelle); + } + $this->line("[0] Tous les sujets"); - $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?'); - if($sujetId == ""){ - $this->error('Id de sujet incorrect'); - die(); - } + if ($sujetId == "") { + $this->error('Id de sujet incorrect'); + die(); + } - if($sujetId == 0){ - $medias = Media::onlyTrashed()->with('Sujet.formats')->get(); - }else{ - $medias = Media::onlyTrashed()->where('sujet_id', $sujetId)->with('Sujet.formats')->get(); - } + if ($sujetId == 0) { + $medias = Media::onlyTrashed()->with('Sujet.formats')->get(); + } else { + $medias = Media::onlyTrashed()->where('sujet_id', $sujetId)->with('Sujet.formats')->get(); + } - if($medias->count() == 0){ - $this->error('Aucun média a supprimer'); - die(); - } + if ($medias->count() == 0) { + $this->error('Aucun média a supprimer'); + die(); + } - $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); - $bar = $this->output->createProgressBar(count($medias)); - $bar->start(); + $this->info($medias->count() . ' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); - foreach ($medias as $media) { - // 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 - $media->forceDelete(); - $bar->advance(); - } + foreach ($medias as $media) { + // 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 + $media->forceDelete(); + $bar->advance(); + } - $bar->finish(); - $this->line(""); - $this->info('Fin du traitement'); + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); } } diff --git a/app/Console/Commands/ImportArcadiaFiles.php b/app/Console/Commands/ImportArcadiaFiles.php index bf1c814..90741ad 100644 --- a/app/Console/Commands/ImportArcadiaFiles.php +++ b/app/Console/Commands/ImportArcadiaFiles.php @@ -5,7 +5,6 @@ namespace App\Console\Commands; use App\Models\Societe; use Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; -use Illuminate\Support\Facades\File; use App\Models\Article; use App\Models\Marque; use App\Models\Sujet; @@ -13,12 +12,11 @@ use App\Models\Typemedia; use App\Models\Typevue; use App\Models\Site; use App\Models\Variante; -use App\Models\Media; use App\Http\Traits\MediaTools; class ImportArcadiaFiles extends Command { - use MediaTools; + use MediaTools; /** * The name and signature of the console command. @@ -51,170 +49,181 @@ class ImportArcadiaFiles extends Command */ public function handle() { - $this->info('Démarrage du traitement'); - $files = Storage::disk('arcadia')->files(); - $bar = $this->output->createProgressBar(count($files)-1); - $bar->start(); + $this->info('Démarrage du traitement'); + $files = Storage::disk('arcadia')->files(); + $bar = $this->output->createProgressBar(count($files) - 1); + $bar->start(); - // ---- Pour chaque fichier - foreach ($files as $filename) { + // ---- Pour chaque fichier + foreach ($files as $filename) { + if ($filename == ".gitignore") { + continue; + } - if($filename == ".gitignore") continue; + // ---- Récupération du contenu + $files = Storage::disk('arcadia')->get($filename); + $fileContent = simplexml_load_string($files); - // ---- Récupération du contenu - $files = Storage::disk('arcadia')->get($filename); - $fileContent = simplexml_load_string($files); - - // ---- 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; + // ---- 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(); - } - } + $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); + // ---- 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(); + } + } - }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); + // ---- 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(); + } + } - }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, 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); + // ---- 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(); + } + } - }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, 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, 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) { + // ---- 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 + if ($record) { +// Update record $record->libelle = $row->nomSociete; $record->save(); - }else{ // Insert new record - $record = new Societe(); - $record->id = $row->codSociete; + } else { +// Insert new record + $record = new Societe(); + $record->id = $row->codSociete; $record->libelle = $row->nomSociete; $record->save(); } @@ -222,12 +231,12 @@ class ImportArcadiaFiles extends Command // ---- Suppression du fichier Storage::disk('arcadia')->delete($filename); - } - $bar->advance(); - } + }//end if + $bar->advance(); + }//end foreach - $bar->finish(); - $this->line(""); - $this->info('Fin du traitement'); + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); } } diff --git a/app/Console/Commands/ImportMedia.php b/app/Console/Commands/ImportMedia.php index 99d7ecd..e545725 100644 --- a/app/Console/Commands/ImportMedia.php +++ b/app/Console/Commands/ImportMedia.php @@ -53,29 +53,30 @@ class ImportMedia extends Command $this->line("-> Import du fichier DAM_MEDIA_VISUEL"); // ---- Traitement de l'import des XML Visuel foreach ($files as $filename) { - $path = explode("/", $filename); + $path = explode("/", $filename); $filename = $path[count($path) - 1]; // ---- Récupération du contenu - $oneFile = Storage::disk('arcadia')->get($filename); + $oneFile = Storage::disk('arcadia')->get($filename); $fileContent = simplexml_load_string($oneFile); // ---- traitement du fichier - $bar = $this->output->createProgressBar(count($fileContent->MEDIA_VISUEL)-1); + $bar = $this->output->createProgressBar(count($fileContent->MEDIA_VISUEL) - 1); $bar->start(); foreach ($fileContent->MEDIA_VISUEL as $row) { $record = Media::where('arcadia_id', $row->code)->first(); - if (!$record) { // Insert new record - $record = new Media(); + if (!$record) { +// Insert new record + $record = new Media(); $record->arcadia_id = $row->code; if ($row->extension != "") { $record->extension = $row->extension->typeFichier->libExtension; } - $record->libelle = $row->libelle; - $record->largeur = $row->nbPxLargeur; + $record->libelle = $row->libelle; + $record->largeur = $row->nbPxLargeur; $record->largeur_mm = $row->largeurMm; - $record->hauteur = $row->nbPxHauteur; + $record->hauteur = $row->nbPxHauteur; $record->hauteur_mm = $row->hauteurMm; $record->resolution = $row->pppLargeur; if ($row->version != "") { @@ -93,94 +94,93 @@ class ImportMedia extends Command $record->typevue_id = $row->codeTypeVue; } $record->commentaire = $row->commentaire; - $record->sujet_id = $row->codeSujet; + $record->sujet_id = $row->codeSujet; if ($row->langue != "") { $record->langue_id = $row->langue; } if ($row->copyright != "") { $record->copyright_id = $row->copyright; - }else{ + } else { $record->copyright_id = 3; } if ($row->codeVariante != "") { $record->variante_id = $row->codeVariante; } if ($row->dateCreation != "") { - $row->dateCreation = substr($row->dateCreation, 0, 10); - $date = explode("/", $row->dateCreation); + $row->dateCreation = substr($row->dateCreation, 0, 10); + $date = explode("/", $row->dateCreation); $record->created_at = $date[2] . '-' . $date[1] . '-' . $date[0]; } if ($row->dateModification != "") { $row->dateModification = substr($row->dateModification, 0, 10); - $date = explode("/", $row->dateModification); - $record->updated_at = $date[2] . '-' . $date[1] . '-' . $date[0]; + $date = explode("/", $row->dateModification); + $record->updated_at = $date[2] . '-' . $date[1] . '-' . $date[0]; } if ($row->datePublication != "") { $row->datePublication = substr($row->datePublication, 0, 10); - $date = explode("/", $row->datePublication); + $date = explode("/", $row->datePublication); $record->published_at = $date[2] . '-' . $date[1] . '-' . $date[0]; } $record->statut = config('services.statut.public_etendu'); // Affectation d'un dossier et d'un uid - $destinationPath = $this->get_mediaFolder() . "/"; - $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)); + $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)); - $mediaFile = "/images/" . $record->arcadia_id . "." . $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); + $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); + $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->get_file_size($full_path_dest)); - + $record->taille = $this->formatBytes($this->getFileSize($full_path_dest)); } else { // on applique une image par défaut $record->extension = "jpg"; 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->get_file_size("public/" . $destinationPath . $record->uid . '.' . $record->extension)); + $record->taille = $this->formatBytes($this->getFileSize("public/" . $destinationPath . $record->uid . '.' . $record->extension)); } $record->save(); // ---- Creation des vignettes de base - $this->create_sys_thumb($record); + $this->createSysThumb($record); // ---- Creation des vignettes en lien avec le sujet du média - $this->create_thumb($record); + $this->createThumb($record); } else { $this->line("\nDAM_MEDIA_VISUEL : le media n°" . $row->code . " existe déjà en base"); - } + }//end if $bar->advance(); - } + }//end foreach $bar->finish(); // ---- Suppression du fichier Storage::disk('arcadia')->delete($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); + $path = explode("/", $filename); $filename = $path[count($path) - 1]; // ---- Récupération du contenu - $oneFile = Storage::disk('arcadia')->get($filename); + $oneFile = Storage::disk('arcadia')->get($filename); $fileContent = simplexml_load_string($oneFile); // ---- traitement du fichier - $bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle)-1); + $bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle) - 1); $bar->start(); foreach ($fileContent->mediaassoarticle as $row) { $record = Media::where('arcadia_id', $row->codeVisuel)->first(); @@ -191,7 +191,7 @@ class ImportMedia extends Command $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) { + $dossier = Dossier::whereHas("marques", function ($query) use ($marque_id) { $query->where("codMarq", $marque_id); })->first(); @@ -203,52 +203,52 @@ class ImportMedia extends Command } else { $marque = Marque::where('codMarq', '=', $marque_id)->first(); // On cree le dossier - $dossier = new Dossier(); - $dossier->libelle = $marque->libMarq; + $dossier = new Dossier(); + $dossier->libelle = $marque->libMarq; $dossier->sujet_id = 1; - $dossier->system = 0; + $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); + // $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); + $path = explode("/", $filename); $filename = $path[count($path) - 1]; // ---- Récupération du contenu - $oneFile = Storage::disk('arcadia')->get($filename); + $oneFile = Storage::disk('arcadia')->get($filename); $fileContent = simplexml_load_string($oneFile); // ---- traitement du fichier - $bar = $this->output->createProgressBar(count($fileContent->mediaassomarque)-1); + $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)){ + if ($record->marques->contains($row->codMarq)) { $this->line("\nDAM_ASSO_MARQUE : le media n°" . $row->codeVisuel . " est déjà associé à cette marque."); - }else{ + } else { // attache la marque au média $record->marques()->attach($row->codMarq); } @@ -261,21 +261,21 @@ class ImportMedia extends Command // ---- 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); + $path = explode("/", $filename); $filename = $path[count($path) - 1]; // ---- Récupération du contenu - $oneFile = Storage::disk('arcadia')->get($filename); + $oneFile = Storage::disk('arcadia')->get($filename); $fileContent = simplexml_load_string($oneFile); // ---- traitement du fichier - $bar = $this->output->createProgressBar(count($fileContent->mediaassosociete)-1); + $bar = $this->output->createProgressBar(count($fileContent->mediaassosociete) - 1); $bar->start(); foreach ($fileContent->mediaassosociete as $row) { $record = Media::where('arcadia_id', $row->codeVisuel)->first(); @@ -291,7 +291,7 @@ class ImportMedia extends Command // ---- Suppression du fichier Storage::disk('arcadia')->delete($filename); - } + }//end foreach $this->line(""); $this->info('Fin du traitement'); diff --git a/app/Console/Commands/LDCWebStatusChecker.php b/app/Console/Commands/LDCWebStatusChecker.php index fee2b72..016e454 100644 --- a/app/Console/Commands/LDCWebStatusChecker.php +++ b/app/Console/Commands/LDCWebStatusChecker.php @@ -1,11 +1,12 @@ 0){ + $patherror = storage_path('/logs'); + $files = glob($patherror . '/*.log'); + if (count($files) > 0) { foreach ($files as $file) { $data['logs'] = $data['logs'] + filesize($file); } @@ -74,8 +75,8 @@ class LDCWebStatusChecker extends Command $data['code']['version'] = app()->version(); // Send by cURL - $url = 'https://ldc-web.ldc.fr/api/status-checker'; - $ch = curl_init($url); + $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); diff --git a/app/Console/Commands/RegenerateThumbnails.php b/app/Console/Commands/RegenerateThumbnails.php index a33506a..cb50e5d 100644 --- a/app/Console/Commands/RegenerateThumbnails.php +++ b/app/Console/Commands/RegenerateThumbnails.php @@ -3,16 +3,13 @@ namespace App\Console\Commands; use Illuminate\Console\Command; -use Illuminate\Support\Facades\Storage; use App\Models\Sujet; -use App\Models\Format; use App\Models\Media; use App\Http\Traits\MediaTools; class RegenerateThumbnails extends Command { - - use MediaTools; + use MediaTools; /** * The name and signature of the console command. @@ -45,50 +42,51 @@ class RegenerateThumbnails extends Command */ public function handle() { - $this->info('Vous allez regénérer toutes les miniatures des médias.'); + $this->info('Vous allez regénérer toutes les miniatures des médias.'); - $sujets = Sujet::where('sujet_dam', 1)->get(); + $sujets = Sujet::where('sujet_dam', 1)->get(); - $this->line(""); - $this->line("Liste des sujets disponibles"); - $this->line("----------------------------"); - foreach ($sujets as $key => $sujet) { - $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); - } - $this->line("[0] Tous les sujets"); + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[" . $sujet->codeSujet . "] " . $sujet->libelle); + } + $this->line("[0] Tous les sujets"); - $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?'); - if($sujetId == ""){ - $this->error('Id de sujet incorrect'); - die(); - } + if ($sujetId == "") { + $this->error('Id de sujet incorrect'); + die(); + } - if($sujetId == 0){ - $medias = Media::where('typemedia_id', 1)->with('Sujet.formats')->get(); - }else{ - $medias = Media::where('sujet_id', $sujetId)->where('typemedia_id', 1)->with('Sujet.formats')->get(); - } + if ($sujetId == 0) { + $medias = Media::where('typemedia_id', 1)->with('Sujet.formats')->get(); + } else { + $medias = Media::where('sujet_id', $sujetId)->where('typemedia_id', 1)->with('Sujet.formats')->get(); + } - if($medias->count() == 0){ - $this->error('Aucun média n\'a été trouvé'); - die(); - } + if ($medias->count() == 0) { + $this->error('Aucun média n\'a été trouvé'); + die(); + } - $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); - $bar = $this->output->createProgressBar(count($medias)); - $bar->start(); + $this->info($medias->count() . ' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); - foreach ($medias as $media) { - // ---- Creation des vignettes de base - $this->create_sys_thumb($media); - // ---- Creation des vignettes en lien avec le sujet du média - $this->create_thumb($media); - $bar->advance(); - } + /** @var \App\Models\Media $media */ + foreach ($medias as $media) { + // ---- Creation des vignettes de base + $this->createSysThumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->createThumb($media); + $bar->advance(); + } - $bar->finish(); - $this->line(""); - $this->info('Fin du traitement'); + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); } } diff --git a/app/Console/Commands/SendMediasModificationsReport.php b/app/Console/Commands/SendMediasModificationsReport.php index ab5a980..30c890e 100644 --- a/app/Console/Commands/SendMediasModificationsReport.php +++ b/app/Console/Commands/SendMediasModificationsReport.php @@ -39,7 +39,7 @@ class SendMediasModificationsReport extends Command public function handle() { $this->info('Running the Job, this could take some time.'); - $job = new JobsSendMediasModificationsReport(); + $job = new JobsSendMediasModificationsReport(); $job->console = $this; $job->handle(); $this->info('Job completed'); diff --git a/app/Console/Commands/reindexElasticOneMedia.php b/app/Console/Commands/reindexElasticOneMedia.php index 8932215..9dcace7 100644 --- a/app/Console/Commands/reindexElasticOneMedia.php +++ b/app/Console/Commands/reindexElasticOneMedia.php @@ -38,8 +38,8 @@ class reindexElasticOneMedia extends Command */ public function handle() { - $this->info('Reindexation du media '.$this->argument('media_id').' dans Elasticsearch...'); - $media = Media::withTrashed()->find($this->argument('media_id')); + $this->info('Reindexation du media ' . $this->argument('media_id') . ' dans Elasticsearch...'); + $media = Media::withTrashed()->find($this->argument('media_id')); $esExist = Media::searchByQuery(array('match' => array('arcadia_id' => "$media->arcadia_id"))); if ($esExist->totalHits() > 0) { $media->removeFromIndex(); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index eb14c1b..d5f0e55 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,7 +2,6 @@ namespace App\Console; -use App\Console\Commands\ArcadiaLinkCommand; use App\Jobs\Arcadia\XmlArcadiaMediasIn; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index d96a230..28ae58c 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -33,7 +33,6 @@ class Handler extends ExceptionHandler public function register() { $this->reportable(function (Throwable $e) { - // }); } } diff --git a/app/Http/Controllers/ArcadiaLinkController.php b/app/Http/Controllers/ArcadiaLinkController.php index 0ed0733..670856d 100644 --- a/app/Http/Controllers/ArcadiaLinkController.php +++ b/app/Http/Controllers/ArcadiaLinkController.php @@ -12,7 +12,7 @@ class ArcadiaLinkController extends Controller public function index(Request $request) { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); - $dt = Carbon::now('Europe/Paris')->subMinutes(15)->toDateTimeString(); + $dt = Carbon::now('Europe/Paris')->subMinutes(15)->toDateTimeString(); $ano = ArcadiaLink::where('created_at', '<', $dt)->orderBy('id', 'DESC')->get(); return view('arcadialink.index', ['ano' => $ano]); } @@ -20,7 +20,7 @@ class ArcadiaLinkController extends Controller public function delete(Request $request) { $id = $request->id; - $a = ArcadiaLink::find($id); + $a = ArcadiaLink::find($id); $a->delete(); return redirect()->route('arcadialink.index'); } diff --git a/app/Http/Controllers/CommunController.php b/app/Http/Controllers/CommunController.php index 423f015..ddff382 100644 --- a/app/Http/Controllers/CommunController.php +++ b/app/Http/Controllers/CommunController.php @@ -3,68 +3,67 @@ namespace App\Http\Controllers; use App\Models\Format; -use App\Models\Typevue; -use App\Models\Variante; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Mail; use App\Models\Sujet; use App\Models\Recherche; -use App\Models\User; use App\Models\Dossier; -use App\Mail\contact; +use App\Mail\Contact; use Illuminate\Http\Request; class CommunController extends Controller { - /** - * page d'accueil - * - * @return \Illuminate\Contracts\Support\Renderable - */ - public function index() - { - $user = Auth::user(); - $sujets = $user->sujets; - $paniers = Auth::user()->paniersFavoris; - $recherches = Recherche::where('user_id', $user->id) - ->with("sujet") - ->limit(10) - ->orderBy("created_at", "desc") - ->get(); + /** + * page d'accueil + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() + { + $user = Auth::user(); + $sujets = $user->sujets; + $paniers = Auth::user()->paniersFavoris; + $recherches = Recherche::where('user_id', $user->id) + ->with("sujet") + ->limit(10) + ->orderBy("created_at", "desc") + ->get(); - $dossiers = Dossier::whereHas("users", function($query) use ($user){ - $query->where('user_id', $user->id); - }) - ->with("sujet") - ->get(); - return view('home')->with(['sujets'=> $sujets, 'recherches'=> $recherches, 'dossiers'=> $dossiers, 'paniers'=> $paniers]); - } + $dossiers = Dossier::whereHas("users", function ($query) use ($user) { + $query->where('user_id', $user->id); + }) + ->with("sujet") + ->get(); + return view('home')->with(['sujets' => $sujets, 'recherches' => $recherches, 'dossiers' => $dossiers, 'paniers' => $paniers]); + } - /** - * Envoi d'un message - * - */ - public function sendMessage(Request $request) - { - $type = $request->input('type'); - $url = $request->input('url'); - $message = $request->input('message'); + /** + * Envoi d'un message + * + */ + public function sendMessage(Request $request) + { + $type = $request->input('type'); + $url = $request->input('url'); + $message = $request->input('message'); - if (Auth::check()) { - $user = auth()->user(); - Mail::to(env('MAIL_ADMIN_ADDRESS', "informatique.internet@ldc.fr"))->send(new contact($type, $url, $message, $user)); - } - return json_encode(array('status' => "OK")); - } + if (Auth::check()) { + $user = auth()->user(); + Mail::to(env('MAIL_ADMIN_ADDRESS', "informatique.internet@ldc.fr")) + ->send(new Contact($type, $url, $message, $user)); + } + return json_encode(array('status' => "OK")); + } - public function getDatasBySujet(Request $request) { + public function getDatasBySujet(Request $request) + { $sujet_id = $request->sujet_id; $sujet = Sujet::findOrFail($sujet_id); - $response['typesvue'] = $sujet->typeVues; + $response['typesvue'] = $sujet->typeVues; $response['typesvariantes'] = $sujet->variantes; - $response['formats'] = array_merge(Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', 1)->get()->toArray(), $sujet->formats->toArray()); + $response['formats'] = array_merge(Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', 1)->get()->toArray(), $sujet->formats->toArray()); return response()->json($response); } diff --git a/app/Http/Controllers/DossierController.php b/app/Http/Controllers/DossierController.php index 4cfd5d8..25724a4 100644 --- a/app/Http/Controllers/DossierController.php +++ b/app/Http/Controllers/DossierController.php @@ -6,7 +6,6 @@ use App\Models\Dossier; use App\Models\Sujet; use App\Models\Marque; use App\Models\Media; -use App\Models\Typevue; use App\Models\Variante; use App\Models\Format; use Illuminate\Http\Request; @@ -22,8 +21,8 @@ class DossierController extends Controller public function index() { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); - $dossiers = Dossier::whereNull('parent_id')->where('system', 0)->orderBy('libelle', 'asc')->get(); - $sujets = Sujet::where('sujet_dam', 1)->get(); + $dossiers = Dossier::whereNull('parent_id')->where('system', false)->orderBy('libelle', 'asc')->get(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.index')->with([ 'dossiers' => $dossiers, @@ -40,13 +39,13 @@ class DossierController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $marques = Marque::all(); - $sujets = Sujet::where('sujet_dam', 1)->get(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.create')->with(['marques' => $marques, 'sujets' => $sujets]); } public function createSub() { - $dossiers = Dossier::whereNull('parent_id')->where('system', 0)->orderBy('libelle', 'asc')->get(); + $dossiers = Dossier::whereNull('parent_id')->where('system', false)->orderBy('libelle', 'asc')->get(); return view('dossiers.create-sub')->with(['dossiers' => $dossiers]); } @@ -71,14 +70,13 @@ class DossierController extends Controller return redirect()->route('dossier.create'); } else { // ---- Le dossier - $dossier = new Dossier(); - $dossier->libelle = $request->libelle; + $dossier = new Dossier(); + $dossier->libelle = $request->libelle; $dossier->description = $request->description; - $dossier->is_private = $request->status; + $dossier->is_private = $request->status; $dossier->sujet()->associate($request->sujet); if ($dossier->save()) { - // ---- Les marques $sMarques = $request->marques; if ($sMarques != "") { @@ -94,7 +92,7 @@ class DossierController extends Controller session()->flash('error', "Une erreur s'est produite, ajout impossible"); return redirect()->route('dossier.create'); } - } + }//end if } public function storeSub(Request $request) @@ -106,19 +104,19 @@ class DossierController extends Controller 'parent_id' => 'required', ]); - $dossierExist = Dossier::where('libelle', $request->libelle)->first(); + $dossierExist = Dossier::where('libelle', $request->libelle)->first(); $parent_dossier = Dossier::findOrFail($request->parent_id); if ($dossierExist) { session()->flash('error', "Ce nom de dossier est déjà présent dans l'application pour ce sujet. Ajout impossible."); return redirect()->route('dossier.create'); } else { // ---- Le dossier - $dossier = new Dossier(); - $dossier->libelle = $request->libelle; + $dossier = new Dossier(); + $dossier->libelle = $request->libelle; $dossier->description = $request->description; - $dossier->is_private = 0; - $dossier->parent_id = $request->parent_id; - $dossier->sujet_id = $parent_dossier->sujet_id; + $dossier->is_private = 0; + $dossier->parent_id = $request->parent_id; + $dossier->sujet_id = $parent_dossier->sujet_id; if ($dossier->save()) { session()->flash('message', "Le dossier a été enregistré"); @@ -138,7 +136,6 @@ class DossierController extends Controller */ public function show(Dossier $dossier) { - // } /** @@ -151,9 +148,9 @@ class DossierController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $dossierMarques = $dossier->marques; - $marques = Marque::all(); - $dossierSujets = $dossier->sujets; - $sujets = Sujet::where('sujet_dam', 1)->get(); + $marques = Marque::all(); + $dossierSujets = $dossier->sujets; + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.edit')->with(['dossier' => $dossier, 'dossierMarques' => $dossierMarques, 'marques' => $marques, 'sujets' => $sujets]); } @@ -161,7 +158,7 @@ class DossierController extends Controller * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request - * @param \App\Models\Dossier $dossier + * @param \App\Models\Dossier $dossier * @return \Illuminate\Http\Response */ public function update(Request $request, Dossier $dossier) @@ -169,7 +166,6 @@ class DossierController extends Controller Auth::user()->authorizeRoles(config('roles.const.ADMIN')); if ($dossier->parent_id === null) { - $validatedData = $request->validate([ 'libelle' => 'required', 'sujet' => 'required', @@ -182,14 +178,13 @@ class DossierController extends Controller return redirect()->route('dossier.edit', ['dossier' => $dossier]); } else { // ---- Le dossier - $dossier->libelle = $request->libelle; + $dossier->libelle = $request->libelle; $dossier->description = $request->description; - $dossier->is_private = $request->status; + $dossier->is_private = $request->status; $dossier->sujet()->dissociate(); $dossier->sujet()->associate($request->sujet); if ($dossier->save()) { - // ---- Les marques $dossier->marques()->detach(); $sMarques = $request->marques; @@ -206,8 +201,8 @@ class DossierController extends Controller session()->flash('error', "Une erreur s'est produite, enregistrement impossible"); return redirect()->route('dossier.edit'); } - } - }else{ + }//end if + } else { $validatedData = $request->validate([ 'libelle' => 'required', ]); @@ -218,7 +213,7 @@ class DossierController extends Controller return redirect()->route('dossier.edit', ['dossier' => $dossier]); } else { // ---- Le dossier - $dossier->libelle = $request->libelle; + $dossier->libelle = $request->libelle; $dossier->description = $request->description; if ($dossier->save()) { @@ -229,7 +224,7 @@ class DossierController extends Controller return redirect()->route('dossier.edit'); } } - } + }//end if } /** @@ -256,15 +251,15 @@ class DossierController extends Controller public function loadFolder(Request $request) { $response = array(); - $sujetId = $request->input('sujetId'); + $sujetId = $request->input('sujetId'); $response['variantes'] = Variante::where('sujet_id', $sujetId)->get(); - $FormatsSujet = Format::whereHas('sujets', function ($query) use ($sujetId) { + $FormatsSujet = Format::whereHas('sujets', function ($query) use ($sujetId) { $query->where('sujet_id', $sujetId); })->get(); - $FormatsSystem = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', 1)->get(); + $FormatsSystem = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', true)->get(); $response['formats'] = $FormatsSujet->merge($FormatsSystem); if (Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')])) { @@ -287,28 +282,29 @@ class DossierController extends Controller { $response = array(); Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); - $parent_id = $request->input('parent_id'); - $libelle = $request->input('libelle'); + $parent_id = $request->input('parent_id'); + $libelle = $request->input('libelle'); $description = $request->input('description'); // ---- Le dossier - $dossier = new Dossier(); - $dossier->libelle = htmlspecialchars($libelle); + $dossier = new Dossier(); + $dossier->libelle = htmlspecialchars($libelle); $dossier->description = $description; - $dossier->parent_id = $parent_id; + $dossier->parent_id = $parent_id; $dossierParent = Dossier::where('id', $parent_id)->first(); - if ($parent_id == 1 || $dossierParent->system == 1) { // dossier de dépôt - $dossier->system = 1; + if ($parent_id == 1 || $dossierParent->system) { + // dossier de dépôt + $dossier->system = true; } else { - $dossier->system = 0; + $dossier->system = false; } $dossier->sujet_id = $dossierParent->sujet_id; $dossier->save(); $response['folder_id'] = $dossier->id; - $response['system'] = $dossier->system; + $response['system'] = $dossier->system ? 1 : 0; return json_encode($response); } @@ -318,17 +314,17 @@ class DossierController extends Controller */ public function addDepotFolder(Request $request) { - $response = array(); - $parent_id = $request->input('parent_id'); - $libelle = $request->input('libelle'); + $response = array(); + $parent_id = $request->input('parent_id'); + $libelle = $request->input('libelle'); $description = $request->input('description'); // ---- Le dossier - $dossier = new Dossier(); - $dossier->libelle = htmlspecialchars($libelle); + $dossier = new Dossier(); + $dossier->libelle = htmlspecialchars($libelle); $dossier->description = $description; - $dossier->parent_id = 1; - $dossier->system = 1; + $dossier->parent_id = 1; + $dossier->system = true; $dossier->save(); $response['folder_id'] = $dossier->id; @@ -363,15 +359,14 @@ class DossierController extends Controller { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); $dossier_id = $request->input('dossier_id'); - $parent_id = $request->input('parent_id'); - $sujet_id = $request->input('sujet_id'); + $parent_id = $request->input('parent_id'); + $sujet_id = $request->input('sujet_id'); // ---- Le dossier $dossier = Dossier::where('id', $dossier_id)->first(); if ($dossier && !is_null($dossier->parent_id)) { $dossier->parent_id = $parent_id; if ($dossier->save()) { - Media::where('dossier_id', $dossier_id)->update(['sujet_id' => $sujet_id]); @@ -390,7 +385,7 @@ class DossierController extends Controller { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); $dossier_id = $request->input('dossier_id'); - $libelle = $request->input('libelle'); + $libelle = $request->input('libelle'); // ---- Le dossier $dossier = Dossier::where('id', $dossier_id)->first(); @@ -409,7 +404,7 @@ class DossierController extends Controller */ public function getFolderProperty(Request $request) { - $response = array(); + $response = array(); $dossier_id = $request->input('dossier_id'); // ---- Le dossier @@ -426,14 +421,14 @@ class DossierController extends Controller */ public function saveFolderProperty(Request $request) { - $dossier_id = $request->input('dossier_id'); - $libelle = $request->input('libelle'); + $dossier_id = $request->input('dossier_id'); + $libelle = $request->input('libelle'); $description = $request->input('description'); // ---- Le dossier $dossier = Dossier::where('id', $dossier_id)->first(); if ($dossier && !is_null($dossier->parent_id) && strlen($libelle) > 3) { - $dossier->libelle = $libelle; + $dossier->libelle = $libelle; $dossier->description = $description; $dossier->save(); } @@ -442,8 +437,8 @@ class DossierController extends Controller public function loadFolders(Request $request) { - $folders = array(); - $user = Auth::user(); + $folders = array(); + $user = Auth::user(); $sujet_id = $request->sujet_id; $dossierQuery = Dossier::where([ @@ -460,7 +455,7 @@ class DossierController extends Controller ['sujet_id', '=', $sujet_id], ])->get(); } else { - $marques = $user->marques()->pluck("marque_id"); + $marques = $user->marques()->pluck("marque_id"); $privateQuery = Dossier::where([ ['is_private', '=', 1], ['sujet_id', '=', $sujet_id], @@ -473,8 +468,8 @@ class DossierController extends Controller // Ajout du dépôt de fichier pour les admin if ($user->hasRole(config('roles.const.ADMIN'))) { - $depotQuery = Dossier::whereNull('parent_id') - ->where('system', 1) + $depotQuery = Dossier::whereNull('parent_id') + ->where('system', true) ->orderBy('libelle', 'ASC') ->get(); $folders['data'] = $dossierQuery->merge($depotQuery); @@ -492,5 +487,4 @@ class DossierController extends Controller return response()->json($folders); } - } diff --git a/app/Http/Controllers/MediaController.php b/app/Http/Controllers/MediaController.php index 1971194..cd7c1ef 100644 --- a/app/Http/Controllers/MediaController.php +++ b/app/Http/Controllers/MediaController.php @@ -4,12 +4,10 @@ namespace App\Http\Controllers; use App\Http\Requests\Bo\AjaxDeleteMediaRequest; use App\Http\Traits\ArcadiaLink; -use Elasticquent\ElasticquentTrait; use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; -use App\Models\Sujet; use App\Models\Setting; use App\Models\Format; use App\Models\Media; @@ -24,13 +22,11 @@ use App\Models\Tag; use App\Models\Article; use App\Models\Recherche; use App\Models\Historique; -use App\Models\Panier; use App\Http\Traits\MediaTools; use App\Models\FormatRestriction; class MediaController extends Controller { - use MediaTools; /** @@ -40,19 +36,19 @@ class MediaController extends Controller */ public function index(Request $request) { - $filters = ""; - $sujets = Auth::user()->sujets; - $paniers = Auth::user()->paniersOwner; + $filters = ""; + $sujets = Auth::user()->sujets; + $paniers = Auth::user()->paniersOwner; $typemedias = Typemedia::all(); - $langues = Langue::all(); + $langues = Langue::all(); $copyrights = Copyright::all(); $etiquettes = Etiquette::all(); - $societes = Societe::orderBy('libelle')->get(); - $marques = Marque::all(); + $societes = Societe::orderBy('libelle')->get(); + $marques = Marque::all(); - $dossier_id = $request->get('d') !== null ? $request->get('d') : -1; - $sujet_id = $request->get('s') !== null ? $request->get('s') : 1; - $textSearch = $request->get('t'); + $dossier_id = $request->get('d') !== null ? $request->get('d') : -1; + $sujet_id = $request->get('s') !== null ? $request->get('s') : 1; + $textSearch = $request->get('t'); $recherche_id = $request->get('r'); // ---- Recherche type texte @@ -72,11 +68,11 @@ class MediaController extends Controller } elseif ($recherche_id != "") { $recherche = Recherche::where('id', $recherche_id)->first(); if ($recherche) { - $filters = $recherche->filters; - $sujet_id = $recherche->sujet_id; + $filters = $recherche->filters; + $sujet_id = $recherche->sujet_id; $dossier_id = $recherche->dossier_id; } - } + } //end if return view('media_manager')->with([ 'sujets' => $sujets, @@ -111,28 +107,29 @@ class MediaController extends Controller */ public function loadMedia(Request $request) { - $response = array(); - $userId = Auth::user()->id; + $response = array(); + $userId = Auth::user()->id; $dossier_id = $request->folder; - $sujet_id = $request->sujet; - $filters = $request->filters; - $offset = $request->offset; - $limit = $request->limit; + $sujet_id = $request->sujet; + $filters = $request->filters; + $offset = $request->offset; + $limit = $request->limit; $saveSearch = $request->saveSearch; - $isDepot = 0; + $isDepot = 0; $order = array_search('order', array_column($filters, 'type')); $orderField = $filters[$order]['value']; - $order = $filters[$order]['order']; + $order = $filters[$order]['order']; - $esMust = []; + $esMust = []; $esMustNot = []; - $esShould = []; + $esShould = []; $esFilters = []; - if ($dossier_id == "0") { // dossier racine - $esMust = array_merge($esMust, [ + if ($dossier_id == "0") { + // dossier racine + $esMust = array_merge($esMust, [ [ 'bool' => [ 'should' => [ @@ -148,7 +145,7 @@ class MediaController extends Controller 'field' => 'dossier_id' ] ]); - $esShould = array_merge($esShould, [ + $esShould = array_merge($esShould, [ [ 'match' => [ 'statut' => config('services.statut.public_etendu') @@ -165,9 +162,8 @@ class MediaController extends Controller ] ] ]); - - } elseif ($dossier_id == "-1") { // recherche global - + } elseif ($dossier_id == "-1") { + // recherche global $esMust = array_merge($esMust, [ [ 'bool' => [ @@ -195,11 +191,10 @@ class MediaController extends Controller ] ] ]); - } else { $dossier = Dossier::where('id', $dossier_id)->first(); - if ($dossier->parent_id != 1 && $dossier->id != 1) { // dossier classic - + if ($dossier->parent_id != 1 && $dossier->id != 1) { + // dossier classic $esMust = array_merge($esMust, [ [ 'bool' => [ @@ -255,33 +250,34 @@ class MediaController extends Controller ] ] )); - }//end if - } else { // dossier dépôt + } //end if + } else { + // dossier dépôt $isDepot = 1; - $esMust = array_merge($esMust, [ + $esMust = array_merge($esMust, [ [ 'match' => [ 'dossier_id' => $dossier_id ] ] ]); - } - } + } //end if + } //end if // Filtre recherche texte $tmp = array_search('search', array_column($filters, 'type')); if ($tmp !== false) { $tmpFilters = []; - $search = strtolower(trim($filters[$tmp]['value'])); + $search = strtolower(trim($filters[$tmp]['value'])); - if (strpos($search, '=') !== false){ + if (strpos($search, '=') !== false) { $tmpSearch = explode('=', $search); - $key = $tmpSearch[0]; - $needle = $tmpSearch[1]; + $key = $tmpSearch[0]; + $needle = $tmpSearch[1]; - switch ($key){ + switch ($key) { case 'ca': - $isCAQuery = true; + $isCAQuery = true; $tmpFilters = [ [ 'bool' => [ @@ -293,7 +289,7 @@ class MediaController extends Controller ] ] ]; - break; + break; case 'fv': $tmpFilters = [ [ @@ -306,7 +302,7 @@ class MediaController extends Controller ] ] ]; - break; + break; case 'gca': $tmpFilters = [ [ @@ -319,7 +315,7 @@ class MediaController extends Controller ] ] ]; - break; + break; case 'gcs': $tmpFilters = [ [ @@ -332,7 +328,7 @@ class MediaController extends Controller ] ] ]; - break; + break; case 'gcp': $tmpFilters = [ [ @@ -345,8 +341,9 @@ class MediaController extends Controller ] ] ]; - break; - case 'cd': // media id + break; + case 'cd': + // media id $tmpFilters = [ [ 'bool' => [ @@ -358,8 +355,9 @@ class MediaController extends Controller ] ] ]; - break; - case 'cv': // media arcadia_id + break; + case 'cv': + // media arcadia_id $tmpFilters = [ [ 'bool' => [ @@ -371,9 +369,9 @@ class MediaController extends Controller ] ] ]; - break; - } - }else if (strpos($search, '+') !== false){ + break; + } //end switch + } elseif (strpos($search, '+') !== false) { $tmpSearch = explode('+', $search); $mustLib = []; @@ -418,8 +416,7 @@ class MediaController extends Controller ] ] ]; - - }else{ + } else { $tmpFilters = [ [ 'multi_match' => [ @@ -439,7 +436,7 @@ class MediaController extends Controller ] ] ]; - } + } //end if $esMust = array_merge($esMust, $tmpFilters); @@ -447,18 +444,18 @@ class MediaController extends Controller if ($saveSearch == 1) { $recherche = Recherche::where('libelle', $search)->first(); if ($recherche) { - $recherche->user_id = $userId; - $recherche->sujet_id = $sujet_id; + $recherche->user_id = $userId; + $recherche->sujet_id = $sujet_id; $recherche->dossier_id = $dossier_id; - $recherche->filters = json_encode($filters); + $recherche->filters = json_encode($filters); $recherche->save(); } else { - $recherche = new Recherche(); - $recherche->user_id = $userId; - $recherche->sujet_id = $sujet_id; + $recherche = new Recherche(); + $recherche->user_id = $userId; + $recherche->sujet_id = $sujet_id; $recherche->dossier_id = $dossier_id; - $recherche->filters = json_encode($filters); - $recherche->libelle = $search; + $recherche->filters = json_encode($filters); + $recherche->libelle = $search; $recherche->save(); // Purge des anciennes recherches @@ -466,9 +463,9 @@ class MediaController extends Controller Recherche::where('user_id', $userId)->orderBy("created_at", "desc")->skip(10)->take($count)->get()->each(function ($row) { $row->delete(); }); - } - } - } + } //end if + } //end if + } //end if // Filtre type de média $tmp = array_search('typemedia_id', array_column($filters, 'type')); @@ -490,7 +487,7 @@ class MediaController extends Controller ] ] ]; - $esMust = array_merge($esMust, $esTypeMedia); + $esMust = array_merge($esMust, $esTypeMedia); } // Filtre type de vue @@ -513,7 +510,7 @@ class MediaController extends Controller ] ] ]; - $esMust = array_merge($esMust, $esTypeVue); + $esMust = array_merge($esMust, $esTypeVue); } // Filtre liason avec Arcadia @@ -526,7 +523,7 @@ class MediaController extends Controller ] ] ]; - $esMust = array_merge($esMust, $esArcadia); + $esMust = array_merge($esMust, $esArcadia); } // Filtre etiquette @@ -549,7 +546,7 @@ class MediaController extends Controller ] ] ]; - $esMust = array_merge($esMust, $esEtiquette); + $esMust = array_merge($esMust, $esEtiquette); } $query = array( @@ -578,7 +575,7 @@ class MediaController extends Controller } $response['isDepot'] = $isDepot; - if (isset($isCAQuery)){ + if (isset($isCAQuery)) { $response['isCAQuery'] = $isCAQuery; } @@ -594,9 +591,9 @@ class MediaController extends Controller public function moveMedia(Request $request) { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); - $response = false; + $response = false; $dossier_id = $request->input('dossier_id'); - $medias = $request->input('medias'); + $medias = $request->input('medias'); $user_id = Auth::user()->id; $libelle = ""; @@ -611,22 +608,22 @@ class MediaController extends Controller foreach ($medias as $media) { $media = Media::where('id', $media['id'])->first(); if ($media) { - $historique = new historique(); - $historique->user_id = $user_id; + $historique = new historique(); + $historique->user_id = $user_id; $historique->media_id = $media->id; - $historique->type = "Déplacement"; + $historique->type = "Déplacement"; if ($dossier_id > 0) { - $media->dossier_id = $dossier_id; + $media->dossier_id = $dossier_id; $historique->description = "Déplacement dans le dossier " . $libelle; } else { - $media->dossier_id = null; + $media->dossier_id = null; $historique->description = "Média déplacé à la racine"; } $media->save(); // Elasticsearch - $id = $media->id; + $id = $media->id; $media = Media::find($id); $media->removeFromIndex(); $media->addToIndex(); @@ -635,8 +632,8 @@ class MediaController extends Controller ArcadiaLink::update($media); $historique->save(); - } - } + } //end if + } //end foreach return json_encode($response); } @@ -692,13 +689,13 @@ class MediaController extends Controller public function recoverMedia(Request $request) { $arcadia_id = $request->arcadia_id; - $media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first(); + $media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first(); $media->restore(); $media->isLocked = 1; $media->save(); // Elasticsearch - $id = $media->id; + $id = $media->id; $media = Media::find($id); $media->addToIndex(); @@ -714,10 +711,10 @@ class MediaController extends Controller */ public function getOneMedia(Request $request) { - $host = $request->getSchemeAndHttpHost(); + $host = $request->getSchemeAndHttpHost(); $response = array(); $media_id = $request->input('media_id'); - $media = Media::where('id', $media_id)->with('sujet', 'societes', 'marques', 'articles', 'tags:libelle')->first(); + $media = Media::where('id', $media_id)->with('sujet', 'societes', 'marques', 'articles', 'tags:libelle')->first(); if ($media) { // stock le média $response['data'] = $media; @@ -726,21 +723,21 @@ class MediaController extends Controller $response['tags'][] = $tag->libelle; } // stock les vignettes existantes - $files = Storage::files($media->folder . "/"); - $filepath = preg_quote($media->folder . $media->uid, '/'); + $files = Storage::files($media->folder . "/"); + $filepath = preg_quote($media->folder . $media->uid, '/'); $matchingFiles = preg_grep('/^' . $filepath . '/', $files); foreach ($matchingFiles as $matchingFile) { - $path_parts = pathinfo($matchingFile); - $fileInfo = array(); - $fileInfo['url'] = $host . "/" . $matchingFile; - $fileInfo['libelle'] = $path_parts['filename']; - $fileInfo['extension'] = $path_parts['extension']; + $path_parts = pathinfo($matchingFile); + $fileInfo = array(); + $fileInfo['url'] = $host . "/" . $matchingFile; + $fileInfo['libelle'] = $path_parts['filename']; + $fileInfo['extension'] = $path_parts['extension']; $fileInfo['resolution'] = ""; if (in_array($path_parts['extension'], array("gif", "jpeg", "jpg", "png", "pdf", "ai", "psd"))) { $im = new \imagick($matchingFile); $im->setIteratorIndex(0); - $imageprops = $im->getImageGeometry(); + $imageprops = $im->getImageGeometry(); $fileInfo['resolution'] = $imageprops['width'] . "x" . $imageprops['height'] . "px"; } @@ -751,8 +748,8 @@ class MediaController extends Controller $fileInfo['libelle'] = "Format original"; } $response['vignettes'][] = $fileInfo; - } - } + } //end foreach + } //end if return json_encode($response); } @@ -764,43 +761,43 @@ class MediaController extends Controller public function saveMedia(Request $request) { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]); - $user_id = Auth::user()->id; + $user_id = Auth::user()->id; $mediaUpdate = (object)$request->input('media'); $media = Media::where('id', $mediaUpdate->id)->first(); if ($media) { - - if ($media->isLocked === 1){ + if ($media->isLocked === 1) { return json_encode(array('status' => false, 'error' => "Le média est en attente d'un retour d'Arcadia.")); } - $media->libelle = mb_substr($mediaUpdate->libelle, 0, 50, "UTF-8"); - $media->typevue_id = $mediaUpdate->typevue_id; - $media->variante_id = $mediaUpdate->variante_id; - $media->langue_id = $mediaUpdate->langue_id; - $media->commentaire = $mediaUpdate->commentaire; - $media->version = $mediaUpdate->version; + $media->libelle = mb_substr($mediaUpdate->libelle, 0, 50, "UTF-8"); + $media->typevue_id = $mediaUpdate->typevue_id; + $media->variante_id = $mediaUpdate->variante_id; + $media->langue_id = $mediaUpdate->langue_id; + $media->commentaire = $mediaUpdate->commentaire; + $media->version = $mediaUpdate->version; $media->published_at = $mediaUpdate->published_at; - $media->statut = $mediaUpdate->statut; + $media->statut = $mediaUpdate->statut; $media->copyright_id = $mediaUpdate->copyright_id; // ---- Historique des actions (etiquette seulement) if ($media->etiquette_id != $mediaUpdate->etiquette_id) { - $curEtiquette = Etiquette::where('etiquette_id', $media->etiquette_id)->first(); - $newEtiquette = Etiquette::where('etiquette_id', $mediaUpdate->etiquette_id)->first(); - $historique = new historique(); - $historique->user_id = $user_id; - $historique->media_id = $media->id; - $historique->type = "Etiquette"; + $curEtiquette = Etiquette::where('etiquette_id', $media->etiquette_id)->first(); + $newEtiquette = Etiquette::where('etiquette_id', $mediaUpdate->etiquette_id)->first(); + $historique = new historique(); + $historique->user_id = $user_id; + $historique->media_id = $media->id; + $historique->type = "Etiquette"; $historique->description = $curEtiquette->libelle . " -> " . $newEtiquette->libelle; $historique->save(); $media->etiquette_id = $mediaUpdate->etiquette_id; } // Si lié à Arcadia on bloque le media en attente du retour - if ($media->arcadia_id !== null) + if ($media->arcadia_id !== null) { $media->isLocked = 1; + } $media->save(); @@ -810,7 +807,7 @@ class MediaController extends Controller foreach ($mediaUpdate->tags as $tag) { $oTag = Tag::where('libelle', $tag['libelle'])->first(); if (!$oTag) { - $oTag = new Tag(); + $oTag = new Tag(); $oTag->libelle = $tag['libelle']; $oTag->save(); } @@ -847,7 +844,7 @@ class MediaController extends Controller } // ---- Index dans Elasticsearch - $id = $media->id; + $id = $media->id; $media = Media::find($id); $media->removeFromIndex(); $media->addToIndex(); @@ -856,14 +853,13 @@ class MediaController extends Controller ArcadiaLink::update($media); // ---- Historique des actions - $historique = new historique(); - $historique->user_id = $user_id; - $historique->media_id = $media->id; - $historique->type = "Modification"; + $historique = new historique(); + $historique->user_id = $user_id; + $historique->media_id = $media->id; + $historique->type = "Modification"; $historique->description = "Les informations du média ont été modifiées"; $historique->save(); - - } + } //end if $response = array('status' => true, 'sujet_id' => $media->sujet_id, 'datas' => $media); return json_encode($response); @@ -878,9 +874,10 @@ class MediaController extends Controller Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]); $media_id = $request->input('media_id'); + /** @var \App\Models\Media $media */ $media = Media::where('id', $media_id)->first(); - if ($media){ - if ($media->isLocked === 1){ + if ($media) { + if ($media->isLocked === 1) { return json_encode(array('status' => false, 'error' => "Le média est en attente d'un retour d'Arcadia.")); } @@ -903,48 +900,48 @@ class MediaController extends Controller $n->tags()->attach($tag); } - $destinationPath = $this->get_mediaFolder() . "/"; - $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)); - $filename = $uid . ".jpg"; + $destinationPath = $this->getMediaFolder() . "/"; + $uid = Str::uuid(); + $filename = $uid . ".jpg"; Storage::copy("assets/images/default.jpg", $destinationPath . $filename); - $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->get_file_size($destinationPath . $filename)); + $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)); $im = new \imagick($destinationPath . $filename); - //pour dev sous windows (pour cause de bug sur imagick avec les chemins relatifs) - //$im = new \imagick(realpath($destinationPath.$filename)); - $resolutions = $im->getImageResolution(); + // pour dev sous windows (pour cause de bug sur imagick avec les chemins relatifs) + // $im = new \imagick(realpath($destinationPath.$filename)); + $resolutions = $im->getImageResolution(); $n->resolution = round($resolutions['x'] * 2.54, 2); - $imageprops = $im->getImageGeometry(); - $n->largeur = $imageprops['width']; - $n->hauteur = $imageprops['height']; + $imageprops = $im->getImageGeometry(); + $n->largeur = $imageprops['width']; + $n->hauteur = $imageprops['height']; $n->largeur_mm = ceil(($n->largeur * 2.54 / $n->resolution) * 10); $n->hauteur_mm = ceil(($n->hauteur * 2.54 / $n->resolution) * 10); - $n->duree = ''; - $n->version = 1; - $n->isDefault = 1; - $n->statut = 0; + $n->duree = ''; + $n->version = 1; + $n->isDefault = 1; + $n->statut = 0; $n->created_at = NOW(); $n->updated_at = NOW(); $n->created_by = Auth::user()->id; $n->save(); // ---- Creation des vignettes de base - $this->create_sys_thumb($n); + $this->createSysThumb($n); // ---- Creation des vignettes en lien avec le sujet du média - $this->create_thumb($n); + $this->createThumb($n); $media = Media::find($n->id); $media->addToIndex(); return json_encode(array('status' => true, 'sujet_id' => $media->sujet_id, 'datas' => $media)); - } + } //end if } /** @@ -954,23 +951,23 @@ class MediaController extends Controller public function applySticker(Request $request) { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]); - $medias = $request->input('medias'); + $medias = $request->input('medias'); $etiquette_id = $request->input('etiquette_id'); - $user_id = Auth::user()->id; + $user_id = Auth::user()->id; $etiquette = Etiquette::where('etiquette_id', $etiquette_id)->first(); - $response = $etiquette; + $response = $etiquette; if ($etiquette) { foreach ($medias as $item) { $media_id = $item['id']; - $media = Media::where('id', $media_id)->first(); + $media = Media::where('id', $media_id)->first(); if ($media) { // ---- Historique des actions - $curEtiquette = Etiquette::where('etiquette_id', $media->etiquette_id)->first(); - $historique = new historique(); - $historique->user_id = $user_id; - $historique->media_id = $media->id; - $historique->type = "Etiquette"; + $curEtiquette = Etiquette::where('etiquette_id', $media->etiquette_id)->first(); + $historique = new historique(); + $historique->user_id = $user_id; + $historique->media_id = $media->id; + $historique->type = "Etiquette"; $historique->description = $curEtiquette->libelle . " -> " . $etiquette->libelle; $historique->save(); @@ -979,16 +976,16 @@ class MediaController extends Controller $media->save(); // ---- Index dans Elasticsearch - $id = $media->id; + $id = $media->id; $media = Media::find($id); $media->removeFromIndex(); $media->addToIndex(); // Lien Arcadia ArcadiaLink::update($media); - } - } - } + } //end if + } //end foreach + } //end if return json_encode($response); } @@ -1000,105 +997,108 @@ class MediaController extends Controller { Auth::user()->authorizeRoles([config('roles.const.ADMIN')]); $media_id = $request->input('media_id'); - $media = Media::find($media_id); - //il faut check les dimensions de l'image - //pour les cas sujet, type vue, type media qui nous interesse + $media = Media::find($media_id); + // il faut check les dimensions de l'image + // pour les cas sujet, type vue, type media qui nous interesse $code_sujet = $media->sujet_id; - $type_vue = $media->typevue_id; + $type_vue = $media->typevue_id; $type_media = $media->typemedia_id; - $extension = $media->extension; - $largeur = $media->largeur; - $hauteur = $media->hauteur; + $extension = $media->extension; + $largeur = $media->largeur; + $hauteur = $media->hauteur; - //on récupère les restrictions par défaut + // on récupère les restrictions par défaut $defaultwidth = Setting::where('key', 'default_size_restriction_width')->first(); - if(empty($defaultwidth->value)) { + if (empty($defaultwidth->value)) { $checkwidth = null; } else { $checkwidth = $defaultwidth->value; } $defaultheight = Setting::where('key', 'default_size_restriction_height')->first(); - if(empty($defaultheight->value)) { + if (empty($defaultheight->value)) { $checkheight = null; } else { $checkheight = $defaultheight->value; } $defaultmime = Setting::where('key', 'default_mime_restriction')->first(); - if(empty($defaultmime->value)) { + if (empty($defaultmime->value)) { $checkmime = array(); } else { $checkmime = explode(',', $defaultmime->value); } - //si on est sur un sujet arcadia (donc pas le sujet Groupe par exemple) + // si on est sur un sujet arcadia (donc pas le sujet Groupe par exemple) if ($media->sujet->sujet_arcadia) { - //le check est requis + // le check est requis $format_restriction = FormatRestriction::query(); $format_restriction = $format_restriction->selectRaw( - '*,(CASE WHEN ISNULL(sujet_id) THEN 0 ELSE 3 END) + (CASE WHEN ISNULL(typevues_id) THEN 0 ELSE 2 END) + (CASE WHEN ISNULL(typemedias_id) THEN 0 ELSE 1 END) AS wght') + '*,(CASE WHEN ISNULL(sujet_id) THEN 0 ELSE 3 END) + (CASE WHEN ISNULL(typevues_id) THEN 0 ELSE 2 END) + (CASE WHEN ISNULL(typemedias_id) THEN 0 ELSE 1 END) AS wght' + ) ->where( function ($q) use ($code_sujet) { $q->where('sujet_id', $code_sujet) ->orWhereNull('sujet_id'); - }) + } + ) ->where( function ($q) use ($type_vue) { $q->where('typevues_id', $type_vue) ->orWhereNull('typevues_id'); - }) + } + ) ->where( function ($q) use ($type_media) { $q->where('typemedias_id', $type_media) ->orWhereNull('typemedias_id'); - }) + } + ) ->orderBy('wght', 'DESC'); $format_restriction = $format_restriction->first(); - if(!$format_restriction) { - //aucune nouvelle restriction trouvée + if (!$format_restriction) { + // aucune nouvelle restriction trouvée } else { $checkwidth = $format_restriction->in_width; $checkheight = $format_restriction->in_height; - if(empty($format_restriction->in_mimes)) { - $checkmime = array(); + if (empty($format_restriction->in_mimes)) { + $checkmime = array(); } else { - $checkmime = explode(',', $format_restriction->in_mimes); + $checkmime = explode(',', $format_restriction->in_mimes); } - } - //vérification du mime - if(in_array($extension, $checkmime) || empty($checkmime)) { - //pass - //verification de la largeur - if($largeur == $checkwidth || $largeur == 1800 || is_null($checkwidth)) { - //pass - //vérification hauteur - if($hauteur == $checkheight || $hauteur == 1800 || is_null($checkheight)) { - //pass - //tout est OK + // vérification du mime + if (in_array($extension, $checkmime) || empty($checkmime)) { + // pass + // verification de la largeur + if ($largeur == $checkwidth || $largeur == 1800 || is_null($checkwidth)) { + // pass + // vérification hauteur + if ($hauteur == $checkheight || $hauteur == 1800 || is_null($checkheight)) { + // pass + // tout est OK } else { - //fail hauteur + // fail hauteur return json_encode(array('status' => false, 'error' => "Les dimensions requises sont ${checkwidth}px par ${checkheight}px, veuillez charger un autre média")); } } else { - //fail largeur + // fail largeur return json_encode(array('status' => false, 'error' => "Les dimensions requises sont ${checkwidth}px par ${checkheight}px, veuillez charger un autre média")); } } else { - //fail type de fichier - return json_encode(array('status' => false, 'error' => "Le type de fichier doit être ". implode(', ', $checkmime) .", veuillez charger un autre média")); - } - } + // fail type de fichier + return json_encode(array('status' => false, 'error' => "Le type de fichier doit être " . implode(', ', $checkmime) . ", veuillez charger un autre média")); + } //end if + } //end if if ($media) { $refs = ArcadiaLink::getRefKey($media); - if (count($refs) > 0){ + if (count($refs) > 0) { return 'true'; - }else{ + } else { return 'false'; } } @@ -1115,10 +1115,10 @@ class MediaController extends Controller $response = false; $media_id = $request->input('media_id'); - $historique = new historique(); - $historique->user_id = Auth::user()->id; - $historique->media_id = $media_id; - $historique->type = "Modification"; + $historique = new historique(); + $historique->user_id = Auth::user()->id; + $historique->media_id = $media_id; + $historique->type = "Modification"; $historique->description = "Ajout de la liaison Arcadia"; $media = Media::where('id', $media_id)->first(); @@ -1130,7 +1130,7 @@ class MediaController extends Controller ArcadiaLink::create($media); // ---- Index dans Elasticsearch - $id = $media->id; + $id = $media->id; $media = Media::find($id); $media->removeFromIndex(); $media->addToIndex(); @@ -1148,8 +1148,10 @@ class MediaController extends Controller */ public function getArticle(Request $request) { - if (!$user = Auth::user()) abort(401, 'Cette action n\'est pas autorisée.'); - $response = array(); + if (!$user = Auth::user()) { + abort(401, 'Cette action n\'est pas autorisée.'); + } + $response = array(); $arcadia_id = $request->input('arcadia_id'); $article = Article::where('noArt', $arcadia_id)->first(); @@ -1167,53 +1169,59 @@ class MediaController extends Controller */ public function downloadMedia(Request $request) { - if (!$user = Auth::user()) abort(404, 'Erreur lors du téléchargement'); + /** @var \App\Models\User|null */ + if (!$user = Auth::user()) { + abort(404, 'Erreur lors du téléchargement'); + } $deleteFileAfterSend = false; // obtention du format $formatId = $request->input('format'); if ($formatId != "original") { + /** @var \App\Models\Format|null */ $format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('id', $formatId)->first(); - if (!$format) abort(404, 'Erreur lors du téléchargement'); + if (!$format) { + abort(404, 'Erreur lors du téléchargement'); + } } else { $format = "original"; } $mediasId = $request->input('medias'); - $medias = explode(",", $mediasId); + $medias = explode(",", $mediasId); if (sizeof($medias) == 1) { $media = Media::where('id', $mediasId)->first(); if ($media) { if ($format === 'original') { - $fp = public_path() . '/' . $media->folder . $media->uid . '.' . $media->extension; - }else{ - $fp = $this->get_mediaPath($media, $format); + $fp = public_path("/{$media->folder}{$media->uid}.{$media->extension}"); + } else { + $fp = $this->getMediaPath($media, $format); } - if (!file_exists($fp)) + if (!file_exists($fp)) { abort(404, 'Fichier inconnu.'); + } $dlFileName = Str::slug($media->libelle); if ($format === 'original') { - return response()->download($fp, str_replace(' ', '_', $dlFileName)."_original_". $media->largeur ."x". $media->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend); - }else{ - return response()->download($fp, str_replace(' ', '_', $dlFileName)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend); + return response()->download($fp, str_replace(' ', '_', $dlFileName) . "_original_" . $media->largeur . "x" . $media->hauteur . "px." . pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend); + } else { + return response()->download($fp, str_replace(' ', '_', $dlFileName) . "_" . $format->libelle . "_" . $format->largeur . "x" . $format->hauteur . "px." . pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend); } } } else { // create zip archive $zip_file = public_path() . '/uploads/DAM_' . uniqid() . '_' . date("Ymd") . '.zip'; - $zip = new \ZipArchive(); + $zip = new \ZipArchive(); $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); // add file to archive foreach ($medias as $mediaId) { $media = Media::where('id', $mediaId)->first(); if ($media) { - if ($format === 'original') { $fp = public_path() . '/' . $media->folder . $media->uid . '.' . $media->extension; - }else{ - $fp = $this->get_mediaPath($media, $format); + } else { + $fp = $this->getMediaPath($media, $format); } if (!file_exists($fp)) { $zip->close(); @@ -1222,17 +1230,17 @@ class MediaController extends Controller } $dlFileName = Str::slug($media->libelle); if ($format === 'original') { - $zip->addFile($fp, str_replace(' ', '_', $dlFileName)."_original_". $media->largeur ."x". $media->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION)); - }else{ - $zip->addFile($fp, str_replace(' ', '_', $dlFileName)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION)); + $zip->addFile($fp, str_replace(' ', '_', $dlFileName) . "_original_" . $media->largeur . "x" . $media->hauteur . "px." . pathinfo($fp, PATHINFO_EXTENSION)); + } else { + $zip->addFile($fp, str_replace(' ', '_', $dlFileName) . "_" . $format->libelle . "_" . $format->largeur . "x" . $format->hauteur . "px." . pathinfo($fp, PATHINFO_EXTENSION)); } } - } + } //end foreach $deleteFileAfterSend = true; $zip->close(); $fp = $zip_file; return response()->download($fp)->deleteFileAfterSend($deleteFileAfterSend); - } + } //end if } @@ -1244,13 +1252,16 @@ class MediaController extends Controller public function getMediaOtherInfos(Request $request) { $media_id = $request->input('media_id'); - if (!$user = Auth::user()) abort(401, 'Cette action n\'est pas autorisée.'); + if (!$user = Auth::user()) { + abort(401, 'Cette action n\'est pas autorisée.'); + } $media = Media::find($media_id); - if(!$media) + if (!$media) { abort('404', "Ce média n'existe pas."); - $response = array(); - $history = Historique::where('media_id', $media_id)->with('user')->orderBy("created_date", "DESC")->get(); - $response['history'] = $history; + } + $response = array(); + $history = Historique::where('media_id', $media_id)->with('user')->orderBy("created_date", "DESC")->get(); + $response['history'] = $history; $response['vignettes'] = $this->getVignettesByMedia($media); return json_encode($response); } @@ -1266,9 +1277,9 @@ class MediaController extends Controller 'hauteur' => $media->hauteur ]; - if(in_array($media->extension, array("pdf", "ai", "psd")) ){ + if (in_array($media->extension, array("pdf", "ai", "psd"))) { $sys_extension = "png"; - }else{ + } else { $sys_extension = $media->extension; } @@ -1278,7 +1289,7 @@ class MediaController extends Controller 'largeur' => '1800', 'hauteur' => '1800' ]; - $vignettes['thumb'] = [ + $vignettes['thumb'] = [ 'url' => config('app.url') . "/" . $media->folder . $media->uid . "_thumb" . "." . $sys_extension, 'extension' => $sys_extension, 'largeur' => '200', @@ -1286,13 +1297,14 @@ class MediaController extends Controller ]; $formats = $media->sujet->formats; - foreach ($formats as $format) + foreach ($formats as $format) { $vignettes[$format->libelle] = [ 'url' => config('app.url') . "/" . $media->folder . $media->uid . "_" . $format->libelle . "." . $format->extension, 'extension' => $format->extension, 'largeur' => $format->largeur, 'hauteur' => $format->hauteur ]; + } return $vignettes; } } diff --git a/app/Http/Controllers/PanierController.php b/app/Http/Controllers/PanierController.php index c2a0a10..11c4e3a 100644 --- a/app/Http/Controllers/PanierController.php +++ b/app/Http/Controllers/PanierController.php @@ -152,7 +152,7 @@ class PanierController extends Controller /** @var \Illuminate\Database\Eloquent\Collection $formats */ $formats = Format::withoutGlobalScope('App\Scopes\SystemScope') - ->where('system', 1)->get(); + ->where('system', true)->get(); return view('panier.show')->with([ 'panier' => $panier, 'formats' => $formats, diff --git a/app/Http/Controllers/RecoveryController.php b/app/Http/Controllers/RecoveryController.php index d5b7900..0c8c68d 100644 --- a/app/Http/Controllers/RecoveryController.php +++ b/app/Http/Controllers/RecoveryController.php @@ -17,11 +17,12 @@ class RecoveryController extends Controller public function checkArcadiaId(Request $request) { - $response = false; + $response = false; $arcadia_id = $request->id; - $media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first(); - if ($media) + $media = Media::onlyTrashed()->where('arcadia_id', '=', $arcadia_id)->first(); + if ($media) { $response = true; + } return json_encode($response); } } diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php index 8a26b4d..cf9209b 100644 --- a/app/Http/Controllers/UploadController.php +++ b/app/Http/Controllers/UploadController.php @@ -1,7 +1,7 @@ get('token'); - if($token != env('TOKEN_DEPOT', "c8c4613a-236c-4b06-95f6-a9c9c6c18861")) { return abort(404); + if ($token != env('TOKEN_DEPOT', "c8c4613a-236c-4b06-95f6-a9c9c6c18861")) { + return abort(404); } $sites = Site::orderBy('libelle')->get(); return view('upload.show')->with( [ - 'sites'=> $sites, + 'sites' => $sites, ] ); } public function storeMedia(Request $request) { - $uid = $request->input('uid'); - $sujet_id = $request->input('sujet_id'); - $dossier_id = $request->input('dossier_id'); + $uid = $request->input('uid'); + $sujet_id = $request->input('sujet_id'); + $dossier_id = $request->input('dossier_id'); $replaceMediaId = $request->input('replaceMediaId'); - if($dossier_id == 0) { $dossier_id = null; + if ($dossier_id == 0) { + $dossier_id = null; } - $headers = $request->headers->all(); + $headers = $request->headers->all(); $acceptFileTypes = array('gif','jpeg', 'jpg','png','mp4','mp3','psd','ai','svg','pdf'); if ($request->hasFile('files')) { $filesa = []; - $file = $request->file('files'); + $file = $request->file('files'); - foreach($file as $files){ - $is_last_chunk = false; + foreach ($file as $files) { + $is_last_chunk = false; $is_chunked_upload = !empty($headers['content-range']); if ($is_chunked_upload) { if (preg_match('|(\d+)/(\d+)|', $headers['content-range'][0], $range)) { @@ -59,29 +59,30 @@ class UploadController extends Controller } } - $extension = strtolower($files->getClientOriginalExtension()); - $originalName = str_replace(".".$extension, "", $files->getClientOriginalName()); - if (!in_array($extension, $acceptFileTypes)) { return array("false"); + $extension = strtolower($files->getClientOriginalExtension()); + $originalName = str_replace("." . $extension, "", $files->getClientOriginalName()); + if (!in_array($extension, $acceptFileTypes)) { + return array("false"); } - if($is_chunked_upload) { - $filename = $uid."_".$range[1].".".$extension; - }else{ - $filename = $uid.'.'.$extension; + if ($is_chunked_upload) { + $filename = $uid . "_" . $range[1] . "." . $extension; + } else { + $filename = $uid . '.' . $extension; } $uploadPath = public_path() . '/uploads/'; $files->move($uploadPath, $filename); // si c'est le dernier morceux d'un fichier - if($is_last_chunk) { - if($dossier = opendir($uploadPath)) { + if ($is_last_chunk) { + if ($dossier = opendir($uploadPath)) { $dirFiles = array(); // 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)); + while (false !== ($fichier = readdir($dossier))) { + if ($fichier != '.' && $fichier != '..') { + if (strpos($fichier, $uid) !== false) { + $dirFiles[$fichier] = str_replace("." . $extension, "", str_replace($uid . "_", "", $fichier)); } } } @@ -90,134 +91,131 @@ class UploadController extends Controller asort($dirFiles, SORT_NUMERIC); // on les assemble dans un fichier final $filename = $uid . '.' . $extension; - foreach($dirFiles as $key => $fichier) { - $file = fopen($uploadPath.$key, 'rb'); - $buff = fread($file, filesize($uploadPath.$key)); + foreach ($dirFiles as $key => $fichier) { + $file = fopen($uploadPath . $key, 'rb'); + $buff = fread($file, filesize($uploadPath . $key)); fclose($file); - $final = fopen($uploadPath.$filename, 'a'); + $final = fopen($uploadPath . $filename, 'a'); $write = fwrite($final, $buff); fclose($final); - unlink($uploadPath.$key); + unlink($uploadPath . $key); } - - - } - } + }//end if + }//end if // 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->get_mediaFolder()."/"; + if ($is_last_chunk || !$is_chunked_upload) { + $destinationPath = $this->getMediaFolder() . "/"; // si on upload un média pour remplacer un fichier par un autre - if($replaceMediaId != 0) { + if ($replaceMediaId != 0) { // on récupère le média à modifier - $media= Media::where('id', $replaceMediaId)->first(); + /** @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); + Storage::move("uploads/" . $filename, $destinationPath . $filename); // 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); + $filesfF = Storage::files($media->folder . "/"); + $filepath = preg_quote($media->folder . $media->uid, '/'); + $matchingFiles = preg_grep('/^' . $filepath . '/', $filesfF); Storage::delete($matchingFiles); $media->isDefault = 0; $media->save(); - - }else{ + } else { // On déplace le fichier dans le répertoire des médias - Storage::move("uploads/".$filename, $destinationPath.$filename); + Storage::move("uploads/" . $filename, $destinationPath . $filename); // on créé un média en bdd - $media = new Media(); + $media = new Media(); $media->dossier_id = $dossier_id; - $media->sujet_id = $sujet_id; + $media->sujet_id = $sujet_id; // Par défaut FR $media->langue_id = 1; // Par défaut propriété de la marque $media->copyright_id = 3; - } + }//end if $media->extension = $extension; - $media->folder = $destinationPath; - if($replaceMediaId == 0) { - $media->libelle = mb_substr($originalName, 0, 50, "UTF-8"); - $media->created_by= Auth::user()->id; + $media->folder = $destinationPath; + if ($replaceMediaId == 0) { + $media->libelle = mb_substr($originalName, 0, 50, "UTF-8"); + $media->created_by = Auth::user()->id; } - $media->uid = $uid; - $media->taille = $this->formatBytes($this->get_file_size($destinationPath.$filename)); + $media->uid = $uid; + $media->taille = $this->formatBytes($this->getFileSize($destinationPath . $filename)); switch ($extension) { // Photo (1) - case 'gif': - case 'jpeg': - case 'jpg': - case 'png': - case 'ai': - case 'pdf': - case 'psd': - $media->typemedia_id = 1; - $im = new \imagick($destinationPath.$filename); + case 'gif': + case 'jpeg': + case 'jpg': + case 'png': + case 'ai': + case 'pdf': + case 'psd': + $media->typemedia_id = 1; + $im = new \imagick($destinationPath . $filename); - if(in_array($extension, array("pdf", "ai", "psd", "gif")) ) { - $im->setIteratorIndex(0); - } + if (in_array($extension, array("pdf", "ai", "psd", "gif"))) { + $im->setIteratorIndex(0); + } - $resolutions = $im->getImageResolution(); - $media->resolution = round($resolutions['x'] * 2.54); - $imageprops = $im->getImageGeometry(); - $media->largeur = $imageprops['width']; - $media->hauteur = $imageprops['height']; + $resolutions = $im->getImageResolution(); + $media->resolution = round($resolutions['x'] * 2.54); + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; - if($media->resolution != 0) { - $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); - $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); - }else{ - $media->largeur_mm = ""; - $media->hauteur_mm = ""; - } - $media->save(); - $im->destroy(); + if ($media->resolution != 0) { + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution) * 10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution) * 10); + } else { + $media->largeur_mm = ""; + $media->hauteur_mm = ""; + } + $media->save(); + $im->destroy(); - // ---- Creation des vignettes de base - $this->create_sys_thumb($media); - // ---- Creation des vignettes en lien avec le sujet du média - if(isset($sujet_id) ) { - $this->create_thumb($media); - } - break; + // ---- Creation des vignettes de base + $this->createSysThumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + if (isset($sujet_id)) { + $this->createThumb($media); + } + break; // Illustration/Vectorielle (2) - case 'svg': - $media->typemedia_id = 2; - $media->save(); - break; + case 'svg': + $media->typemedia_id = 2; + $media->save(); + break; // Vidéo (3) - case 'mp4': - $media->typemedia_id =3 ; - $getID3 = new \getID3; - if($fileInfo = $getID3->analyze($destinationPath.$filename)) { - $media->largeur = $fileInfo['video']['resolution_x']; - $media->hauteur = $fileInfo['video']['resolution_y']; - $media->duree = $fileInfo['playtime_string']; - } - $media->save(); - break; + case 'mp4': + $media->typemedia_id = 3; + $getID3 = new \getID3(); + if ($fileInfo = $getID3->analyze($destinationPath . $filename)) { + $media->largeur = $fileInfo['video']['resolution_x']; + $media->hauteur = $fileInfo['video']['resolution_y']; + $media->duree = $fileInfo['playtime_string']; + } + $media->save(); + break; // Audio (4) - case 'mp3': - $media->typemedia_id = 4; - $getID3 = new \getID3; - if($fileInfo = $getID3->analyze($destinationPath.$filename)) { - $media->duree= $fileInfo['playtime_string']; - } - $media->save(); - break; - } + case 'mp3': + $media->typemedia_id = 4; + $getID3 = new \getID3(); + if ($fileInfo = $getID3->analyze($destinationPath . $filename)) { + $media->duree = $fileInfo['playtime_string']; + } + $media->save(); + break; + }//end switch - $id = $media->id; + $id = $media->id; $media = Media::find($id); // ---- Index dans Elasticsearch $media = Media::where('id', $media->id)->first(); @@ -225,45 +223,46 @@ class UploadController extends Controller // ---- Historique des actions $historique = new historique(); - if($user = Auth::user()) { + if ($user = Auth::user()) { $historique->user_id = $user->id; } $historique->media_id = $media->id; - if($replaceMediaId == 0) { - $historique->type = "Création"; + if ($replaceMediaId == 0) { + $historique->type = "Création"; $historique->description = "Média ajouté"; - }else{ - $historique->type = "Modification"; + } else { + $historique->type = "Modification"; $historique->description = "Le média a été remplacé"; } $historique->save(); - $filest = array(); - $filest['name'] = $filename; - $filest['uid'] = $uid; - $filest['libelle'] = $media->libelle; - $filest['id'] = $media->id; - $filest['folder'] = $media->folder; - $filest['extension'] = $media->extension; + $filest = array(); + $filest['name'] = $filename; + $filest['uid'] = $uid; + $filest['libelle'] = $media->libelle; + $filest['id'] = $media->id; + $filest['folder'] = $media->folder; + $filest['extension'] = $media->extension; $filest['typemedia_id'] = $media->typemedia_id; - $filesa['files'][]=$filest; - } - } - return $filesa; - } + $filesa['files'][] = $filest; + }//end if + }//end foreach + return $filesa; + }//end if } public function storeMediaV2(Request $request) { - $uid = $request->input('uid'); - $sujet_id = $request->input('sujet_id'); - $dossier_id = $request->input('dossier_id'); + $uid = $request->input('uid'); + $sujet_id = $request->input('sujet_id'); + $dossier_id = $request->input('dossier_id'); $replaceMediaId = $request->input('replaceMediaId'); - if($dossier_id == 0) { $dossier_id = null; + if ($dossier_id == 0) { + $dossier_id = null; } - $filesa = []; + $filesa = []; $acceptFileTypes = array('gif','jpeg', 'jpg','png','mp4','mp3','psd','ai','svg','pdf'); if (!$uid) { @@ -272,12 +271,14 @@ class UploadController extends Controller $file = $request->file('files'); if (!empty($file)) { - $extension = strtolower($file->getClientOriginalExtension()); - $originalName = str_replace(".".$extension, "", $file->getClientOriginalName()); - if (!in_array($extension, $acceptFileTypes)) { return array("false"); + $extension = strtolower($file->getClientOriginalExtension()); + $originalName = str_replace("." . $extension, "", $file->getClientOriginalName()); + if (!in_array($extension, $acceptFileTypes)) { + return array("false"); } - if (!in_array($extension, $acceptFileTypes)) { return array("error" => "Ce type de fichier n'est pas accepté."); + if (!in_array($extension, $acceptFileTypes)) { + return array("error" => "Ce type de fichier n'est pas accepté."); } // check the error status @@ -287,7 +288,7 @@ class UploadController extends Controller // init the destination file (format .part<#chunk> // the file is stored in a temporary directory - if(isset($request->resumableIdentifier) && trim($request->resumableIdentifier)!='') { + if (isset($request->resumableIdentifier) && trim($request->resumableIdentifier) != '') { $temp_dir = 'uploads/' . $request->resumableIdentifier; } $dest_file = $temp_dir . '/' . $request->resumableFilename . '.part' . $request->resumableChunkNumber; @@ -299,123 +300,121 @@ class UploadController extends Controller // 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('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); if ($isLast) { - - $destinationPath = $this->get_mediaFolder()."/"; + $destinationPath = $this->getMediaFolder() . "/"; // si on upload un média pour remplacer un fichier par un autre - if($replaceMediaId != 0) { + if ($replaceMediaId != 0) { // on récupère le média à modifier - $media= Media::where('id', $replaceMediaId)->first(); + /** @var \App\Models\Media|null $media */ + $media = Media::where('id', $replaceMediaId)->first(); // On déplace le fichier dans le répertoire des médias - Storage::move("uploads/".$filename, $destinationPath.$filename); + Storage::move("uploads/" . $filename, $destinationPath . $filename); // 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); + $filesfF = Storage::files($media->folder . "/"); + $filepath = preg_quote($media->folder . $media->uid, '/'); + $matchingFiles = preg_grep('/^' . $filepath . '/', $filesfF); Storage::delete($matchingFiles); $media->isDefault = 0; $media->save(); - - }else{ + } else { // On déplace le fichier dans le répertoire des médias - Storage::move("uploads/".$filename, $destinationPath.$filename); + Storage::move("uploads/" . $filename, $destinationPath . $filename); // on créé un média en bdd - $media = new Media(); + $media = new Media(); $media->dossier_id = $dossier_id; - $media->sujet_id = $sujet_id; + $media->sujet_id = $sujet_id; // Par défaut FR $media->langue_id = 1; // Par défaut propriété de la marque $media->copyright_id = 3; - } + }//end if $media->extension = $extension; - $media->folder = $destinationPath; - if($replaceMediaId == 0) { - $media->libelle = mb_substr($originalName, 0, 50, "UTF-8"); - $media->created_by= Auth::user()->id; + $media->folder = $destinationPath; + if ($replaceMediaId == 0) { + $media->libelle = mb_substr($originalName, 0, 50, "UTF-8"); + $media->created_by = Auth::user()->id; } - $media->uid = $uid; - $media->taille = $this->formatBytes($this->get_file_size($destinationPath.$filename)); + $media->uid = $uid; + $media->taille = $this->formatBytes($this->getFileSize($destinationPath . $filename)); switch ($extension) { // Photo (1) - case 'gif': - case 'jpeg': - case 'jpg': - case 'png': - case 'ai': - case 'pdf': - case 'psd': - $media->typemedia_id = 1; - $im = new \imagick($destinationPath . $filename); - //$im = new \imagick(realpath($destinationPath.$filename)); + case 'gif': + case 'jpeg': + case 'jpg': + case 'png': + case 'ai': + case 'pdf': + 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); + } - if(in_array($extension, array("pdf", "ai", "psd", "gif")) ) { - $im->setIteratorIndex(0); - } + $resolutions = $im->getImageResolution(); + $media->resolution = round($resolutions['x'] * 2.54); + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; - $resolutions = $im->getImageResolution(); - $media->resolution = round($resolutions['x'] * 2.54); - $imageprops = $im->getImageGeometry(); - $media->largeur = $imageprops['width']; - $media->hauteur = $imageprops['height']; + if ($media->resolution != 0) { + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution) * 10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution) * 10); + } else { + $media->largeur_mm = ""; + $media->hauteur_mm = ""; + } + $media->save(); + $im->destroy(); - if($media->resolution != 0) { - $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); - $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); - }else{ - $media->largeur_mm = ""; - $media->hauteur_mm = ""; - } - $media->save(); - $im->destroy(); - - // ---- Creation des vignettes de base - $this->create_sys_thumb($media); - // ---- Creation des vignettes en lien avec le sujet du média - if(isset($sujet_id) ) { - $this->create_thumb($media); - } - break; + // ---- Creation des vignettes de base + $this->createSysThumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + if (isset($sujet_id)) { + $this->createThumb($media); + } + break; // Illustration/Vectorielle (2) - case 'svg': - $media->typemedia_id = 2; - $media->save(); - break; + case 'svg': + $media->typemedia_id = 2; + $media->save(); + break; // Vidéo (3) - case 'mp4': - $media->typemedia_id =3 ; - $getID3 = new \getID3; - if($fileInfo = $getID3->analyze($destinationPath.$filename)) { - $media->largeur = $fileInfo['video']['resolution_x']; - $media->hauteur = $fileInfo['video']['resolution_y']; - $media->duree = $fileInfo['playtime_string']; - } - $media->save(); - break; + case 'mp4': + $media->typemedia_id = 3; + $getID3 = new \getID3(); + if ($fileInfo = $getID3->analyze($destinationPath . $filename)) { + $media->largeur = $fileInfo['video']['resolution_x']; + $media->hauteur = $fileInfo['video']['resolution_y']; + $media->duree = $fileInfo['playtime_string']; + } + $media->save(); + break; // Audio (4) - case 'mp3': - $media->typemedia_id = 4; - $getID3 = new \getID3; - if($fileInfo = $getID3->analyze($destinationPath.$filename)) { - $media->duree= $fileInfo['playtime_string']; - } - $media->save(); - break; - } + case 'mp3': + $media->typemedia_id = 4; + $getID3 = new \getID3(); + if ($fileInfo = $getID3->analyze($destinationPath . $filename)) { + $media->duree = $fileInfo['playtime_string']; + } + $media->save(); + break; + }//end switch - $id = $media->id; + $id = $media->id; $media = Media::find($id); // ---- Index dans Elasticsearch $media = Media::where('id', $media->id)->first(); @@ -423,23 +422,23 @@ class UploadController extends Controller // ---- Historique des actions $historique = new historique(); - if($user = Auth::user()) { + if ($user = Auth::user()) { $historique->user_id = $user->id; } $historique->media_id = $media->id; - if($replaceMediaId == 0) { - $historique->type = "Création"; + if ($replaceMediaId == 0) { + $historique->type = "Création"; $historique->description = "Média ajouté"; - }else{ - $historique->type = "Modification"; + } else { + $historique->type = "Modification"; $historique->description = "Le média a été remplacé"; } $historique->save(); return response()->json($media); - } - } - } + }//end if + }//end if + }//end if } /** @@ -450,27 +449,27 @@ class UploadController extends Controller * @param string $fileName - the original file name * @param string $chunkSize - each chunk size (in bytes) * @param string $totalSize - original file size (in bytes) - * @return bool + * @return boolean */ private function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize, $total_files, $finalName) { // count all the parts of this file $total_files_on_server_size = 0; - $temp_total = 0; - foreach(scandir($temp_dir) as $file) { - $temp_total = $total_files_on_server_size; - $tempfilesize = filesize($temp_dir.'/'.$file); + $temp_total = 0; + foreach (scandir($temp_dir) as $file) { + $temp_total = $total_files_on_server_size; + $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. if ($total_files_on_server_size >= $totalSize) { // 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); + 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); } fclose($fp); } else { @@ -480,13 +479,13 @@ class UploadController extends Controller // 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'); + if (rename($temp_dir, $temp_dir . '_UNUSED')) { + $this->rrmdir($temp_dir . '_UNUSED'); } else { $this->rrmdir($temp_dir); } return true; - } + }//end if return false; } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index b3150e2..fd6179c 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -204,7 +204,7 @@ class UserController extends Controller * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request - * @param \App\Models\User $user + * @param \App\Models\User $user * @return \Illuminate\Http\Response */ public function update(Request $request, User $user) @@ -257,7 +257,7 @@ class UserController extends Controller * Remove the specified resource from storage. * * @param \App\Http\Requests\DestroyUserRequest $request - * @param \App\Models\User $user + * @param \App\Models\User $user * @return \Illuminate\Http\Response */ public function destroy(DestroyUserRequest $request, User $user) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 704089a..aeb9d80 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -9,7 +9,7 @@ class Authenticate extends Middleware /** * Get the path the user should be redirected to when they are not authenticated. * - * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Request $request * @return string|null */ protected function redirectTo($request) diff --git a/app/Http/Traits/ArcadiaLink.php b/app/Http/Traits/ArcadiaLink.php index 081f903..d1ca624 100644 --- a/app/Http/Traits/ArcadiaLink.php +++ b/app/Http/Traits/ArcadiaLink.php @@ -8,21 +8,24 @@ use DOMDocument; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Storage; -trait ArcadiaLink { - +trait ArcadiaLink +{ public static function checkRequiredValues($media) { $required = ['sujet_id', 'typemedia_id', 'typevue_id', 'variante_id', 'langue_id', 'version']; - foreach ($required as $v) - if ($media->$v === NULL) + foreach ($required as $v) { + if ($media->$v === null) { return false; + } + } return true; } public static function create($media) { - if (!self::checkRequiredValues($media)) + if (!self::checkRequiredValues($media)) { return; + } $media->isLocked = 1; $media->save(); @@ -31,11 +34,13 @@ trait ArcadiaLink { public static function update($media) { - if ($media->arcadia_id === NULL) + if ($media->arcadia_id === null) { return; + } - if (!self::checkRequiredValues($media)) + if (!self::checkRequiredValues($media)) { return; + } $media->isLocked = 1; $media->save(); @@ -44,11 +49,13 @@ trait ArcadiaLink { public static function delete($media) { - if ($media->arcadia_id === NULL) + if ($media->arcadia_id === null) { return; + } - if (!self::checkRequiredValues($media)) + if (!self::checkRequiredValues($media)) { return; + } $media->isLocked = 1; $media->save(); @@ -57,11 +64,13 @@ trait ArcadiaLink { public static function reactivate($media) { - if ($media->arcadia_id === NULL) + if ($media->arcadia_id === null) { return; + } - if (!self::checkRequiredValues($media)) + if (!self::checkRequiredValues($media)) { return; + } $media->isLocked = 1; $media->save(); @@ -78,8 +87,8 @@ trait ArcadiaLink { private static function compress($uid, $media) { try { - $zip_file = storage_path('arcadia_link/send') ."/$media->id-$uid.zip"; - $zip = new \ZipArchive(); + $zip_file = storage_path('arcadia_link/send') . "/$media->id-$uid.zip"; + $zip = new \ZipArchive(); $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); $zip->addFile(storage_path('arcadia_link/send') . "/$uid.xml", 'media.xml'); $zip->addFile(public_path() . "/$media->folder$media->uid.$media->extension", "$media->uid.$media->extension"); @@ -88,78 +97,77 @@ trait ArcadiaLink { unlink(storage_path('arcadia_link/send') . "/$uid.xml"); // On insert dans la table de supervision - $s = new \App\Models\ArcadiaLink(); + $s = new \App\Models\ArcadiaLink(); $s->media_id = $media->id; - if ($media->arcadia_id !== NULL) { + if ($media->arcadia_id !== null) { $s->arcadia_id = $media->arcadia_id; } $s->filename = "$media->id-$uid.zip"; $s->save(); - } catch (Exception $e) { - //echo "Exception : " . $e; + // echo "Exception : " . $e; // TODO : Envoi mail Log Log::emergency("Erreur création .zip : $e (Traits/ArcadiaLink)"); - } + }//end try } private static function getXML($media, $mouvement) { - $refKey = self::getRefKey($media); + $refKey = self::getRefKey($media); $formats = self::getFormats(); - $dom = new DOMDocument('1.0','UTF-8'); + $dom = new DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $root = $dom->createElement('MEDIA_VISUEL'); $dom->appendChild($root); - $root->appendChild($dom->createElement('codeArcadia'))->appendChild($dom->createCDATASection( "$media->arcadia_id")); - $root->appendChild($dom->createElement('code_DAM'))->appendChild($dom->createCDATASection( "$media->id")); - $root->appendChild( $dom->createElement('TypeMouvement'))->appendChild($dom->createCDATASection( "$mouvement")); + $root->appendChild($dom->createElement('codeArcadia'))->appendChild($dom->createCDATASection("$media->arcadia_id")); + $root->appendChild($dom->createElement('code_DAM'))->appendChild($dom->createCDATASection("$media->id")); + $root->appendChild($dom->createElement('TypeMouvement'))->appendChild($dom->createCDATASection("$mouvement")); - $cleRef = $root->appendChild( $dom->createElement('cle_Referentiel')); + $cleRef = $root->appendChild($dom->createElement('cle_Referentiel')); foreach ($refKey as $k) { if ($media->sujet_id === 1) { $cleRef->appendChild($dom->createElement('id'))->appendChild($dom->createCDATASection("$k->noArt")); - }elseif ($media->sujet_id === 2) { + } elseif ($media->sujet_id === 2) { $cleRef->appendChild($dom->createElement('id'))->appendChild($dom->createCDATASection("$k->codMarq")); - }elseif ($media->sujet_id === 4) { + } elseif ($media->sujet_id === 4) { $cleRef->appendChild($dom->createElement('id'))->appendChild($dom->createCDATASection("$k->id")); } } - $root->appendChild( $dom->createElement('libExtension'))->appendChild($dom->createCDATASection( "$media->extension")); - $root->appendChild( $dom->createElement('nbPxLargeur'))->appendChild($dom->createCDATASection( "$media->largeur")); - $root->appendChild( $dom->createElement('largeurMm'))->appendChild($dom->createCDATASection( "$media->largeur_mm")); - $root->appendChild( $dom->createElement('nbPxHauteur'))->appendChild($dom->createCDATASection( "$media->hauteur")); - $root->appendChild( $dom->createElement('hauteurMm'))->appendChild($dom->createCDATASection( "$media->hauteur_mm")); - $root->appendChild( $dom->createElement('pppLargeur'))->appendChild($dom->createCDATASection( "$media->resolution")); - $root->appendChild( $dom->createElement('version'))->appendChild($dom->createCDATASection( "$media->version")); - $root->appendChild( $dom->createElement('codeTypeMedia'))->appendChild($dom->createCDATASection( "$media->typemedia_id")); - $root->appendChild( $dom->createElement('codeTypeVue'))->appendChild($dom->createCDATASection( "$media->typevue_id")); - $root->appendChild( $dom->createElement('commentaire'))->appendChild($dom->createCDATASection( "$media->commentaire")); - $root->appendChild( $dom->createElement('codeSujet'))->appendChild($dom->createCDATASection( "$media->sujet_id")); - $root->appendChild( $dom->createElement('langue'))->appendChild($dom->createCDATASection( "$media->langue_id")); - $root->appendChild( $dom->createElement('copyright'))->appendChild($dom->createCDATASection( "$media->copyright_id")); - $root->appendChild( $dom->createElement('codeVariante'))->appendChild($dom->createCDATASection( "$media->variante_id")); - $root->appendChild( $dom->createElement('dateCreation'))->appendChild($dom->createCDATASection( "$media->created_at")); - $root->appendChild( $dom->createElement('dateModification'))->appendChild($dom->createCDATASection( "$media->updated_at")); - $root->appendChild( $dom->createElement('datePublication'))->appendChild($dom->createCDATASection( "$media->published_at")); - $root->appendChild( $dom->createElement('libelle'))->appendChild($dom->createCDATASection( "$media->libelle")); - $root->appendChild( $dom->createElement('NomFichier'))->appendChild($dom->createCDATASection( "$media->uid.$media->extension")); + $root->appendChild($dom->createElement('libExtension'))->appendChild($dom->createCDATASection("$media->extension")); + $root->appendChild($dom->createElement('nbPxLargeur'))->appendChild($dom->createCDATASection("$media->largeur")); + $root->appendChild($dom->createElement('largeurMm'))->appendChild($dom->createCDATASection("$media->largeur_mm")); + $root->appendChild($dom->createElement('nbPxHauteur'))->appendChild($dom->createCDATASection("$media->hauteur")); + $root->appendChild($dom->createElement('hauteurMm'))->appendChild($dom->createCDATASection("$media->hauteur_mm")); + $root->appendChild($dom->createElement('pppLargeur'))->appendChild($dom->createCDATASection("$media->resolution")); + $root->appendChild($dom->createElement('version'))->appendChild($dom->createCDATASection("$media->version")); + $root->appendChild($dom->createElement('codeTypeMedia'))->appendChild($dom->createCDATASection("$media->typemedia_id")); + $root->appendChild($dom->createElement('codeTypeVue'))->appendChild($dom->createCDATASection("$media->typevue_id")); + $root->appendChild($dom->createElement('commentaire'))->appendChild($dom->createCDATASection("$media->commentaire")); + $root->appendChild($dom->createElement('codeSujet'))->appendChild($dom->createCDATASection("$media->sujet_id")); + $root->appendChild($dom->createElement('langue'))->appendChild($dom->createCDATASection("$media->langue_id")); + $root->appendChild($dom->createElement('copyright'))->appendChild($dom->createCDATASection("$media->copyright_id")); + $root->appendChild($dom->createElement('codeVariante'))->appendChild($dom->createCDATASection("$media->variante_id")); + $root->appendChild($dom->createElement('dateCreation'))->appendChild($dom->createCDATASection("$media->created_at")); + $root->appendChild($dom->createElement('dateModification'))->appendChild($dom->createCDATASection("$media->updated_at")); + $root->appendChild($dom->createElement('datePublication'))->appendChild($dom->createCDATASection("$media->published_at")); + $root->appendChild($dom->createElement('libelle'))->appendChild($dom->createCDATASection("$media->libelle")); + $root->appendChild($dom->createElement('NomFichier'))->appendChild($dom->createCDATASection("$media->uid.$media->extension")); - $mediaFormat = $root->appendChild( $dom->createElement('formats')); + $mediaFormat = $root->appendChild($dom->createElement('formats')); foreach ($formats as $k) { - $format = $mediaFormat->appendChild( $dom->createElement('format')); - $format->appendChild( $dom->createElement('id'))->appendChild($dom->createCDATASection( $k['id'])); - $format->appendChild( $dom->createElement('libelle'))->appendChild($dom->createCDATASection( $k['libelle'])); - $format->appendChild( $dom->createElement('extension'))->appendChild($dom->createCDATASection("$media->extension")); - $format->appendChild( $dom->createElement('largeur'))->appendChild($dom->createCDATASection( $k['largeur'])); - $format->appendChild( $dom->createElement('hauteur'))->appendChild($dom->createCDATASection( $k['hauteur'])); - $format->appendChild( $dom->createElement('lien'))->appendChild($dom->createCDATASection(env('APP_URL') . "/$media->folder$media->uid" . "_" . $k['libelle'] . ".$media->extension")); + $format = $mediaFormat->appendChild($dom->createElement('format')); + $format->appendChild($dom->createElement('id'))->appendChild($dom->createCDATASection($k['id'])); + $format->appendChild($dom->createElement('libelle'))->appendChild($dom->createCDATASection($k['libelle'])); + $format->appendChild($dom->createElement('extension'))->appendChild($dom->createCDATASection("$media->extension")); + $format->appendChild($dom->createElement('largeur'))->appendChild($dom->createCDATASection($k['largeur'])); + $format->appendChild($dom->createElement('hauteur'))->appendChild($dom->createCDATASection($k['hauteur'])); + $format->appendChild($dom->createElement('lien'))->appendChild($dom->createCDATASection(env('APP_URL') . "/$media->folder$media->uid" . "_" . $k['libelle'] . ".$media->extension")); } return $dom->saveXML(); @@ -167,7 +175,7 @@ trait ArcadiaLink { public static function getRefKey($media) { - switch ($media->sujet_id){ + switch ($media->sujet_id) { case 1: return $media->articles()->get(); break; @@ -184,6 +192,7 @@ trait ArcadiaLink { private static function getFormats() { - return Format::withoutGlobalScope(SystemScope::class)->where('system', '=', '1')->get(); + return Format::withoutGlobalScope(SystemScope::class) + ->where('system', true)->get(); } } diff --git a/app/Http/Traits/ElasticTrait.php b/app/Http/Traits/ElasticTrait.php index ae5ccea..f9aecc2 100644 --- a/app/Http/Traits/ElasticTrait.php +++ b/app/Http/Traits/ElasticTrait.php @@ -1,9 +1,11 @@ getElasticSearchClient(); - $index = array( + $instance = new static(); + $client = $instance->getElasticSearchClient(); + $index = array( 'index' => $instance->getIndexName(), ); return $client->indices()->exists($index); } - } diff --git a/app/Http/Traits/MediaTools.php b/app/Http/Traits/MediaTools.php index ec3bf95..07531e9 100644 --- a/app/Http/Traits/MediaTools.php +++ b/app/Http/Traits/MediaTools.php @@ -1,191 +1,209 @@ fixIntegerOverflow(filesize($file_path)); + } - public function get_file_size($file_path) { - return $this->fix_integer_overflow(filesize($file_path)); - } + /** + * Create thumbnail for a Media + * + * @param Media $media + * @return void + */ + public function createThumb(Media $media) + { + /** @var \Illuminate\Support\Collection<\App\Models\Format> $formats */ + $formats = optional($media->sujet)->formats ?? collect(); + $mediaPath = public_path("/{$media->folder}{$media->uid}.{$media->extension}"); + $im = new \Imagick($mediaPath); + $im->setImageBackgroundColor('#ffffff'); + $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); + $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); + $im->stripImage(); + if (in_array($media->extension, array("pdf", "ai", "psd"))) { + $im->setIteratorIndex(0); + } - public function create_thumb($media) { - $formats = $media->sujet->formats; - $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; - $im = new \Imagick($mediaPath); - $im->setImageBackgroundColor('#ffffff'); - $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); - $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); - $im->stripImage(); - if(in_array($media->extension, array("pdf", "ai", "psd")) ){ - $im->setIteratorIndex(0); - } + foreach ($formats as $format) { + $fp = public_path("/{$media->folder}{$media->uid}_{$format->libelle}.{$format->extension}"); - foreach ($formats as $format) { + $targetWidth = $format->largeur; + if ($format->hauteur == 0) { + $targetHeight = floor(($media->hauteur * $format->largeur) / $media->largeur); + } else { + $targetHeight = $format->hauteur; + } - $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); - }else{ - $targetHeight = $format->hauteur; - } + $im->setImageFormat($format->extension); + if ($media->largeur >= $targetWidth || $media->hauteur >= $targetHeight) { + $im->thumbnailImage($targetWidth, $targetHeight, true); + } + $im->writeImage($fp); + } + $im->destroy(); + unset($im); + } - $im->setImageFormat($format->extension); - if($media->largeur >= $targetWidth || $media->hauteur >= $targetHeight){ - $im->thumbnailImage($targetWidth, $targetHeight , true); - } - $im->writeImage($fp); - } - $im->destroy(); - unset($im); - } + public function createSysThumb($media) + { + $mediaPath = public_path() . "/" . $media->folder . $media->uid . "." . $media->extension; + $im = new \Imagick(); + $im->readImage($mediaPath); - public function create_sys_thumb($media) { - $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; - $im = new \Imagick(); - $im->readImage($mediaPath); + if (in_array($media->extension, array("pdf", "ai", "psd"))) { + $extension = "png"; + $im->setIteratorIndex(0); + } else { + $extension = $media->extension; + } - if(in_array($media->extension, array("pdf", "ai", "psd")) ){ - $extension = "png"; - $im->setIteratorIndex(0); - }else{ - $extension = $media->extension; - } - - /* Handle CMJN - DOESN'T WORK - if ($im->getImageColorspace() === \Imagick::COLORSPACE_CMYK){ + /* + Handle CMJN - DOESN'T WORK + if ($im->getImageColorspace() === \Imagick::COLORSPACE_CMYK){ $im->transformImageColorspace(\Imagick::COLORSPACE_RGB); }*/ - // create preview + // * create preview $format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'preview')->first(); - $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(); - foreach ($im as $frame) { - $frame->thumbnailImage($format->largeur, $format->hauteur); - $frame->setImagePage($format->largeur, $format->hauteur, 0, 0); - } - $im = $im->deconstructImages(); - } - $im->writeImages($fp, true); - }else{ - if($media->largeur >= $format->largeur || $media->hauteur >= $format->hauteur || $media->largeur == ""){ - $im->thumbnailImage($format->largeur, $format->hauteur , true); - } - $im->writeImage($fp); - } + $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(); + foreach ($im as $frame) { + $frame->thumbnailImage($format->largeur, $format->hauteur); + $frame->setImagePage($format->largeur, $format->hauteur, 0, 0); + } + $im = $im->deconstructImages(); + } + $im->writeImages($fp, true); + } else { + if ($media->largeur >= $format->largeur || $media->hauteur >= $format->hauteur || $media->largeur == "") { + $im->thumbnailImage($format->largeur, $format->hauteur, true); + } + $im->writeImage($fp); + } - // create thumb + // * create thumb $format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'thumb')->first(); - if ($extension != "png"){ + 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; - $im->thumbnailImage($format->largeur, $format->hauteur , true); - $im->writeImage($fp); - $im->destroy(); + $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 get_mediaFolder() { - $mediaPath = "medias/"; - $directories = Storage::allDirectories($mediaPath ); - $selectedFolder = ""; + public function getMediaFolder() + { + $mediaPath = "medias/"; + $directories = Storage::allDirectories($mediaPath); + $selectedFolder = ""; - // on obtient le dernier dossier créé - foreach ($directories as $key => $foldername) { - if($selectedFolder < $foldername){ - $selectedFolder = $foldername; - } - } - // si on n'a pas de dossier, on le créé - if($selectedFolder == ""){ - $selectedFolder = $mediaPath.uniqid(); - Storage::makeDirectory($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); - } - } - return $selectedFolder; - } + // * on obtient le dernier dossier créé + foreach ($directories as $key => $foldername) { + if ($selectedFolder < $foldername) { + $selectedFolder = $foldername; + } + } + // * si on n'a pas de dossier, on le créé + if ($selectedFolder == "") { + $selectedFolder = $mediaPath . uniqid(); + Storage::makeDirectory($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); + } + } + return $selectedFolder; + } - public function fix_integer_overflow($size) { - if ($size < 0) { - $size += 2.0 * (PHP_INT_MAX + 1); - } - return $size; - } + public function fixIntegerOverflow($size) + { + if ($size < 0) { + $size += 2.0 * (PHP_INT_MAX + 1); + } + return $size; + } - public function formatBytes($octet, $precision = 2) { - // Array contenant les differents unités - $unite = array('octet','Ko','Mo','Go'); + public function formatBytes($octet, $precision = 2) + { + // * Array contenant les differents unités + $unite = array('octet', 'Ko', 'Mo', 'Go'); - if ($octet < 1000) // octet - { - return $octet.$unite[0]; - } - else - { - if ($octet < 1000000) // ko - { - $ko = round($octet/1024,2); - return $ko.$unite[1]; - } - else // Mo ou Go - { - if ($octet < 1000000000) // Mo - { - $mo = round($octet/(1024*1024),2); - return $mo.$unite[2]; - } - else // Go - { - $go = round($octet/(1024*1024*1024),2); - return $go.$unite[3]; - } - } - } - } + // * octet + if ($octet < 1000) { + return $octet . $unite[0]; + } else { + if ($octet < 1000000) { + // * ko + $ko = round($octet / 1024, 2); + return $ko . $unite[1]; + } else { + // * Mo ou Go + if ($octet < 1000000000) { + // * Mo + $mo = round($octet / (1024 * 1024), 2); + return $mo . $unite[2]; + } else { + // * Go + $go = round($octet / (1024 * 1024 * 1024), 2); + return $go . $unite[3]; + } + } + } + } - // ---- Renvoi le chemin attendu d'un média selon le format demandé - public function get_mediaPath($media, $format = "") { - - // format spécifique - if($format->system == 0){ - if(in_array($media->extension, array("gif", "jpeg", "jpg", "png", "pdf", "ai", "psd")) ){ - return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; - }else{ - return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; - } - } - - // format système (thumb et preview) - if($format->system == 1){ - if(in_array($media->extension, array("gif", "jpeg", "jpg", "png")) ){ - //gestion du cas de format qui fixe l'extension - if($format->extension != "") { + /** + * Renvoi le chemin attendu d'un média selon le format demandé + * + * @param \App\Models\Media $media + * @param \App\Models\Format $format + * @return string + * @throws \ErrorException If Format is not handled. + */ + public function getMediaPath(Media $media, Format $format): string + { + // * format spécifique + if ($format->system) { + if (in_array($media->extension, array("gif", "jpeg", "jpg", "png", "pdf", "ai", "psd"))) { + return public_path("/{$media->folder}{$media->uid}_{$format->libelle}.{$format->extension}"); + } + return public_path("/{$media->folder}{$media->uid}.{$media->extension}"); + } + // * format système (thumb et preview) + if ($format->system) { + if (in_array($media->extension, array("gif", "jpeg", "jpg", "png"))) { + // * Gestion du cas de format qui fixe l'extension + if ($format->extension != '') { $file_extension = $format->extension; } else { $file_extension = $media->extension; } - return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$file_extension; - }elseif(in_array($media->extension, array("pdf", "ai", "psd"))){ - return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.png'; - }else{ - return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; - } - } - } + return public_path("/{$media->folder}{$media->uid}_{$format->libelle}.{$file_extension}"); + } elseif (in_array($media->extension, array("pdf", "ai", "psd"))) { + return public_path("/{$media->folder}{$media->uid}_{$format->libelle}.png"); + } + return public_path("/{$media->folder}.{$media->uid}.{$media->extension}"); + } + throw new \ErrorException("Unhandled Format $format->id $format->libelle"); + } } diff --git a/app/Jobs/SendMediasModificationsReport.php b/app/Jobs/SendMediasModificationsReport.php index fba53b6..7fa8861 100644 --- a/app/Jobs/SendMediasModificationsReport.php +++ b/app/Jobs/SendMediasModificationsReport.php @@ -16,7 +16,10 @@ use Illuminate\Foundation\Bus\Dispatchable; class SendMediasModificationsReport implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable; + use InteractsWithQueue; + use Queueable; + use SerializesModels; /** * Create a new job instance. @@ -25,7 +28,6 @@ class SendMediasModificationsReport implements ShouldQueue */ public function __construct() { - // } /** @@ -35,12 +37,12 @@ class SendMediasModificationsReport implements ShouldQueue */ public function handle() { - //Gather Medias to report - //filtered by subject (2,4) - $now = Carbon::now(); + // Gather Medias to report + // filtered by subject (2,4) + $now = Carbon::now(); $yesterday = $now->subDay(1); - $arSujets = []; - $onesujet = Sujet::find(2); + $arSujets = []; + $onesujet = Sujet::find(2); array_push($arSujets, $onesujet->libelle); $onesujet = Sujet::find(4); array_push($arSujets, $onesujet->libelle); @@ -50,13 +52,13 @@ class SendMediasModificationsReport implements ShouldQueue $medias = Media::whereDate('updated_at', '>=', $yesterday) ->whereIn('sujet_id', [2,4]) ->get(); - //send mail + // send mail $toMailSetting = Setting::where('key', 'media_report_to_mail')->first(); - if(empty($toMailSetting->value)) { - //pas d'envoi car pas de mail cible + if (empty($toMailSetting->value)) { + // pas d'envoi car pas de mail cible } else { $email = $toMailSetting->value; - Mail::to($email)->send(new SendMediaReportMail($medias,$yesterday,$sujets)); + Mail::to($email)->send(new SendMediaReportMail($medias, $yesterday, $sujets)); } } } diff --git a/app/Lib/Utils.php b/app/Lib/Utils.php index 10173d6..c1b3a47 100644 --- a/app/Lib/Utils.php +++ b/app/Lib/Utils.php @@ -66,13 +66,13 @@ class Utils */ private static function getAnonymizedStackTrace(\Throwable $e): string { - $projectPath = \realpath(\sprintf('%s/../', \app_path())); - $traceStack = $e->getTrace(); - $traceStr = ''; + $projectPath = \realpath(\sprintf('%s/../', \app_path())); + $traceStack = $e->getTrace(); + $traceStr = ''; $maxStackStage = 0; foreach ($traceStack as $stackStage => $stack) { $maxStackStage = $stackStage; - $traceStr .= \sprintf( + $traceStr .= \sprintf( '#%s %s(%d): ', $stackStage, str_replace($projectPath, '', $stack['file'] ?? ''), @@ -91,7 +91,7 @@ class Utils } $traceStr .= ")\n"; } - } + }//end foreach $maxStackStage++; $traceStr .= "#$maxStackStage {main}"; return $traceStr; diff --git a/app/Mail/contact.php b/app/Mail/Contact.php similarity index 69% rename from app/Mail/contact.php rename to app/Mail/Contact.php index 2a9f5ea..5697798 100644 --- a/app/Mail/contact.php +++ b/app/Mail/Contact.php @@ -5,16 +5,19 @@ namespace App\Mail; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; -class contact extends Mailable +class Contact extends Mailable { - use Queueable, SerializesModels; + use Queueable; + use SerializesModels; + + public $type; - public $type; public $url; + public $message; - public $user; + + public $user; /** * Create a new message instance. @@ -23,10 +26,10 @@ class contact extends Mailable */ public function __construct($type, $url, $message, $user) { - $this->type = $type; - $this->url = $url; - $this->message = $message; - $this->user = $user; + $this->type = $type; + $this->url = $url; + $this->message = $message; + $this->user = $user; } /** @@ -36,7 +39,7 @@ class contact extends Mailable */ public function build() { - return $this->from('dam@ldc.fr', 'DAM') + return $this->from('dam@ldc.fr', 'DAM') ->subject('Message d\'un utilisateur') ->view('mails.contact') ->with(['type' => $this->type, 'url' => $this->url, 'messagetxt' => $this->message, 'user' => $this->user]); diff --git a/app/Mail/SendMediaReportMail.php b/app/Mail/SendMediaReportMail.php index c6011ae..77773a8 100644 --- a/app/Mail/SendMediaReportMail.php +++ b/app/Mail/SendMediaReportMail.php @@ -6,22 +6,22 @@ use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; class SendMediaReportMail extends Mailable { - use Queueable, SerializesModels; + use Queueable; + use SerializesModels; /** * Create a new message instance. * * @return void */ - public function __construct($medias,$yesterday,$sujets) + public function __construct($medias, $yesterday, $sujets) { - $this->medias = $medias; + $this->medias = $medias; $this->yesterday = $yesterday; - $this->sujets = $sujets; + $this->sujets = $sujets; } /** @@ -36,6 +36,6 @@ class SendMediaReportMail extends Mailable $yesterday = $this->yesterday; $sujets = $this->sujets; - return $this->subject("Rapport d'activité DAM - " . $now->formatLocalized('%d %B %Y à %H:%M'))->view('mails.send-media-report', compact('medias','yesterday','sujets')); + return $this->subject("Rapport d'activité DAM - " . $now->formatLocalized('%d %B %Y à %H:%M'))->view('mails.send-media-report', compact('medias', 'yesterday', 'sujets')); } } diff --git a/app/Models/Article.php b/app/Models/Article.php index dbc7afe..b0f04e0 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Model; class Article extends Model { - /** - * The medias that belong to the article. - */ - public function medias() - { - return $this->belongsToMany('App\Models\Media', 'medias_articles', 'article_id', 'media_id'); - } + /** + * The medias that belong to the article. + */ + public function medias() + { + return $this->belongsToMany('App\Models\Media', 'medias_articles', 'article_id', 'media_id'); + } } diff --git a/app/Models/Copyright.php b/app/Models/Copyright.php index c7a6d85..1e8d866 100644 --- a/app/Models/Copyright.php +++ b/app/Models/Copyright.php @@ -6,10 +6,10 @@ use Illuminate\Database\Eloquent\Model; class Copyright extends Model { - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'copyright_id'; + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'copyright_id'; } diff --git a/app/Models/Etiquette.php b/app/Models/Etiquette.php index b4edc9b..d46d3cb 100644 --- a/app/Models/Etiquette.php +++ b/app/Models/Etiquette.php @@ -6,18 +6,18 @@ use Illuminate\Database\Eloquent\Model; class Etiquette extends Model { - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'etiquette_id'; + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'etiquette_id'; - /** - * Get the medias for the etiquette. - */ - public function medias() - { - return $this->hasMany('App\Models\Media'); - } + /** + * Get the medias for the etiquette. + */ + public function medias() + { + return $this->hasMany('App\Models\Media'); + } } diff --git a/app/Models/Format.php b/app/Models/Format.php index ea942af..e5242f2 100644 --- a/app/Models/Format.php +++ b/app/Models/Format.php @@ -2,30 +2,26 @@ namespace App\Models; -use App\Scopes\SystemScope; use Illuminate\Database\Eloquent\Model; class Format extends Model { - - /** - * The "booting" method of the model. + /** + * The attributes that should be cast. * - * @return void + * @var array */ - protected static function boot() + protected $casts = [ + 'largeur' => 'int', + 'hauteur' => 'int', + 'system' => 'bool', + ]; + + /** + * The sujet that belong to the format. + */ + public function sujets() { - parent::boot(); - - //static::addGlobalScope(new SystemScope); + return $this->belongsToMany('App\Models\Sujet', 'sujets_formats', 'format_id', 'sujet_id'); } - - /** - * The sujet that belong to the format. - */ - public function sujets() - { - return $this->belongsToMany('App\Models\Sujet', 'sujets_formats', 'format_id', 'sujet_id'); - } - } diff --git a/app/Models/FormatRestriction.php b/app/Models/FormatRestriction.php index 6d262ae..0fb60cb 100644 --- a/app/Models/FormatRestriction.php +++ b/app/Models/FormatRestriction.php @@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model; class FormatRestriction extends Model { - // } diff --git a/app/Models/Historique.php b/app/Models/Historique.php index 64692f6..d63747e 100644 --- a/app/Models/Historique.php +++ b/app/Models/Historique.php @@ -8,19 +8,19 @@ class Historique extends Model { public $timestamps = false; - /** - * Get the user that owns the historique. - */ - public function user() - { - return $this->belongsTo('App\Models\User', 'user_id'); - } + /** + * Get the user that owns the historique. + */ + public function user() + { + return $this->belongsTo('App\Models\User', 'user_id'); + } - /** - * Get the media that owns the historique. - */ - public function media() - { - return $this->belongsTo('App\Models\Media', 'media_id'); - } + /** + * Get the media that owns the historique. + */ + public function media() + { + return $this->belongsTo('App\Models\Media', 'media_id'); + } } diff --git a/app/Models/Langue.php b/app/Models/Langue.php index 4c89efd..f006609 100644 --- a/app/Models/Langue.php +++ b/app/Models/Langue.php @@ -6,10 +6,10 @@ use Illuminate\Database\Eloquent\Model; class Langue extends Model { - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'langue_id'; + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'langue_id'; } diff --git a/app/Models/Marque.php b/app/Models/Marque.php index 52641ba..92050c7 100644 --- a/app/Models/Marque.php +++ b/app/Models/Marque.php @@ -6,36 +6,34 @@ use Illuminate\Database\Eloquent\Model; class Marque extends Model { - - /** + /** * The primary key associated with the table. * * @var string */ protected $primaryKey = 'codMarq'; - /** - * The users that belong to the marque. - */ - public function users() - { - return $this->belongsToMany('App\Models\User', 'marques_users', 'marque_id', 'user_id'); - } + /** + * The users that belong to the marque. + */ + public function users() + { + return $this->belongsToMany('App\Models\User', 'marques_users', 'marque_id', 'user_id'); + } /** - * The dossier that belong to the marque. - */ - public function dossiers() - { - return $this->belongsToMany('App\Models\Dossier', 'marques_dossier', 'marque_id', 'dossier_id'); - } - - /** - * The medias that belong to the marques. - */ - public function medias() - { - return $this->belongsToMany('App\Models\Media', 'medias_marques', 'marque_id', 'media_id'); - } + * The dossier that belong to the marque. + */ + public function dossiers() + { + return $this->belongsToMany('App\Models\Dossier', 'marques_dossier', 'marque_id', 'dossier_id'); + } + /** + * The medias that belong to the marques. + */ + public function medias() + { + return $this->belongsToMany('App\Models\Media', 'medias_marques', 'marque_id', 'media_id'); + } } diff --git a/app/Models/Media.php b/app/Models/Media.php index 98e1640..bc91fa0 100644 --- a/app/Models/Media.php +++ b/app/Models/Media.php @@ -4,7 +4,6 @@ namespace App\Models; use App\Http\Traits\ElasticTrait; use App\Models\User; -use DateTimeInterface; use Elasticquent\ElasticquentTrait; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; diff --git a/app/Models/Recherche.php b/app/Models/Recherche.php index 98abab5..1260317 100644 --- a/app/Models/Recherche.php +++ b/app/Models/Recherche.php @@ -6,21 +6,19 @@ use Illuminate\Database\Eloquent\Model; class Recherche extends Model { + /** + * Get the sujet that owns the recherche. + */ + public function sujet() + { + return $this->belongsTo('App\Models\Sujet', 'sujet_id'); + } - - /** - * Get the sujet that owns the recherche. - */ - public function sujet() - { - return $this->belongsTo('App\Models\Sujet', 'sujet_id'); - } - - /** - * Get the user that owns the recherche. - */ - public function user() - { - return $this->belongsTo('App\Models\User', 'id'); - } + /** + * Get the user that owns the recherche. + */ + public function user() + { + return $this->belongsTo('App\Models\User', 'id'); + } } diff --git a/app/Models/Setting.php b/app/Models/Setting.php index 2cac625..b84c3cf 100644 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model; class Setting extends Model { - // } diff --git a/app/Models/Site.php b/app/Models/Site.php index 1ac257d..50ba909 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model; class Site extends Model { - } diff --git a/app/Models/Societe.php b/app/Models/Societe.php index ca1cf2d..dac3df5 100644 --- a/app/Models/Societe.php +++ b/app/Models/Societe.php @@ -6,11 +6,11 @@ use Illuminate\Database\Eloquent\Model; class Societe extends Model { - /** - * The medias that belong to the societes. - */ - public function medias() - { - return $this->belongsToMany('App\Models\Media', 'medias_societes', 'societe_id', 'media_id'); - } + /** + * The medias that belong to the societes. + */ + public function medias() + { + return $this->belongsToMany('App\Models\Media', 'medias_societes', 'societe_id', 'media_id'); + } } diff --git a/app/Models/Sujet.php b/app/Models/Sujet.php index efcf15f..2dda394 100644 --- a/app/Models/Sujet.php +++ b/app/Models/Sujet.php @@ -6,67 +6,66 @@ use Illuminate\Database\Eloquent\Model; class Sujet extends Model { + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'codeSujet'; - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'codeSujet'; + /** + * The users that belong to the sujet. + */ + public function users() + { + return $this->belongsToMany('App\Models\User', 'sujets_users', 'sujet_id', 'user_id'); + } - /** - * The users that belong to the sujet. - */ - public function users() - { - return $this->belongsToMany('App\Models\User', 'sujets_users', 'sujet_id', 'user_id'); - } - - /** + /** * Get the dossier for the sujet. */ - public function dossiers() - { - return $this->hasMany('App\Models\Dossier'); - } + public function dossiers() + { + return $this->hasMany('App\Models\Dossier'); + } - /** - * Get the variantes for the sujet. - */ - public function variantes() - { - return $this->hasMany('App\Models\Variante', 'sujet_id', 'codeSujet'); - } + /** + * Get the variantes for the sujet. + */ + public function variantes() + { + return $this->hasMany('App\Models\Variante', 'sujet_id', 'codeSujet'); + } - /** - * Get the typeVue for the sujet. - */ - public function typeVues() - { - return $this->hasMany('App\Models\Typevue', 'sujet_id', 'codeSujet'); - } + /** + * Get the typeVue for the sujet. + */ + public function typeVues() + { + return $this->hasMany('App\Models\Typevue', 'sujet_id', 'codeSujet'); + } - /** + /** * Get the medias for the sujet. */ - public function medias() - { - return $this->hasMany('App\Models\Media'); - } + public function medias() + { + return $this->hasMany('App\Models\Media'); + } - /** - * The formats that belong to the sujet. - */ - public function formats() - { - return $this->belongsToMany('App\Models\Format', 'sujets_formats', 'sujet_id', 'format_id'); - } + /** + * The formats that belong to the sujet. + */ + public function formats() + { + return $this->belongsToMany('App\Models\Format', 'sujets_formats', 'sujet_id', 'format_id'); + } - /** - * Get the recherches for the sujet. - */ - public function recherches() - { - return $this->hasMany('App\Models\Recherche'); - } + /** + * Get the recherches for the sujet. + */ + public function recherches() + { + return $this->hasMany('App\Models\Recherche'); + } } diff --git a/app/Models/Tag.php b/app/Models/Tag.php index ee27885..044c34d 100644 --- a/app/Models/Tag.php +++ b/app/Models/Tag.php @@ -6,14 +6,12 @@ use Illuminate\Database\Eloquent\Model; class Tag extends Model { - - public $timestamps = false; - /** - * The media that belong to the tags. - */ - public function medias() - { - return $this->belongsToMany('App\Models\Media', 'medias_tags', 'tag_id', 'media_id'); - } - + public $timestamps = false; + /** + * The media that belong to the tags. + */ + public function medias() + { + return $this->belongsToMany('App\Models\Media', 'medias_tags', 'tag_id', 'media_id'); + } } diff --git a/app/Models/Typemedia.php b/app/Models/Typemedia.php index 84f30c1..fdd6109 100644 --- a/app/Models/Typemedia.php +++ b/app/Models/Typemedia.php @@ -6,20 +6,20 @@ use Illuminate\Database\Eloquent\Model; class Typemedia extends Model { - protected $table = "typemedias"; + protected $table = "typemedias"; - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'codeTypemedia'; + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'codeTypemedia'; - /** - * Get the media for the Typemedia. - */ - public function medias() - { - return $this->hasMany('App\Models\Media'); - } + /** + * Get the media for the Typemedia. + */ + public function medias() + { + return $this->hasMany('App\Models\Media'); + } } diff --git a/app/Models/Typevue.php b/app/Models/Typevue.php index 5075169..6a89bf0 100644 --- a/app/Models/Typevue.php +++ b/app/Models/Typevue.php @@ -6,22 +6,22 @@ use Illuminate\Database\Eloquent\Model; class Typevue extends Model { - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'codeTypevue'; + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'codeTypevue'; - /** - * Get the variantes for the Typevue. - */ - public function variantes() - { - return $this->hasMany('App\Models\Variante'); - } + /** + * Get the variantes for the Typevue. + */ + public function variantes() + { + return $this->hasMany('App\Models\Variante'); + } - /** + /** * Get the sujet that owns the Typevue. */ public function sujet() @@ -29,11 +29,11 @@ class Typevue extends Model return $this->belongsTo('App\Models\Sujet', 'sujet_id'); } - /** - * Get the medias for the Typevue. - */ - public function medias() - { - return $this->hasMany('App\Models\Media'); - } + /** + * Get the medias for the Typevue. + */ + public function medias() + { + return $this->hasMany('App\Models\Media'); + } } diff --git a/app/Models/Variante.php b/app/Models/Variante.php index 47688c1..80b2a91 100644 --- a/app/Models/Variante.php +++ b/app/Models/Variante.php @@ -6,15 +6,14 @@ use Illuminate\Database\Eloquent\Model; class Variante extends Model { + /** + * The primary key associated with the table. + * + * @var string + */ + protected $primaryKey = 'codeVariante'; - /** - * The primary key associated with the table. - * - * @var string - */ - protected $primaryKey = 'codeVariante'; - - /** + /** * Get the sujet that owns the variante. */ public function sujet() @@ -22,11 +21,11 @@ class Variante extends Model return $this->belongsTo('App\Models\Sujet', 'sujet_id'); } - /** - * Get the typeVue that owns the variante. - */ - public function typeVue() - { - return $this->belongsTo('App\Models\Typevue', 'typevue_id'); - } + /** + * Get the typeVue that owns the variante. + */ + public function typeVue() + { + return $this->belongsTo('App\Models\Typevue', 'typevue_id'); + } } diff --git a/app/Scopes/OpenLdapScope.php b/app/Scopes/OpenLdapScope.php index 964354f..1020c40 100644 --- a/app/Scopes/OpenLdapScope.php +++ b/app/Scopes/OpenLdapScope.php @@ -1,4 +1,5 @@ where('system', 0); + $builder->where('system', false); } -} \ No newline at end of file +} diff --git a/config/app.php b/config/app.php index 9cab945..e9a255b 100644 --- a/config/app.php +++ b/config/app.php @@ -3,53 +3,53 @@ return [ /* - |-------------------------------------------------------------------------- - | Application Name - |-------------------------------------------------------------------------- - | - | This value is the name of your application. This value is used when the - | framework needs to place the application's name in a notification or - | any other location as required by the application or its packages. - | + |-------------------------------------------------------------------------- + | Application Name + |-------------------------------------------------------------------------- + | + | This value is the name of your application. This value is used when the + | framework needs to place the application's name in a notification or + | any other location as required by the application or its packages. + | */ 'name' => env('APP_NAME', 'Laravel'), /* - |-------------------------------------------------------------------------- - | Application Environment - |-------------------------------------------------------------------------- - | - | This value determines the "environment" your application is currently - | running in. This may determine how you prefer to configure various - | services the application utilizes. Set this in your ".env" file. - | + |-------------------------------------------------------------------------- + | Application Environment + |-------------------------------------------------------------------------- + | + | This value determines the "environment" your application is currently + | running in. This may determine how you prefer to configure various + | services the application utilizes. Set this in your ".env" file. + | */ 'env' => env('APP_ENV', 'production'), /* - |-------------------------------------------------------------------------- - | Application Debug Mode - |-------------------------------------------------------------------------- - | - | When your application is in debug mode, detailed error messages with - | stack traces will be shown on every error that occurs within your - | application. If disabled, a simple generic error page is shown. - | + |-------------------------------------------------------------------------- + | Application Debug Mode + |-------------------------------------------------------------------------- + | + | When your application is in debug mode, detailed error messages with + | stack traces will be shown on every error that occurs within your + | application. If disabled, a simple generic error page is shown. + | */ - 'debug' => (bool) env('APP_DEBUG', false), + 'debug' => (bool)env('APP_DEBUG', false), /* - |-------------------------------------------------------------------------- - | Application URL - |-------------------------------------------------------------------------- - | - | This URL is used by the console to properly generate URLs when using - | the Artisan command line tool. You should set this to the root of - | your application so that it is used when running Artisan tasks. - | + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | */ 'url' => env('APP_URL', 'http://localhost'), @@ -57,66 +57,66 @@ return [ 'asset_url' => env('ASSET_URL', null), /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | Here you may specify the default timezone for your application, which - | will be used by the PHP date and date-time functions. We have gone - | ahead and set this to a sensible default for you out of the box. - | + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | */ 'timezone' => 'Europe/Paris', /* - |-------------------------------------------------------------------------- - | Application Locale Configuration - |-------------------------------------------------------------------------- - | - | The application locale determines the default locale that will be used - | by the translation service provider. You are free to set this value - | to any of the locales which will be supported by the application. - | + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | */ 'locale' => 'fr', /* - |-------------------------------------------------------------------------- - | Application Fallback Locale - |-------------------------------------------------------------------------- - | - | The fallback locale determines the locale to use when the current one - | is not available. You may change the value to correspond to any of - | the language folders that are provided through your application. - | + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | */ 'fallback_locale' => 'en', /* - |-------------------------------------------------------------------------- - | Faker Locale - |-------------------------------------------------------------------------- - | - | This locale will be used by the Faker PHP library when generating fake - | data for your database seeds. For example, this will be used to get - | localized telephone numbers, street address information and more. - | + |-------------------------------------------------------------------------- + | Faker Locale + |-------------------------------------------------------------------------- + | + | This locale will be used by the Faker PHP library when generating fake + | data for your database seeds. For example, this will be used to get + | localized telephone numbers, street address information and more. + | */ 'faker_locale' => 'en_US', /* - |-------------------------------------------------------------------------- - | Encryption Key - |-------------------------------------------------------------------------- - | - | This key is used by the Illuminate encrypter service and should be set - | to a random, 32 character string, otherwise these encrypted strings - | will not be safe. Please do this before deploying an application! - | + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | */ 'key' => env('APP_KEY'), @@ -124,14 +124,14 @@ return [ 'cipher' => 'AES-256-CBC', /* - |-------------------------------------------------------------------------- - | Autoloaded Service Providers - |-------------------------------------------------------------------------- - | - | The service providers listed here will be automatically loaded on the - | request to your application. Feel free to add your own services to - | this array to grant expanded functionality to your applications. - | + |-------------------------------------------------------------------------- + | Autoloaded Service Providers + |-------------------------------------------------------------------------- + | + | The service providers listed here will be automatically loaded on the + | request to your application. Feel free to add your own services to + | this array to grant expanded functionality to your applications. + | */ 'providers' => [ @@ -161,12 +161,12 @@ return [ Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, - Collective\Html\HtmlServiceProvider::class, + Collective\Html\HtmlServiceProvider::class, /* * Package Service Providers... */ - Elasticquent\ElasticquentServiceProvider::class, + Elasticquent\ElasticquentServiceProvider::class, /* * Application Service Providers... */ @@ -179,14 +179,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | This array of class aliases will be registered when this application - | is started. However, feel free to register as many as you wish as - | the aliases are "lazy" loaded so they don't hinder performance. - | + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | */ 'aliases' => [ @@ -230,10 +230,10 @@ return [ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, - 'Adldap' => Adldap\Laravel\Facades\Adldap::class, - 'Form' => Collective\Html\FormFacade::class, - 'Html' => Collective\Html\HtmlFacade::class, - 'Es' => Elasticquent\ElasticquentElasticsearchFacade::class, + 'Adldap' => Adldap\Laravel\Facades\Adldap::class, + 'Form' => Collective\Html\FormFacade::class, + 'Html' => Collective\Html\HtmlFacade::class, + 'Es' => Elasticquent\ElasticquentElasticsearchFacade::class, ], ]; diff --git a/config/auth.php b/config/auth.php index c3167d7..46e417f 100644 --- a/config/auth.php +++ b/config/auth.php @@ -3,14 +3,14 @@ return [ /* - |-------------------------------------------------------------------------- - | Authentication Defaults - |-------------------------------------------------------------------------- - | - | This option controls the default authentication "guard" and password - | reset options for your application. You may change these defaults - | as required, but they're a perfect start for most applications. - | + |-------------------------------------------------------------------------- + | Authentication Defaults + |-------------------------------------------------------------------------- + | + | This option controls the default authentication "guard" and password + | reset options for your application. You may change these defaults + | as required, but they're a perfect start for most applications. + | */ 'defaults' => [ @@ -19,20 +19,20 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Authentication Guards - |-------------------------------------------------------------------------- - | - | Next, you may define every authentication guard for your application. - | Of course, a great default configuration has been defined for you - | here which uses session storage and the Eloquent user provider. - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | Supported: "session", "token" - | + |-------------------------------------------------------------------------- + | Authentication Guards + |-------------------------------------------------------------------------- + | + | Next, you may define every authentication guard for your application. + | Of course, a great default configuration has been defined for you + | here which uses session storage and the Eloquent user provider. + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | Supported: "session", "token" + | */ 'guards' => [ @@ -43,20 +43,20 @@ return [ ], /* - |-------------------------------------------------------------------------- - | User Providers - |-------------------------------------------------------------------------- - | - | All authentication drivers have a user provider. This defines how the - | users are actually retrieved out of your database or other storage - | mechanisms used by this application to persist your user's data. - | - | If you have multiple user tables or models you may configure multiple - | sources which represent each model / table. These sources may then - | be assigned to any extra authentication guards you have defined. - | - | Supported: "session" - | + |-------------------------------------------------------------------------- + | User Providers + |-------------------------------------------------------------------------- + | + | All authentication drivers have a user provider. This defines how the + | users are actually retrieved out of your database or other storage + | mechanisms used by this application to persist your user's data. + | + | If you have multiple user tables or models you may configure multiple + | sources which represent each model / table. These sources may then + | be assigned to any extra authentication guards you have defined. + | + | Supported: "session" + | */ 'providers' => [ @@ -66,24 +66,24 @@ return [ ], // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', + // 'driver' => 'database', + // 'table' => 'users', // ], ], /* - |-------------------------------------------------------------------------- - | Resetting Passwords - |-------------------------------------------------------------------------- - | - | You may specify multiple password reset configurations if you have more - | than one user table or model in the application and you want to have - | separate password reset settings based on the specific user types. - | - | The expire time is the number of minutes that each reset token will be - | considered valid. This security feature keeps tokens short-lived so - | they have less time to be guessed. You may change this as needed. - | + |-------------------------------------------------------------------------- + | Resetting Passwords + |-------------------------------------------------------------------------- + | + | You may specify multiple password reset configurations if you have more + | than one user table or model in the application and you want to have + | separate password reset settings based on the specific user types. + | + | The expire time is the number of minutes that each reset token will be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | */ 'passwords' => [ @@ -96,14 +96,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Password Confirmation Timeout - |-------------------------------------------------------------------------- - | - | Here you may define the amount of seconds before a password confirmation - | times out and the user is prompted to re-enter their password via the - | confirmation screen. By default, the timeout lasts for three hours. - | + |-------------------------------------------------------------------------- + | Password Confirmation Timeout + |-------------------------------------------------------------------------- + | + | Here you may define the amount of seconds before a password confirmation + | times out and the user is prompted to re-enter their password via the + | confirmation screen. By default, the timeout lasts for three hours. + | */ 'password_timeout' => 10800, diff --git a/config/broadcasting.php b/config/broadcasting.php index 7398f94..a26e31d 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -3,29 +3,29 @@ return [ /* - |-------------------------------------------------------------------------- - | Default Broadcaster - |-------------------------------------------------------------------------- - | - | This option controls the default broadcaster that will be used by the - | framework when an event needs to be broadcast. You may set this to - | any of the connections defined in the "connections" array below. - | - | Supported: "pusher", "ably", "redis", "log", "null" - | + |-------------------------------------------------------------------------- + | Default Broadcaster + |-------------------------------------------------------------------------- + | + | This option controls the default broadcaster that will be used by the + | framework when an event needs to be broadcast. You may set this to + | any of the connections defined in the "connections" array below. + | + | Supported: "pusher", "ably", "redis", "log", "null" + | */ 'default' => env('BROADCAST_DRIVER', 'null'), /* - |-------------------------------------------------------------------------- - | Broadcast Connections - |-------------------------------------------------------------------------- - | - | Here you may define all of the broadcast connections that will be used - | to broadcast events to other systems or over websockets. Samples of - | each available type of connection are provided inside this array. - | + |-------------------------------------------------------------------------- + | Broadcast Connections + |-------------------------------------------------------------------------- + | + | Here you may define all of the broadcast connections that will be used + | to broadcast events to other systems or over websockets. Samples of + | each available type of connection are provided inside this array. + | */ 'connections' => [ diff --git a/config/cache.php b/config/cache.php index b3169ad..d2977ad 100644 --- a/config/cache.php +++ b/config/cache.php @@ -5,30 +5,30 @@ use Illuminate\Support\Str; return [ /* - |-------------------------------------------------------------------------- - | Default Cache Store - |-------------------------------------------------------------------------- - | - | This option controls the default cache connection that gets used while - | using this caching library. This connection is used when another is - | not explicitly specified when executing a given caching function. - | + |-------------------------------------------------------------------------- + | Default Cache Store + |-------------------------------------------------------------------------- + | + | This option controls the default cache connection that gets used while + | using this caching library. This connection is used when another is + | not explicitly specified when executing a given caching function. + | */ 'default' => env('CACHE_DRIVER', 'file'), /* - |-------------------------------------------------------------------------- - | Cache Stores - |-------------------------------------------------------------------------- - | - | Here you may define all of the cache "stores" for your application as - | well as their drivers. You may even define multiple stores for the - | same cache driver to group types of items stored in your caches. - | - | Supported drivers: "apc", "array", "database", "file", - | "memcached", "redis", "dynamodb", "octane", "null" - | + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + | Supported drivers: "apc", "array", "database", "file", + | "memcached", "redis", "dynamodb", "octane", "null" + | */ 'stores' => [ @@ -93,16 +93,16 @@ 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. - | + |-------------------------------------------------------------------------- + | 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. + | */ - 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'), ]; diff --git a/config/cors.php b/config/cors.php index 8a39e6d..32a0f68 100644 --- a/config/cors.php +++ b/config/cors.php @@ -3,16 +3,16 @@ return [ /* - |-------------------------------------------------------------------------- - | Cross-Origin Resource Sharing (CORS) Configuration - |-------------------------------------------------------------------------- - | - | Here you may configure your settings for cross-origin resource sharing - | or "CORS". This determines what cross-origin operations may execute - | in web browsers. You are free to adjust these settings as needed. - | - | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS - | + |-------------------------------------------------------------------------- + | Cross-Origin Resource Sharing (CORS) Configuration + |-------------------------------------------------------------------------- + | + | Here you may configure your settings for cross-origin resource sharing + | or "CORS". This determines what cross-origin operations may execute + | in web browsers. You are free to adjust these settings as needed. + | + | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + | */ 'paths' => ['api/*', 'sanctum/csrf-cookie'], diff --git a/config/database.php b/config/database.php index 3cac8ba..4190c62 100644 --- a/config/database.php +++ b/config/database.php @@ -3,32 +3,32 @@ return [ /* - |-------------------------------------------------------------------------- - | Default Database Connection Name - |-------------------------------------------------------------------------- - | - | Here you may specify which of the database connections below you wish - | to use as your default connection for all database work. Of course - | you may use many connections at once using the Database library. - | + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | */ 'default' => env('DB_CONNECTION', 'mysql'), /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | Here are each of the database connections setup for your application. - | Of course, examples of configuring each database platform that is - | supported by Laravel is shown below to make development simple. - | - | - | All database work in Laravel is done through the PHP PDO facilities - | so make sure you have the driver for your particular database of - | choice installed on your machine before you begin development. - | + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | */ 'connections' => [ @@ -88,27 +88,27 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Migration Repository Table - |-------------------------------------------------------------------------- - | - | This table keeps track of all the migrations that have already run for - | your application. Using this information, we can determine which of - | the migrations on disk haven't actually been run in the database. - | + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | */ 'migrations' => 'migrations', /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store that also - | provides a richer body of commands than a typical key-value system - | such as APC or Memcached. Laravel makes it easy to dig right in. - | + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer body of commands than a typical key-value system + | such as APC or Memcached. Laravel makes it easy to dig right in. + | */ 'redis' => [ diff --git a/config/elasticquent.php b/config/elasticquent.php index 009d50a..bcd2649 100644 --- a/config/elasticquent.php +++ b/config/elasticquent.php @@ -3,14 +3,14 @@ return array( /* - |-------------------------------------------------------------------------- - | Custom Elasticsearch Client Configuration - |-------------------------------------------------------------------------- - | - | This array will be passed to the Elasticsearch client. - | See configuration options here: - | - | http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html + |-------------------------------------------------------------------------- + | Custom Elasticsearch Client Configuration + |-------------------------------------------------------------------------- + | + | This array will be passed to the Elasticsearch client. + | See configuration options here: + | + | http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html */ 'config' => [ @@ -19,12 +19,12 @@ return array( ], /* - |-------------------------------------------------------------------------- - | Default Index Name - |-------------------------------------------------------------------------- - | - | This is the index name that Elasticquent will use for all - | Elasticquent models. + |-------------------------------------------------------------------------- + | Default Index Name + |-------------------------------------------------------------------------- + | + | This is the index name that Elasticquent will use for all + | Elasticquent models. */ 'default_index' => 'dam_index', diff --git a/config/filesystems.php b/config/filesystems.php index c9518df..2c9629b 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -3,29 +3,29 @@ return [ /* - |-------------------------------------------------------------------------- - | Default Filesystem Disk - |-------------------------------------------------------------------------- - | - | Here you may specify the default filesystem disk that should be used - | by the framework. The "local" disk, as well as a variety of cloud - | based disks are available to your application. Just store away! - | + |-------------------------------------------------------------------------- + | Default Filesystem Disk + |-------------------------------------------------------------------------- + | + | Here you may specify the default filesystem disk that should be used + | by the framework. The "local" disk, as well as a variety of cloud + | based disks are available to your application. Just store away! + | */ 'default' => env('FILESYSTEM_DRIVER', 'local'), /* - |-------------------------------------------------------------------------- - | Filesystem Disks - |-------------------------------------------------------------------------- - | - | 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. - | - | Supported Drivers: "local", "ftp", "sftp", "s3" - | + |-------------------------------------------------------------------------- + | Filesystem Disks + |-------------------------------------------------------------------------- + | + | 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. + | + | Supported Drivers: "local", "ftp", "sftp", "s3" + | */ 'disks' => [ @@ -38,14 +38,14 @@ return [ 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'url' => env('APP_URL') . '/storage', 'visibility' => 'public', ], - 'arcadia' => [ - 'driver' => 'local', - 'root' => storage_path('export_arcadia'), - ], + 'arcadia' => [ + 'driver' => 'local', + 'root' => storage_path('export_arcadia'), + ], 'arcadia_link_s' => [ 'driver' => 'local', @@ -69,14 +69,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Symbolic Links - |-------------------------------------------------------------------------- - | - | Here you may configure the symbolic links that will be created when the - | `storage:link` Artisan command is executed. The array keys should be - | the locations of the links and the values should be their targets. - | + |-------------------------------------------------------------------------- + | Symbolic Links + |-------------------------------------------------------------------------- + | + | Here you may configure the symbolic links that will be created when the + | `storage:link` Artisan command is executed. The array keys should be + | the locations of the links and the values should be their targets. + | */ 'links' => [ diff --git a/config/hashing.php b/config/hashing.php index bcd3be4..db3d9dd 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -3,29 +3,29 @@ return [ /* - |-------------------------------------------------------------------------- - | Default Hash Driver - |-------------------------------------------------------------------------- - | - | This option controls the default hash driver that will be used to hash - | passwords for your application. By default, the bcrypt algorithm is - | used; however, you remain free to modify this option if you wish. - | - | Supported: "bcrypt", "argon", "argon2id" - | + |-------------------------------------------------------------------------- + | Default Hash Driver + |-------------------------------------------------------------------------- + | + | This option controls the default hash driver that will be used to hash + | passwords for your application. By default, the bcrypt algorithm is + | used; however, you remain free to modify this option if you wish. + | + | Supported: "bcrypt", "argon", "argon2id" + | */ 'driver' => 'bcrypt', /* - |-------------------------------------------------------------------------- - | Bcrypt Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Bcrypt algorithm. This will allow you - | to control the amount of time it takes to hash the given password. - | + |-------------------------------------------------------------------------- + | Bcrypt Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Bcrypt algorithm. This will allow you + | to control the amount of time it takes to hash the given password. + | */ 'bcrypt' => [ @@ -33,14 +33,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Argon Options - |-------------------------------------------------------------------------- - | - | Here you may specify the configuration options that should be used when - | passwords are hashed using the Argon algorithm. These will allow you - | to control the amount of time it takes to hash the given password. - | + |-------------------------------------------------------------------------- + | Argon Options + |-------------------------------------------------------------------------- + | + | Here you may specify the configuration options that should be used when + | passwords are hashed using the Argon algorithm. These will allow you + | to control the amount of time it takes to hash the given password. + | */ 'argon' => [ diff --git a/config/ldap.php b/config/ldap.php index 413513a..9e30bc2 100644 --- a/config/ldap.php +++ b/config/ldap.php @@ -3,32 +3,32 @@ return [ /* - |-------------------------------------------------------------------------- - | Logging - |-------------------------------------------------------------------------- - | - | This option enables logging all LDAP operations on all configured - | connections such as bind requests and CRUD operations. - | - | Log entries will be created in your default logging stack. - | - | This option is extremely helpful for debugging connectivity issues. - | + |-------------------------------------------------------------------------- + | Logging + |-------------------------------------------------------------------------- + | + | This option enables logging all LDAP operations on all configured + | connections such as bind requests and CRUD operations. + | + | Log entries will be created in your default logging stack. + | + | This option is extremely helpful for debugging connectivity issues. + | */ 'logging' => env('LDAP_LOGGING', true), /* - |-------------------------------------------------------------------------- - | Connections - |-------------------------------------------------------------------------- - | - | This array stores the connections that are added to Adldap. You can add - | as many connections as you like. - | - | The key is the name of the connection you wish to use and the value is - | an array of configuration settings. - | + |-------------------------------------------------------------------------- + | Connections + |-------------------------------------------------------------------------- + | + | This array stores the connections that are added to Adldap. You can add + | as many connections as you like. + | + | The key is the name of the connection you wish to use and the value is + | an array of configuration settings. + | */ 'connections' => [ @@ -36,199 +36,199 @@ return [ 'default' => [ /* - |-------------------------------------------------------------------------- - | Auto Connect - |-------------------------------------------------------------------------- - | - | If auto connect is true, Adldap will try to automatically connect to - | your LDAP server in your configuration. This allows you to assume - | connectivity rather than having to connect manually - | in your application. - | - | If this is set to false, you **must** connect manually before running - | LDAP operations. Otherwise, you will receive exceptions. - | + |-------------------------------------------------------------------------- + | Auto Connect + |-------------------------------------------------------------------------- + | + | If auto connect is true, Adldap will try to automatically connect to + | your LDAP server in your configuration. This allows you to assume + | connectivity rather than having to connect manually + | in your application. + | + | If this is set to false, you **must** connect manually before running + | LDAP operations. Otherwise, you will receive exceptions. + | */ 'auto_connect' => env('LDAP_AUTO_CONNECT', true), /* - |-------------------------------------------------------------------------- - | Connection - |-------------------------------------------------------------------------- - | - | The connection class to use to run raw LDAP operations on. - | - | Custom connection classes must implement: - | - | Adldap\Connections\ConnectionInterface - | + |-------------------------------------------------------------------------- + | Connection + |-------------------------------------------------------------------------- + | + | The connection class to use to run raw LDAP operations on. + | + | Custom connection classes must implement: + | + | Adldap\Connections\ConnectionInterface + | */ 'connection' => Adldap\Connections\Ldap::class, /* - |-------------------------------------------------------------------------- - | Connection Settings - |-------------------------------------------------------------------------- - | - | This connection settings array is directly passed into the Adldap constructor. - | - | Feel free to add or remove settings you don't need. - | + |-------------------------------------------------------------------------- + | Connection Settings + |-------------------------------------------------------------------------- + | + | This connection settings array is directly passed into the Adldap constructor. + | + | Feel free to add or remove settings you don't need. + | */ 'settings' => [ /* - |-------------------------------------------------------------------------- - | Schema - |-------------------------------------------------------------------------- - | - | The schema class to use for retrieving attributes and generating models. - | - | You can also set this option to `null` to use the default schema class. - | - | For OpenLDAP, you must use the schema: - | - | Adldap\Schemas\OpenLDAP::class - | - | For FreeIPA, you must use the schema: - | - | Adldap\Schemas\FreeIPA::class - | - | Custom schema classes must implement Adldap\Schemas\SchemaInterface - | + |-------------------------------------------------------------------------- + | Schema + |-------------------------------------------------------------------------- + | + | The schema class to use for retrieving attributes and generating models. + | + | You can also set this option to `null` to use the default schema class. + | + | For OpenLDAP, you must use the schema: + | + | Adldap\Schemas\OpenLDAP::class + | + | For FreeIPA, you must use the schema: + | + | Adldap\Schemas\FreeIPA::class + | + | Custom schema classes must implement Adldap\Schemas\SchemaInterface + | */ 'schema' => Adldap\Schemas\OpenLDAP::class, /* - |-------------------------------------------------------------------------- - | Account Prefix - |-------------------------------------------------------------------------- - | - | The account prefix option is the prefix of your user accounts in LDAP directory. - | - | This string is prepended to all authenticating users usernames. - | + |-------------------------------------------------------------------------- + | Account Prefix + |-------------------------------------------------------------------------- + | + | The account prefix option is the prefix of your user accounts in LDAP directory. + | + | This string is prepended to all authenticating users usernames. + | */ 'account_prefix' => env('LDAP_ACCOUNT_PREFIX'), /* - |-------------------------------------------------------------------------- - | Account Suffix - |-------------------------------------------------------------------------- - | - | The account suffix option is the suffix of your user accounts in your LDAP directory. - | - | This string is appended to all authenticating users usernames. - | + |-------------------------------------------------------------------------- + | Account Suffix + |-------------------------------------------------------------------------- + | + | The account suffix option is the suffix of your user accounts in your LDAP directory. + | + | This string is appended to all authenticating users usernames. + | */ 'account_suffix' => env('LDAP_ACCOUNT_SUFFIX'), /* - |-------------------------------------------------------------------------- - | Domain Controllers - |-------------------------------------------------------------------------- - | - | The domain controllers option is an array of servers located on your - | network that serve Active Directory. You can insert as many servers or - | as little as you'd like depending on your forest (with the - | minimum of one of course). - | - | These can be IP addresses of your server(s), or the host name. - | + |-------------------------------------------------------------------------- + | Domain Controllers + |-------------------------------------------------------------------------- + | + | The domain controllers option is an array of servers located on your + | network that serve Active Directory. You can insert as many servers or + | as little as you'd like depending on your forest (with the + | minimum of one of course). + | + | These can be IP addresses of your server(s), or the host name. + | */ 'hosts' => explode(' ', env('LDAP_HOSTS')), /* - |-------------------------------------------------------------------------- - | Port - |-------------------------------------------------------------------------- - | - | The port option is used for authenticating and binding to your LDAP server. - | + |-------------------------------------------------------------------------- + | Port + |-------------------------------------------------------------------------- + | + | The port option is used for authenticating and binding to your LDAP server. + | */ 'port' => env('LDAP_PORT', 636), /* - |-------------------------------------------------------------------------- - | Timeout - |-------------------------------------------------------------------------- - | - | The timeout option allows you to configure the amount of time in - | seconds that your application waits until a response - | is received from your LDAP server. - | + |-------------------------------------------------------------------------- + | Timeout + |-------------------------------------------------------------------------- + | + | The timeout option allows you to configure the amount of time in + | seconds that your application waits until a response + | is received from your LDAP server. + | */ 'timeout' => env('LDAP_TIMEOUT', 5), /* - |-------------------------------------------------------------------------- - | Base Distinguished Name - |-------------------------------------------------------------------------- - | - | The base distinguished name is the base distinguished name you'd - | like to perform query operations on. An example base DN would be: - | - | dc=corp,dc=acme,dc=org - | - | A correct base DN is required for any query results to be returned. - | + |-------------------------------------------------------------------------- + | Base Distinguished Name + |-------------------------------------------------------------------------- + | + | The base distinguished name is the base distinguished name you'd + | like to perform query operations on. An example base DN would be: + | + | dc=corp,dc=acme,dc=org + | + | A correct base DN is required for any query results to be returned. + | */ 'base_dn' => env('LDAP_BASE_DN'), /* - |-------------------------------------------------------------------------- - | LDAP Username & Password - |-------------------------------------------------------------------------- - | - | When connecting to your LDAP server, a username and password is required - | to be able to query and run operations on your server(s). You can - | use any user account that has these permissions. This account - | does not need to be a domain administrator unless you - | require changing and resetting user passwords. - | + |-------------------------------------------------------------------------- + | LDAP Username & Password + |-------------------------------------------------------------------------- + | + | When connecting to your LDAP server, a username and password is required + | to be able to query and run operations on your server(s). You can + | use any user account that has these permissions. This account + | does not need to be a domain administrator unless you + | require changing and resetting user passwords. + | */ 'username' => env('LDAP_USERNAME'), 'password' => env('LDAP_PASSWORD'), /* - |-------------------------------------------------------------------------- - | Follow Referrals - |-------------------------------------------------------------------------- - | - | The follow referrals option is a boolean to tell active directory - | to follow a referral to another server on your network if the - | server queried knows the information your asking for exists, - | but does not yet contain a copy of it locally. - | - | This option is defaulted to false. - | + |-------------------------------------------------------------------------- + | Follow Referrals + |-------------------------------------------------------------------------- + | + | The follow referrals option is a boolean to tell active directory + | to follow a referral to another server on your network if the + | server queried knows the information your asking for exists, + | but does not yet contain a copy of it locally. + | + | This option is defaulted to false. + | */ 'follow_referrals' => false, /* - |-------------------------------------------------------------------------- - | SSL & TLS - |-------------------------------------------------------------------------- - | - | If you need to be able to change user passwords on your server, then an - | SSL or TLS connection is required. All other operations are allowed - | on unsecured protocols. - | - | One of these options are definitely recommended if you - | have the ability to connect to your server securely. - | + |-------------------------------------------------------------------------- + | SSL & TLS + |-------------------------------------------------------------------------- + | + | If you need to be able to change user passwords on your server, then an + | SSL or TLS connection is required. All other operations are allowed + | on unsecured protocols. + | + | One of these options are definitely recommended if you + | have the ability to connect to your server securely. + | */ 'use_ssl' => env('LDAP_USE_SSL', true), diff --git a/config/ldap_auth.php b/config/ldap_auth.php index 29de701..aa5d2da 100644 --- a/config/ldap_auth.php +++ b/config/ldap_auth.php @@ -3,90 +3,88 @@ return [ /* - |-------------------------------------------------------------------------- - | Connection - |-------------------------------------------------------------------------- - | - | The LDAP connection to use for Laravel authentication. - | - | You must specify connections in your `config/ldap.php` configuration file. - | + |-------------------------------------------------------------------------- + | Connection + |-------------------------------------------------------------------------- + | + | The LDAP connection to use for Laravel authentication. + | + | You must specify connections in your `config/ldap.php` configuration file. + | */ 'connection' => env('LDAP_CONNECTION', 'default'), /* - |-------------------------------------------------------------------------- - | Provider - |-------------------------------------------------------------------------- - | - | The LDAP authentication provider to use depending - | if you require database synchronization. - | - | For synchronizing LDAP users to your local applications database, use the provider: - | - | Adldap\Laravel\Auth\DatabaseUserProvider::class - | - | Otherwise, if you just require LDAP authentication, use the provider: - | - | Adldap\Laravel\Auth\NoDatabaseUserProvider::class - | + |-------------------------------------------------------------------------- + | Provider + |-------------------------------------------------------------------------- + | + | The LDAP authentication provider to use depending + | if you require database synchronization. + | + | For synchronizing LDAP users to your local applications database, use the provider: + | + | Adldap\Laravel\Auth\DatabaseUserProvider::class + | + | Otherwise, if you just require LDAP authentication, use the provider: + | + | Adldap\Laravel\Auth\NoDatabaseUserProvider::class + | */ 'provider' => Adldap\Laravel\Auth\DatabaseUserProvider::class, /* - |-------------------------------------------------------------------------- - | Model - |-------------------------------------------------------------------------- - | - | The model to utilize for authentication and importing. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Model + |-------------------------------------------------------------------------- + | + | The model to utilize for authentication and importing. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'model' => App\Models\User::class, /* - |-------------------------------------------------------------------------- - | Rules - |-------------------------------------------------------------------------- - | - | Rules allow you to control user authentication requests depending on scenarios. - | - | You can create your own rules and insert them here. - | - | All rules must extend from the following class: - | - | Adldap\Laravel\Validation\Rules\Rule - | + |-------------------------------------------------------------------------- + | Rules + |-------------------------------------------------------------------------- + | + | Rules allow you to control user authentication requests depending on scenarios. + | + | You can create your own rules and insert them here. + | + | All rules must extend from the following class: + | + | Adldap\Laravel\Validation\Rules\Rule + | */ 'rules' => [ // Denys deleted users from authenticating. - Adldap\Laravel\Validation\Rules\DenyTrashed::class, // Allows only manually imported users to authenticate. - Adldap\Laravel\Validation\Rules\OnlyImported::class, ], /* - |-------------------------------------------------------------------------- - | Scopes - |-------------------------------------------------------------------------- - | - | Scopes allow you to restrict the LDAP query that locates - | users upon import and authentication. - | - | All scopes must implement the following interface: - | - | Adldap\Laravel\Scopes\ScopeInterface - | + |-------------------------------------------------------------------------- + | Scopes + |-------------------------------------------------------------------------- + | + | Scopes allow you to restrict the LDAP query that locates + | users upon import and authentication. + | + | All scopes must implement the following interface: + | + | Adldap\Laravel\Scopes\ScopeInterface + | */ 'scopes' => [ @@ -94,7 +92,6 @@ return [ // Only allows users with a user principal name to authenticate. // Suitable when using ActiveDirectory. // Adldap\Laravel\Scopes\UpnScope::class, - // Only allows users with a uid to authenticate. // Suitable when using OpenLDAP. Adldap\Laravel\Scopes\UidScope::class, @@ -104,31 +101,31 @@ return [ 'identifiers' => [ /* - |-------------------------------------------------------------------------- - | LDAP - |-------------------------------------------------------------------------- - | - | Locate Users By: - | - | This value is the users attribute you would like to locate LDAP - | users by in your directory. - | - | For example, using the default configuration below, if you're - | authenticating users with an email address, your LDAP server - | will be queried for a user with the a `userprincipalname` - | equal to the entered email address. - | - | Bind Users By: - | - | This value is the users attribute you would - | like to use to bind to your LDAP server. - | - | For example, when a user is located by the above attribute, - | the users attribute you specify below will be used as - | the 'username' to bind to your LDAP server. - | - | This is usually their distinguished name. - | + |-------------------------------------------------------------------------- + | LDAP + |-------------------------------------------------------------------------- + | + | Locate Users By: + | + | This value is the users attribute you would like to locate LDAP + | users by in your directory. + | + | For example, using the default configuration below, if you're + | authenticating users with an email address, your LDAP server + | will be queried for a user with the a `userprincipalname` + | equal to the entered email address. + | + | Bind Users By: + | + | This value is the users attribute you would + | like to use to bind to your LDAP server. + | + | For example, when a user is located by the above attribute, + | the users attribute you specify below will be used as + | the 'username' to bind to your LDAP server. + | + | This is usually their distinguished name. + | */ 'ldap' => [ @@ -142,33 +139,33 @@ return [ 'database' => [ /* - |-------------------------------------------------------------------------- - | GUID Column - |-------------------------------------------------------------------------- - | - | The value of this option is the database column that will contain the - | LDAP users global identifier. This column does not need to be added - | to the sync attributes below. It is synchronized automatically. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | GUID Column + |-------------------------------------------------------------------------- + | + | The value of this option is the database column that will contain the + | LDAP users global identifier. This column does not need to be added + | to the sync attributes below. It is synchronized automatically. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'guid_column' => 'objectguid', /* - |-------------------------------------------------------------------------- - | Username Column - |-------------------------------------------------------------------------- - | - | The value of this option is the database column that contains your - | users login username. - | - | This column must be added to your sync attributes below to be - | properly synchronized. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Username Column + |-------------------------------------------------------------------------- + | + | The value of this option is the database column that contains your + | users login username. + | + | This column must be added to your sync attributes below to be + | properly synchronized. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'username_column' => 'matricule', @@ -176,29 +173,29 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Windows Authentication Middleware (SSO) - |-------------------------------------------------------------------------- - | - | Local Users By: - | - | This value is the users attribute you would like to locate LDAP - | users by in your directory. - | - | For example, if 'samaccountname' is the value, then your LDAP server is - | queried for a user with the 'samaccountname' equal to the value of - | $_SERVER['AUTH_USER']. - | - | If a user is found, they are imported (if using the DatabaseUserProvider) - | into your local database, then logged in. - | - | Server Key: - | - | This value represents the 'key' of the $_SERVER - | array to pull the users account name from. - | - | For example, $_SERVER['AUTH_USER']. - | + |-------------------------------------------------------------------------- + | Windows Authentication Middleware (SSO) + |-------------------------------------------------------------------------- + | + | Local Users By: + | + | This value is the users attribute you would like to locate LDAP + | users by in your directory. + | + | For example, if 'samaccountname' is the value, then your LDAP server is + | queried for a user with the 'samaccountname' equal to the value of + | $_SERVER['AUTH_USER']. + | + | If a user is found, they are imported (if using the DatabaseUserProvider) + | into your local database, then logged in. + | + | Server Key: + | + | This value represents the 'key' of the $_SERVER + | array to pull the users account name from. + | + | For example, $_SERVER['AUTH_USER']. + | */ 'windows' => [ @@ -214,39 +211,39 @@ return [ 'passwords' => [ /* - |-------------------------------------------------------------------------- - | Password Sync - |-------------------------------------------------------------------------- - | - | The password sync option allows you to automatically synchronize users - | LDAP passwords to your local database. These passwords are hashed - | natively by Laravel using the Hash::make() method. - | - | Enabling this option would also allow users to login to their accounts - | using the password last used when an LDAP connection was present. - | - | If this option is disabled, the local database account is applied a - | random 16 character hashed password upon first login, and will - | lose access to this account upon loss of LDAP connectivity. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Password Sync + |-------------------------------------------------------------------------- + | + | The password sync option allows you to automatically synchronize users + | LDAP passwords to your local database. These passwords are hashed + | natively by Laravel using the Hash::make() method. + | + | Enabling this option would also allow users to login to their accounts + | using the password last used when an LDAP connection was present. + | + | If this option is disabled, the local database account is applied a + | random 16 character hashed password upon first login, and will + | lose access to this account upon loss of LDAP connectivity. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'sync' => env('LDAP_PASSWORD_SYNC', false), /* - |-------------------------------------------------------------------------- - | Column - |-------------------------------------------------------------------------- - | - | This is the column of your users database table - | that is used to store passwords. - | - | Set this to `null` if you do not have a password column. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Column + |-------------------------------------------------------------------------- + | + | This is the column of your users database table + | that is used to store passwords. + | + | Set this to `null` if you do not have a password column. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'column' => 'password', @@ -254,37 +251,37 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Login Fallback - |-------------------------------------------------------------------------- - | - | The login fallback option allows you to login as a user located in the - | local database if active directory authentication fails. - | - | Set this to true if you would like to enable it. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Login Fallback + |-------------------------------------------------------------------------- + | + | The login fallback option allows you to login as a user located in the + | local database if active directory authentication fails. + | + | Set this to true if you would like to enable it. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'login_fallback' => env('LDAP_LOGIN_FALLBACK', true), /* - |-------------------------------------------------------------------------- - | Sync Attributes - |-------------------------------------------------------------------------- - | - | Attributes specified here will be added / replaced on the user model - | upon login, automatically synchronizing and keeping the attributes - | up to date. - | - | The array key represents the users Laravel model key, and - | the value represents the users LDAP attribute. - | - | You **must** include the users login attribute here. - | - | This option is only applicable to the DatabaseUserProvider. - | + |-------------------------------------------------------------------------- + | Sync Attributes + |-------------------------------------------------------------------------- + | + | Attributes specified here will be added / replaced on the user model + | upon login, automatically synchronizing and keeping the attributes + | up to date. + | + | The array key represents the users Laravel model key, and + | the value represents the users LDAP attribute. + | + | You **must** include the users login attribute here. + | + | This option is only applicable to the DatabaseUserProvider. + | */ 'sync_attributes' => [ @@ -296,23 +293,23 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Logging - |-------------------------------------------------------------------------- - | - | User authentication attempts will be logged using Laravel's - | default logger if this setting is enabled. - | - | No credentials are logged, only usernames. - | - | This is usually stored in the '/storage/logs' directory - | in the root of your application. - | - | This option is useful for debugging as well as auditing. - | - | You can freely remove any events you would not like to log below, - | as well as use your own listeners if you would prefer. - | + |-------------------------------------------------------------------------- + | Logging + |-------------------------------------------------------------------------- + | + | User authentication attempts will be logged using Laravel's + | default logger if this setting is enabled. + | + | No credentials are logged, only usernames. + | + | This is usually stored in the '/storage/logs' directory + | in the root of your application. + | + | This option is useful for debugging as well as auditing. + | + | You can freely remove any events you would not like to log below, + | as well as use your own listeners if you would prefer. + | */ 'logging' => [ diff --git a/config/logging.php b/config/logging.php index 425c6ac..870b230 100644 --- a/config/logging.php +++ b/config/logging.php @@ -7,44 +7,44 @@ use Monolog\Handler\SyslogUdpHandler; return [ /* - |-------------------------------------------------------------------------- - | Default Log Channel - |-------------------------------------------------------------------------- - | - | This option defines the default log channel that gets used when writing - | messages to the logs. The name specified in this option should match - | one of the channels defined in the "channels" configuration array. - | + |-------------------------------------------------------------------------- + | Default Log Channel + |-------------------------------------------------------------------------- + | + | This option defines the default log channel that gets used when writing + | messages to the logs. The name specified in this option should match + | one of the channels defined in the "channels" configuration array. + | */ 'default' => env('LOG_CHANNEL', 'stack'), /* - |-------------------------------------------------------------------------- - | Deprecations Log Channel - |-------------------------------------------------------------------------- - | - | This option controls the log channel that should be used to log warnings - | regarding deprecated PHP and library features. This allows you to get - | your application ready for upcoming major versions of dependencies. - | + |-------------------------------------------------------------------------- + | Deprecations Log Channel + |-------------------------------------------------------------------------- + | + | This option controls the log channel that should be used to log warnings + | regarding deprecated PHP and library features. This allows you to get + | your application ready for upcoming major versions of dependencies. + | */ 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), /* - |-------------------------------------------------------------------------- - | Log Channels - |-------------------------------------------------------------------------- - | - | Here you may configure the log channels for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Drivers: "single", "daily", "slack", "syslog", - | "errorlog", "monolog", - | "custom", "stack" - | + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", + | "custom", "stack" + | */ 'channels' => [ diff --git a/config/queue.php b/config/queue.php index 87a46f3..fe55c44 100644 --- a/config/queue.php +++ b/config/queue.php @@ -3,29 +3,29 @@ return [ /* - |-------------------------------------------------------------------------- - | Default Queue Connection Name - |-------------------------------------------------------------------------- - | - | Laravel's queue API supports an assortment of back-ends via a single - | API, giving you convenient access to each back-end using the same - | syntax for every one. Here you may define a default connection. - | + |-------------------------------------------------------------------------- + | Default Queue Connection Name + |-------------------------------------------------------------------------- + | + | Laravel's queue API supports an assortment of back-ends via a single + | API, giving you convenient access to each back-end using the same + | syntax for every one. Here you may define a default connection. + | */ 'default' => env('QUEUE_CONNECTION', 'sync'), /* - |-------------------------------------------------------------------------- - | Queue Connections - |-------------------------------------------------------------------------- - | - | Here you may configure the connection information for each server that - | is used by your application. A default configuration has been added - | for each back-end shipped with Laravel. You are free to add more. - | - | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" - | + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | */ 'connections' => [ @@ -73,14 +73,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Failed Queue Jobs - |-------------------------------------------------------------------------- - | - | These options configure the behavior of failed queue job logging so you - | can control which database and table are used to store the jobs that - | have failed. You may change them to any database / table you wish. - | + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | */ 'failed' => [ diff --git a/config/sanctum.php b/config/sanctum.php index 693c6de..20676d0 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -3,14 +3,14 @@ return [ /* - |-------------------------------------------------------------------------- - | Stateful Domains - |-------------------------------------------------------------------------- - | - | Requests from the following domains / hosts will receive stateful API - | authentication cookies. Typically, these should include your local - | and production domains which access your API via a frontend SPA. - | + |-------------------------------------------------------------------------- + | Stateful Domains + |-------------------------------------------------------------------------- + | + | Requests from the following domains / hosts will receive stateful API + | authentication cookies. Typically, these should include your local + | and production domains which access your API via a frontend SPA. + | */ 'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( @@ -20,41 +20,41 @@ return [ ))), /* - |-------------------------------------------------------------------------- - | Sanctum Guards - |-------------------------------------------------------------------------- - | - | This array contains the authentication guards that will be checked when - | Sanctum is trying to authenticate a request. If none of these guards - | are able to authenticate the request, Sanctum will use the bearer - | token that's present on an incoming request for authentication. - | + |-------------------------------------------------------------------------- + | Sanctum Guards + |-------------------------------------------------------------------------- + | + | This array contains the authentication guards that will be checked when + | Sanctum is trying to authenticate a request. If none of these guards + | are able to authenticate the request, Sanctum will use the bearer + | token that's present on an incoming request for authentication. + | */ 'guard' => ['web'], /* - |-------------------------------------------------------------------------- - | Expiration Minutes - |-------------------------------------------------------------------------- - | - | This value controls the number of minutes until an issued token will be - | considered expired. If this value is null, personal access tokens do - | not expire. This won't tweak the lifetime of first-party sessions. - | + |-------------------------------------------------------------------------- + | Expiration Minutes + |-------------------------------------------------------------------------- + | + | This value controls the number of minutes until an issued token will be + | considered expired. If this value is null, personal access tokens do + | not expire. This won't tweak the lifetime of first-party sessions. + | */ 'expiration' => null, /* - |-------------------------------------------------------------------------- - | Sanctum Middleware - |-------------------------------------------------------------------------- - | - | When authenticating your first-party SPA with Sanctum you may need to - | customize some of the middleware Sanctum uses while processing the - | request. You may change the middleware listed below as required. - | + |-------------------------------------------------------------------------- + | Sanctum Middleware + |-------------------------------------------------------------------------- + | + | When authenticating your first-party SPA with Sanctum you may need to + | customize some of the middleware Sanctum uses while processing the + | request. You may change the middleware listed below as required. + | */ 'middleware' => [ diff --git a/config/services.php b/config/services.php index 908eb62..c2bd239 100644 --- a/config/services.php +++ b/config/services.php @@ -3,15 +3,15 @@ return [ /* - |-------------------------------------------------------------------------- - | Third Party Services - |-------------------------------------------------------------------------- - | - | This file is for storing the credentials for third party services such - | as Mailgun, Postmark, AWS and more. This file provides the de facto - | default location for this type of information, allowing packages - | to have a conventional place to find your various credentials. - | + |-------------------------------------------------------------------------- + | Third Party Services + |-------------------------------------------------------------------------- + | + | This file is for storing the credentials for third party services such + | as Mailgun, Postmark, AWS and more. This file provides the de facto + | default location for this type of information, allowing packages + | to have a conventional place to find your various credentials. + | */ 'mailgun' => [ diff --git a/config/session.php b/config/session.php index ac0802b..b096861 100644 --- a/config/session.php +++ b/config/session.php @@ -5,30 +5,30 @@ use Illuminate\Support\Str; return [ /* - |-------------------------------------------------------------------------- - | Default Session Driver - |-------------------------------------------------------------------------- - | - | This option controls the default session "driver" that will be used on - | requests. By default, we will use the lightweight native driver but - | you may specify any of the other wonderful drivers provided here. - | - | Supported: "file", "cookie", "database", "apc", - | "memcached", "redis", "dynamodb", "array" - | + |-------------------------------------------------------------------------- + | Default Session Driver + |-------------------------------------------------------------------------- + | + | This option controls the default session "driver" that will be used on + | requests. By default, we will use the lightweight native driver but + | you may specify any of the other wonderful drivers provided here. + | + | Supported: "file", "cookie", "database", "apc", + | "memcached", "redis", "dynamodb", "array" + | */ 'driver' => env('SESSION_DRIVER', 'file'), /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | Here you may specify the number of minutes that you wish the session - | to be allowed to remain idle before it expires. If you want them - | to immediately expire on the browser closing, set that option. - | + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | */ 'lifetime' => env('SESSION_LIFETIME', 120), @@ -36,164 +36,164 @@ return [ 'expire_on_close' => false, /* - |-------------------------------------------------------------------------- - | Session Encryption - |-------------------------------------------------------------------------- - | - | This option allows you to easily specify that all of your session data - | should be encrypted before it is stored. All encryption will be run - | automatically by Laravel and you can use the Session like normal. - | + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it is stored. All encryption will be run + | automatically by Laravel and you can use the Session like normal. + | */ 'encrypt' => false, /* - |-------------------------------------------------------------------------- - | Session File Location - |-------------------------------------------------------------------------- - | - | When using the native session driver, we need a location where session - | files may be stored. A default has been set for you but a different - | location may be specified. This is only needed for file sessions. - | + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | */ 'files' => storage_path('framework/sessions'), /* - |-------------------------------------------------------------------------- - | Session Database Connection - |-------------------------------------------------------------------------- - | - | When using the "database" or "redis" session drivers, you may specify a - | connection that should be used to manage these sessions. This should - | correspond to a connection in your database configuration options. - | + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | */ 'connection' => env('SESSION_CONNECTION', null), /* - |-------------------------------------------------------------------------- - | Session Database Table - |-------------------------------------------------------------------------- - | - | When using the "database" session driver, you may specify the table we - | should use to manage the sessions. Of course, a sensible default is - | provided for you; however, you are free to change this as needed. - | + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | */ 'table' => 'sessions', /* - |-------------------------------------------------------------------------- - | Session Cache Store - |-------------------------------------------------------------------------- - | - | While using one of the framework's cache driven session backends you may - | list a cache store that should be used for these sessions. This value - | must match with one of the application's configured cache "stores". - | - | Affects: "apc", "dynamodb", "memcached", "redis" - | + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | While using one of the framework's cache driven session backends you may + | list a cache store that should be used for these sessions. This value + | must match with one of the application's configured cache "stores". + | + | Affects: "apc", "dynamodb", "memcached", "redis" + | */ 'store' => env('SESSION_STORE', null), /* - |-------------------------------------------------------------------------- - | Session Sweeping Lottery - |-------------------------------------------------------------------------- - | - | Some session drivers must manually sweep their storage location to get - | rid of old sessions from storage. Here are the chances that it will - | happen on a given request. By default, the odds are 2 out of 100. - | + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | */ 'lottery' => [2, 100], /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may change the name of the cookie used to identify a session - | instance by ID. The name specified here will get used every time a - | new session cookie is created by the framework for every driver. - | + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | */ 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_').'_session' + Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' ), /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The session cookie path determines the path for which the cookie will - | be regarded as available. Typically, this will be the root path of - | your application but you are free to change this when necessary. - | + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | */ 'path' => '/', /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | Here you may change the domain of the cookie used to identify a session - | in your application. This will determine which domains the cookie is - | available to in your application. A sensible default has been set. - | + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | */ 'domain' => env('SESSION_DOMAIN', null), /* - |-------------------------------------------------------------------------- - | HTTPS Only Cookies - |-------------------------------------------------------------------------- - | - | By setting this option to true, session cookies will only be sent back - | to the server if the browser has a HTTPS connection. This will keep - | the cookie from being sent to you when it can't be done securely. - | + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you when it can't be done securely. + | */ 'secure' => env('SESSION_SECURE_COOKIE'), /* - |-------------------------------------------------------------------------- - | HTTP Access Only - |-------------------------------------------------------------------------- - | - | Setting this value to true will prevent JavaScript from accessing the - | value of the cookie and the cookie will only be accessible through - | the HTTP protocol. You are free to modify this option if needed. - | + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. You are free to modify this option if needed. + | */ 'http_only' => true, /* - |-------------------------------------------------------------------------- - | Same-Site Cookies - |-------------------------------------------------------------------------- - | - | This option determines how your cookies behave when cross-site requests - | take place, and can be used to mitigate CSRF attacks. By default, we - | will set this value to "lax" since this is a secure default value. - | - | Supported: "lax", "strict", "none", null - | + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | will set this value to "lax" since this is a secure default value. + | + | Supported: "lax", "strict", "none", null + | */ 'same_site' => 'lax', diff --git a/config/view.php b/config/view.php index 22b8a18..53008fd 100644 --- a/config/view.php +++ b/config/view.php @@ -3,14 +3,14 @@ return [ /* - |-------------------------------------------------------------------------- - | View Storage Paths - |-------------------------------------------------------------------------- - | - | Most templating systems load templates from disk. Here you may specify - | an array of paths that should be checked for your views. Of course - | the usual Laravel view path has already been registered for you. - | + |-------------------------------------------------------------------------- + | View Storage Paths + |-------------------------------------------------------------------------- + | + | Most templating systems load templates from disk. Here you may specify + | an array of paths that should be checked for your views. Of course + | the usual Laravel view path has already been registered for you. + | */ 'paths' => [ @@ -18,14 +18,14 @@ return [ ], /* - |-------------------------------------------------------------------------- - | Compiled View Path - |-------------------------------------------------------------------------- - | - | This option determines where all the compiled Blade templates will be - | stored for your application. Typically, this is within the storage - | directory. However, as usual, you are free to change this value. - | + |-------------------------------------------------------------------------- + | Compiled View Path + |-------------------------------------------------------------------------- + | + | This option determines where all the compiled Blade templates will be + | stored for your application. Typically, this is within the storage + | directory. However, as usual, you are free to change this value. + | */ 'compiled' => env( diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index a3eb239..5cdba5b 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -18,7 +18,8 @@ class UserFactory extends Factory 'name' => $this->faker->name(), 'email' => $this->faker->unique()->safeEmail(), 'email_verified_at' => now(), - 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', +// password 'remember_token' => Str::random(10), ]; } diff --git a/routes/web.php b/routes/web.php index 384cb65..dde7dc3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,7 +1,6 @@ make(Kernel::class)->bootstrap(); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 2528673..f4e2e2c 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -3,7 +3,6 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase { @@ -12,7 +11,7 @@ class ExampleTest extends TestCase * * @return void */ - public function test_example() + public function testExample() { $response = $this->get('/'); diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 512787d..6e7911c 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -3,7 +3,6 @@ namespace Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase { @@ -12,7 +11,7 @@ class ExampleTest extends TestCase * * @return void */ - public function test_example() + public function testExample() { $this->assertTrue(true); }