Merge bump into 'develop'
This commit is contained in:
commit
bb38b9e400
155 changed files with 14087 additions and 10130 deletions
|
|
@ -11,5 +11,8 @@ trim_trailing_whitespace = true
|
|||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.yml]
|
||||
[*.yml,yaml]
|
||||
indent_size = 2
|
||||
|
||||
[docker-compose.yml]
|
||||
indent_size = 4
|
||||
|
|
|
|||
25
.env.example
25
.env.example
|
|
@ -6,6 +6,8 @@ APP_URL=http://localhost
|
|||
PROJECT_UUID=
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
|
|
@ -16,13 +18,20 @@ DB_PASSWORD=secret
|
|||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
|
@ -39,6 +48,16 @@ LDAP_USERNAME="cn=admin,dc=example,dc=org"
|
|||
LDAP_PASSWORD=adminpassword
|
||||
LDAP_USE_SSL=false
|
||||
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
ELASTICSEARCH_HOSTS=
|
||||
|
||||
MAIL_LIST_SERVICEWEB=
|
||||
|
||||
PROJECT_UUID=
|
||||
|
||||
## MAIL ADDRESSES
|
||||
MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
|
||||
|
|
|
|||
11
.gitattributes
vendored
11
.gitattributes
vendored
|
|
@ -1,5 +1,10 @@
|
|||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.scss linguist-vendored
|
||||
*.js linguist-vendored
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
|
|
|
|||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -31,4 +31,6 @@ Homestead.json
|
|||
Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
.idea/
|
||||
/.idea
|
||||
/.vscode
|
||||
*.sqlite*
|
||||
|
|
|
|||
13
.styleci.yml
Normal file
13
.styleci.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
php:
|
||||
preset: laravel
|
||||
disabled:
|
||||
- unused_use
|
||||
- no_unused_imports
|
||||
finder:
|
||||
not-name:
|
||||
- index.php
|
||||
js:
|
||||
finder:
|
||||
not-name:
|
||||
- webpack.mix.js
|
||||
css: true
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -18,5 +18,6 @@
|
|||
"titleBar.inactiveBackground": "#51440399",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"peacock.remoteColor": "#514403"
|
||||
"peacock.remoteColor": "#514403",
|
||||
"intelephense.environment.phpVersion": "8.1"
|
||||
}
|
||||
|
|
|
|||
11
README.md
11
README.md
|
|
@ -24,3 +24,14 @@ composer install
|
|||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
```
|
||||
|
||||
# BUMP LARAVEL MEP
|
||||
.env => remplacer MAIL_DRIVER par MAIL_MAILER
|
||||
.env => remplacer FILESYSTEM_DRIVER par FILESYSTEM_DISK
|
||||
.env rajouter PROJECT_UUID=
|
||||
.env rajouter MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
|
||||
|
||||
## Dans les LABs
|
||||
```
|
||||
MAIL_VERIFY_PEER=false
|
||||
```
|
||||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\Sujet;
|
||||
use App\Models\Media;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class DeleteMediaArchive extends Command
|
||||
{
|
||||
|
|
@ -20,19 +21,10 @@ class DeleteMediaArchive extends Command
|
|||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
* @phpcs:disable Generic.Files.LineLength.TooLong
|
||||
*/
|
||||
protected $description = 'Suppression définitive de tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete)';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -40,60 +32,78 @@ 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).');
|
||||
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$this->info('Vous allez supprimer définitivement tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete).');
|
||||
|
||||
$choice = $this->choice('Etes-vous sûr de vouloir lancer ce traitement ?' , ['y', 'n'], 'y');
|
||||
$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);
|
||||
if (\is_array($matchingFiles)) {
|
||||
$this->deleteFiles($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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete files
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFiles(array $files)
|
||||
{
|
||||
collect($files)->map(function (string $filename) {
|
||||
if (!Storage::delete($filename)) {
|
||||
Log::warning("Could not delete $filename from storage.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,23 +2,23 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Societe;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Article;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Site;
|
||||
use App\Models\Societe;
|
||||
use App\Models\Sujet;
|
||||
use App\Models\Typemedia;
|
||||
use App\Models\Typevue;
|
||||
use App\Models\Site;
|
||||
use App\Models\Variante;
|
||||
use App\Models\Media;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ImportArcadiaFiles extends Command
|
||||
{
|
||||
use MediaTools;
|
||||
use MediaTools;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -34,200 +34,328 @@ class ImportArcadiaFiles extends Command
|
|||
*/
|
||||
protected $description = 'Import des fichiers xml Arcadia';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Démarrage du traitement');
|
||||
$files = Storage::disk('arcadia')->files();
|
||||
$bar = $this->output->createProgressBar(count($files)-1);
|
||||
$bar->start();
|
||||
$this->info('Démarrage du traitement');
|
||||
$files = collect(Storage::disk('arcadia')->files());
|
||||
$bar = $this->output->createProgressBar(count($files) - 1);
|
||||
$bar->start();
|
||||
|
||||
// ---- Pour chaque fichier
|
||||
foreach ($files as $filename) {
|
||||
|
||||
if($filename == ".gitignore") continue;
|
||||
|
||||
// ---- 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;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 10) == "DAM_MARQUE") {
|
||||
foreach ($fileContent->dam as $row) {
|
||||
$record = Marque::where('codMarq', $row->codMarq)->first();
|
||||
if($record){ // Update record
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Marque();
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 15) == "DAM_MEDIA_SUJET") {
|
||||
foreach ($fileContent->mediaSujet as $row) {
|
||||
$record = Sujet::where('codeSujet', $row->code)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Sujet();
|
||||
$record->codeSujet = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 20) == "DAM_MEDIA_TYPE_MEDIA") {
|
||||
foreach ($fileContent->mediatypemedia as $row) {
|
||||
$record = Typemedia::where('codeTypemedia', $row->code)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Typemedia();
|
||||
$record->codeTypemedia = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 17) == "DAM_MEDIA_TYPEVUE") {
|
||||
foreach ($fileContent->mediatypesvue as $row) {
|
||||
$record = Typevue::where('codeTypevue', $row->code)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Typevue();
|
||||
$record->codeTypevue = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 18) == "DAM_MEDIA_VARIANTE") {
|
||||
foreach ($fileContent->mediavariante as $row) {
|
||||
$record = Variante::where('codeVariante', $row->code)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Variante();
|
||||
$record->codeVariante = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
|
||||
}elseif (substr($filename, 0, 20) == "DAM_SITE_PROD_GROUPE") {
|
||||
foreach ($fileContent->SITE_PROD_GRP as $row) {
|
||||
$record = Site::where('id', $row->code)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Site();
|
||||
$record->id = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}elseif (substr($filename, 0, 11) == "DAM_SOCIETE") {
|
||||
foreach ($fileContent->dam as $row) {
|
||||
$record = Societe::where('id', $row->codSociete)->first();
|
||||
if($record){ // Update record
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->save();
|
||||
}else{ // Insert new record
|
||||
$record = new Societe();
|
||||
$record->id = $row->codSociete;
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->save();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
// ---- Pour chaque fichier
|
||||
foreach ($files as $filename) {
|
||||
if ($filename == ".gitignore") {
|
||||
continue;
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
// ---- Récupération du contenu
|
||||
if (!($fileContent = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($fileContent))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
switch (true) {
|
||||
case substr($filename, 0, 11) == 'DAM_ARTICLE':
|
||||
$this->insertDamArticle($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 10) == 'DAM_MARQUE':
|
||||
$this->insertDamMarque($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 15) == 'DAM_MEDIA_SUJET':
|
||||
$this->insertDamMediaSujet($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 20) == 'DAM_MEDIA_TYPE_MEDIA':
|
||||
$this->insertDamMediaTypeMedia($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 17) == 'DAM_MEDIA_TYPEVUE':
|
||||
$this->insertDamMediaTypeVue($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 18) == 'DAM_MEDIA_VARIANTE':
|
||||
$this->insertDamMediaVariante($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 20) == 'DAM_SITE_PROD_GROUPE':
|
||||
$this->insertDamSiteProdGroupe($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
case substr($filename, 0, 11) == 'DAM_SOCIETE':
|
||||
$this->insertDamSociete($fileContent);
|
||||
$this->deleteFile($filename);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException("Unhandled file $filename");
|
||||
} //end switch
|
||||
$bar->advance();
|
||||
} //end foreach
|
||||
|
||||
$bar->finish();
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Article
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamArticle(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Article|null $record */
|
||||
$record = Article::where('noArt', $row->noArt)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Article();
|
||||
$record->noArt = $row->noArt;
|
||||
$record->libCcial = $row->libCcial;
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->codFamVte = $row->codFamVte;
|
||||
$record->libFamVte = $row->libFamVte;
|
||||
$record->codGencodAdm = $row->codGencodAdm;
|
||||
$record->codGencodSymb = $row->codGencodSymb;
|
||||
$record->codGencodPds = $row->codGencodPds;
|
||||
$record->utilisableGroupe = $row->utilisableGroupe;
|
||||
$record->saveOrFail();
|
||||
} //end if
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Marque
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMarque(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Marque|null $record */
|
||||
$record = Marque::where('codMarq', $row->codMarq)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Marque();
|
||||
$record->codMarq = $row->codMarq;
|
||||
$record->libMarq = $row->libMarq;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Sujet
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaSujet(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaSujet as $row) {
|
||||
/** @var \App\Models\Sujet|null $record */
|
||||
$record = Sujet::where('codeSujet', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Sujet();
|
||||
$record->codeSujet = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Type Media
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaTypeMedia(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediatypemedia as $row) {
|
||||
/** @var \App\Models\Typemedia|null $record */
|
||||
$record = Typemedia::where('codeTypemedia', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Typemedia();
|
||||
$record->codeTypemedia = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Type Vue
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaTypeVue(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediatypesvue as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Typevue::where('codeTypevue', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Typevue();
|
||||
$record->codeTypevue = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->mediasujet->code;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Media Variante
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamMediaVariante(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediavariante as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Variante::where('codeVariante', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Variante();
|
||||
$record->codeVariante = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->sujet_id = $row->sujet_id->children()[0]->code;
|
||||
$record->typevue_id = $row->CodeTypeVue->mediatypesvue->code;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Site Prod Groupe
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamSiteProdGroupe(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->SITE_PROD_GRP as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Site::where('id', $row->code)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Site();
|
||||
$record->id = $row->code;
|
||||
$record->libelle = $row->libelle;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update or Create Dam Societe
|
||||
*
|
||||
* @param \SimpleXMLElement $fileContent
|
||||
* @return void
|
||||
* @throws \Throwable On save failure.
|
||||
*/
|
||||
private function insertDamSociete(\SimpleXMLElement $fileContent)
|
||||
{
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->dam as $row) {
|
||||
/** @var \App\Models\Typevue|null $record */
|
||||
$record = Societe::where('id', $row->codSociete)->first();
|
||||
if ($record) {
|
||||
// * Update record
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->saveOrFail();
|
||||
} else {
|
||||
// * Insert new record
|
||||
$record = new Societe();
|
||||
$record->id = $row->codSociete;
|
||||
$record->libelle = $row->nomSociete;
|
||||
$record->saveOrFail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFile(string $filename)
|
||||
{
|
||||
if (!Storage::disk('arcadia')->delete($filename)) {
|
||||
Log::warning("Could not delete $filename from arcadia storage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Article;
|
||||
use App\Models\Dossier;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Media;
|
||||
use App\Models\Dossier;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use League\Flysystem\FileNotFoundException;
|
||||
|
||||
class ImportMedia extends Command
|
||||
{
|
||||
|
|
@ -29,16 +33,6 @@ class ImportMedia extends Command
|
|||
*/
|
||||
protected $description = 'Import des fichiers xml Média Visuel Arcadia';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -48,34 +42,243 @@ class ImportMedia extends Command
|
|||
{
|
||||
$this->info('Démarrage du traitement');
|
||||
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_MEDIA_VISUEL_*.*");
|
||||
$files = File::glob(storage_path('export_arcadia') . '/DAM_MEDIA_VISUEL_*.*');
|
||||
|
||||
$this->line("-> Import du fichier DAM_MEDIA_VISUEL");
|
||||
// ---- Traitement de l'import des XML Visuel
|
||||
|
||||
$this->xmlVisuels($files);
|
||||
$this->associateMediasArticles($files);
|
||||
$this->associateMediasMarques($files);
|
||||
$this->associateMediasSocietes($files);
|
||||
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> societe
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
*/
|
||||
private function associateMediasSocietes(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_SOCIETE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_SOCIETE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->MEDIA_VISUEL)-1);
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassosociete) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassosociete as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
// * attache la societe au média
|
||||
$record->societes()->attach($row->codSociete);
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_SOCIETE : le media n°$row->codeVisuel n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> marque
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
*/
|
||||
private function associateMediasMarques(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_MARQUE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_MARQUE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassomarque) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassomarque as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
if ($record->marques->contains($row->codMarq)) {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°$row->codeVisuel est déjà associé à cette marque.");
|
||||
} else {
|
||||
// * attache la marque au média
|
||||
$record->marques()->attach($row->codMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°$row->codeVisuel n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'association media <-> article
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException If a model cant be found on transaction.
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \Throwable If saving fails.
|
||||
* @phpcs:disable Generic.Metrics.NestingLevel.TooHigh
|
||||
* @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
|
||||
*/
|
||||
private function associateMediasArticles(array $files): void
|
||||
{
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_ARTICLE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_ARTICLE");
|
||||
/** @var string $filename */
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle) - 1);
|
||||
$bar->start();
|
||||
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->mediaassoarticle as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
/** @var \App\Models\Article|null */
|
||||
$article = Article::where('noArt', $row->noArt)->first();
|
||||
if ($article) {
|
||||
// * attache l'article au média
|
||||
$record->articles()->syncWithoutDetaching($article->id);
|
||||
// * recherche un dossier lié à la marque de l'article
|
||||
$marque_id = $article->codMarq;
|
||||
/** @var \App\Models\Dossier|null */
|
||||
$dossier = Dossier::whereHas("marques", function ($query) use ($marque_id) {
|
||||
$query->where("codMarq", $marque_id);
|
||||
})->first();
|
||||
|
||||
if ($dossier) {
|
||||
// * attache le dossier marque au Média
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
$this->line("Liason media n°$row->codeVisuel à la marque n°$article->libMarq");
|
||||
} else {
|
||||
DB::transaction(function () use ($record, $marque_id) {
|
||||
/** @var \App\Models\Marque */
|
||||
$marque = Marque::where('codMarq', '=', $marque_id)->firstOrFail();
|
||||
// * On cree le dossier
|
||||
$dossier = new Dossier();
|
||||
$dossier->libelle = $marque->libMarq;
|
||||
$dossier->sujet_id = 1;
|
||||
$dossier->system = false;
|
||||
$dossier->saveOrFail();
|
||||
$dossier->marques()->syncWithoutDetaching($marque_id);
|
||||
$dossier->saveOrFail();
|
||||
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->saveOrFail();
|
||||
});
|
||||
} //end if
|
||||
} else {
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°$row->codeVisuel ne peut être lié à l'article n°$row->noArt");
|
||||
} //end if
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°$row->codeVisuel n'existe pas");
|
||||
} //end if
|
||||
$bar->advance();
|
||||
} //end foreach
|
||||
$bar->finish();
|
||||
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Traitement de l'import des XML Visuel
|
||||
*
|
||||
* @param array $files
|
||||
* @return void
|
||||
* @throws \League\Flysystem\FileNotFoundException If a file could not be read.
|
||||
* @throws \ErrorException If a xml file could not be parsed.
|
||||
*/
|
||||
private function xmlVisuels(array $files): void
|
||||
{
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
if (!($oneFile = Storage::disk('arcadia')->get($filename))) {
|
||||
throw new FileNotFoundException($filename);
|
||||
}
|
||||
if (!($fileContent = simplexml_load_string($oneFile))) {
|
||||
throw new \ErrorException("Could not parse $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->MEDIA_VISUEL) - 1);
|
||||
$bar->start();
|
||||
/** @var \SimpleXMLElement $row */
|
||||
foreach ($fileContent->MEDIA_VISUEL as $row) {
|
||||
/** @var \App\Models\Media|null */
|
||||
$record = Media::where('arcadia_id', $row->code)->first();
|
||||
if (!$record) { // Insert new record
|
||||
$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 != "") {
|
||||
|
|
@ -89,211 +292,102 @@ class ImportMedia extends Command
|
|||
} else {
|
||||
$record->typemedia_id = 1;
|
||||
}
|
||||
if ($row->codeTypeVue != "") {
|
||||
if (
|
||||
$row->codeTypeVue != ""
|
||||
) {
|
||||
$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));
|
||||
// Affectation d'un dossier et d'un uid.
|
||||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
$record->folder = $destinationPath;
|
||||
$record->uid = Str::uuid();
|
||||
|
||||
$mediaFile = "/images/{$record->arcadia_id}.{$record->extension}";
|
||||
if (Storage::disk('arcadia')->exists($mediaFile)) {
|
||||
// * déplacement du média et renommage du fichier
|
||||
if (!($fileContent = Storage::disk('arcadia')->get($mediaFile))) {
|
||||
throw new \ErrorException("Could not read $mediaFile from arcadia storage.");
|
||||
}
|
||||
// * According to config, should throw exception on failure.
|
||||
Storage::disk('local')->put(
|
||||
$fileContent,
|
||||
"{$destinationPath}{$record->uid}.$record->extension"
|
||||
);
|
||||
|
||||
$mediaFile = "/images/" . $record->arcadia_id . "." . $record->extension;
|
||||
$fileExists = Storage::disk('arcadia')->exists($mediaFile);
|
||||
if ($fileExists) {
|
||||
// déplacement du média et renommage du fichier
|
||||
$file = Storage::disk('arcadia')->get($mediaFile);
|
||||
$full_path_source = Storage::disk('arcadia')->getDriver()->getAdapter()->applyPathPrefix($mediaFile);
|
||||
$full_path_dest = Storage::disk('local')->getDriver()->getAdapter()->applyPathPrefix($destinationPath . $record->uid . '.' . $record->extension);
|
||||
File::move($full_path_source, $full_path_dest);
|
||||
|
||||
// calcul de la taille du média
|
||||
$record->taille = $this->formatBytes($this->get_file_size($full_path_dest));
|
||||
|
||||
// * calcul de la taille du média
|
||||
$record->taille = $this->formatBytes(Storage::disk('local')
|
||||
->size("{$destinationPath}{$record->uid}.$record->extension"));
|
||||
} else {
|
||||
// on applique une image par défaut
|
||||
// * on applique une image par défaut
|
||||
$record->extension = "jpg";
|
||||
Storage::disk('local')->copy("assets/images/default.jpg", $destinationPath . $record->uid . '.' . $record->extension);
|
||||
Storage::disk('local')->copy(
|
||||
"assets/images/default.jpg",
|
||||
"{$destinationPath}{$record->uid}.{$record->extension}"
|
||||
);
|
||||
|
||||
// calcul de la taille du média
|
||||
$record->taille = $this->formatBytes($this->get_file_size("public/" . $destinationPath . $record->uid . '.' . $record->extension));
|
||||
}
|
||||
// * calcul de la taille du média
|
||||
$record->taille = $this->formatBytes(Storage::disk('local')
|
||||
->size("{$destinationPath}{$record->uid}.{$record->extension}"));
|
||||
} //end if
|
||||
|
||||
|
||||
$record->save();
|
||||
$record->saveOrFail();
|
||||
|
||||
// ---- Creation des vignettes de base
|
||||
$this->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");
|
||||
}
|
||||
$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);
|
||||
$this->deleteFile($filename);
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param string $filename
|
||||
* @return void
|
||||
*/
|
||||
private function deleteFile(string $filename): void
|
||||
{
|
||||
if (!Storage::disk('arcadia')->delete($filename)) {
|
||||
Log::warning("Could not delete $filename from arcadia storage.");
|
||||
}
|
||||
|
||||
|
||||
// ---- Traitement de l'association media <-> article
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_ARTICLE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_ARTICLE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassoarticle)-1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassoarticle as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
$article = Article::where('noArt', $row->noArt)->first();
|
||||
if ($article) {
|
||||
// attache l'article au média
|
||||
$record->articles()->syncWithoutDetaching($article->id);
|
||||
// recherche un dossier lié à la marque de l'article
|
||||
$marque_id = $article->codMarq;
|
||||
$dossier = Dossier::whereHas("marques", function ($query) use ($marque_id) {
|
||||
$query->where("codMarq", $marque_id);
|
||||
})->first();
|
||||
|
||||
if ($dossier) {
|
||||
// attache le dossier marque au Média
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
$this->line("Liason media n°" . $row->codeVisuel . " à la marque n°" . $article->libMarq);
|
||||
} else {
|
||||
$marque = Marque::where('codMarq', '=', $marque_id)->first();
|
||||
// On cree le dossier
|
||||
$dossier = new Dossier();
|
||||
$dossier->libelle = $marque->libMarq;
|
||||
$dossier->sujet_id = 1;
|
||||
$dossier->system = 0;
|
||||
$dossier->save();
|
||||
$dossier->marques()->syncWithoutDetaching($marque_id);
|
||||
$dossier->save();
|
||||
|
||||
$record->dossier_id = $dossier->id;
|
||||
$record->save();
|
||||
//$this->line("Liason media n°" . $row->codeVisuel . " à la marque n°" . $article->libMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°" . $row->codeVisuel . " ne peut être lié à l'article n°" . $row->noArt);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_ARTICLE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}
|
||||
|
||||
// ---- Traitement de l'association media <-> marque
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_MARQUE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_MARQUE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassomarque)-1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassomarque as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
if ($record->marques->contains($row->codMarq)){
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°" . $row->codeVisuel . " est déjà associé à cette marque.");
|
||||
}else{
|
||||
// attache la marque au média
|
||||
$record->marques()->attach($row->codMarq);
|
||||
}
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_MARQUE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}
|
||||
|
||||
// ---- Traitement de l'association media <-> societe
|
||||
$files = File::glob(storage_path('export_arcadia') . "/DAM_ASSO_SOCIETE_*.*");
|
||||
$this->line("-> Import du fichier DAM_ASSO_SOCIETE");
|
||||
foreach ($files as $filename) {
|
||||
$path = explode("/", $filename);
|
||||
$filename = $path[count($path) - 1];
|
||||
|
||||
// ---- Récupération du contenu
|
||||
$oneFile = Storage::disk('arcadia')->get($filename);
|
||||
$fileContent = simplexml_load_string($oneFile);
|
||||
|
||||
// ---- traitement du fichier
|
||||
$bar = $this->output->createProgressBar(count($fileContent->mediaassosociete)-1);
|
||||
$bar->start();
|
||||
foreach ($fileContent->mediaassosociete as $row) {
|
||||
$record = Media::where('arcadia_id', $row->codeVisuel)->first();
|
||||
if ($record) {
|
||||
// attache la societe au média
|
||||
$record->societes()->attach($row->codSociete);
|
||||
} else {
|
||||
$this->line("\nDAM_ASSO_SOCIETE : le media n°" . $row->codeVisuel . " n'existe pas");
|
||||
}
|
||||
$bar->advance();
|
||||
}
|
||||
$bar->finish();
|
||||
|
||||
// ---- Suppression du fichier
|
||||
Storage::disk('arcadia')->delete($filename);
|
||||
}
|
||||
|
||||
$this->line("");
|
||||
$this->info('Fin du traitement');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
/*
|
||||
* Command Name: LDC Web Status Checker
|
||||
* Description: Envoi des infos Serveur/Laravel vers LDC Web
|
||||
* Version: 1.0
|
||||
* Author: Vincent BRIDIER
|
||||
* Author URI: vincent.bridier@ldc.fr
|
||||
*/
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class LDCWebStatusChecker extends Command
|
||||
/**
|
||||
* Command Name: LDC Web Status Checker
|
||||
* Description: Envoi des infos Serveur/Laravel vers LDC Web
|
||||
* Version: 1.1
|
||||
* Author: Vincent BRIDIER
|
||||
* Author URI: vincent.bridier@ldc.fr
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class LdcWebStatusChecker extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -27,16 +29,6 @@ class LDCWebStatusChecker extends Command
|
|||
*/
|
||||
protected $description = 'Envoi des infos Serveur/Laravel vers LDC Web';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -44,28 +36,28 @@ class LDCWebStatusChecker extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [];
|
||||
$data['uuid'] = env('PROJECT_UUID');
|
||||
$data = [];
|
||||
$data['uuid'] = config('ldcweb.project_uuid');
|
||||
|
||||
// Sitemap.xml ?
|
||||
if (file_exists(public_path() . '/sitemap.xml')) {
|
||||
$data['sitemap'] = 'true';
|
||||
}else{
|
||||
} else {
|
||||
$data['sitemap'] = 'false';
|
||||
}
|
||||
|
||||
// Robots.txt ?
|
||||
if (file_exists(public_path() . '/robots.txt')) {
|
||||
$data['robots'] = 'true';
|
||||
}else{
|
||||
} else {
|
||||
$data['robots'] = 'false';
|
||||
}
|
||||
|
||||
//Check logs
|
||||
// Check logs.
|
||||
$data['logs'] = 0;
|
||||
$patherror = storage_path('/logs');
|
||||
$files = glob($patherror.'/*.log');
|
||||
if(count($files) > 0){
|
||||
$patherror = storage_path('/logs');
|
||||
$files = glob($patherror . '/*.log');
|
||||
if (count($files) > 0) {
|
||||
foreach ($files as $file) {
|
||||
$data['logs'] = $data['logs'] + filesize($file);
|
||||
}
|
||||
|
|
@ -73,13 +65,14 @@ 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);
|
||||
// Send by cURL.
|
||||
$url = 'https://ldc-web.ldc.fr/api/status-checker';
|
||||
$ch = curl_init($url);
|
||||
$payload = ['token' => 'CE8S52Qq7stf5k8frF4T', 'datas' => json_encode($data)];
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($ch);
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,17 +2,14 @@
|
|||
|
||||
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;
|
||||
use App\Models\Media;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RegenerateThumbnails extends Command
|
||||
{
|
||||
|
||||
use MediaTools;
|
||||
use MediaTools;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -28,16 +25,6 @@ class RegenerateThumbnails extends Command
|
|||
*/
|
||||
protected $description = 'Regénération de toutes les vignettes des médias';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -45,50 +32,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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ReindexElasticMedia extends Command
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class reindexElasticOneMedia extends Command
|
||||
class ReindexElasticOneMedia extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -21,16 +21,6 @@ class reindexElasticOneMedia extends Command
|
|||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -38,8 +28,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();
|
||||
|
|
@ -21,16 +21,6 @@ class SendMediasModificationsReport extends Command
|
|||
*/
|
||||
protected $description = 'Run the SendMediasModificationsReport Manually';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
|
|
@ -39,7 +29,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');
|
||||
|
|
|
|||
|
|
@ -2,22 +2,12 @@
|
|||
|
||||
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;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
ArcadiaLinkCommand::class
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* En attente phpcs merge
|
||||
* https://github.com/squizlabs/PHP_CodeSniffer/pull/3478
|
||||
*/
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* @method static self debug()
|
||||
* @method static self log()
|
||||
* @method static self warning()
|
||||
* @method static self info()
|
||||
* @method static self error()
|
||||
* @method static self critical()
|
||||
*/
|
||||
final class LogType extends BaseEnumRoutable
|
||||
enum LogType: int
|
||||
{
|
||||
case debug = 0;
|
||||
case log = 1;
|
||||
case warning = 2;
|
||||
case info = 3;
|
||||
case error = 4;
|
||||
case critical = 5;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class AbortXmlImportException extends ErrorException
|
||||
class AbortXmlImportException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class ElasticSearchException extends ErrorException
|
||||
class ElasticSearchException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,50 +2,44 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of exception types with their corresponding custom log levels.
|
||||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
protected $dontReport = [];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
public function register()
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
$this->reportable(function (Throwable $e) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use ErrorException;
|
||||
|
||||
class InvalidXmlException extends ErrorException
|
||||
class InvalidXmlException extends \ErrorException
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
|
|
@ -3,21 +3,11 @@
|
|||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
|
|
@ -25,7 +15,7 @@ class LoginController extends Controller
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
protected $redirectTo = RouteServiceProvider::HOME;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
|
@ -37,8 +27,13 @@ class LoginController extends Controller
|
|||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
|
||||
public function username()
|
||||
{
|
||||
return 'matricule';
|
||||
}
|
||||
/**
|
||||
* Get the login username to be used by the controller.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function username()
|
||||
{
|
||||
return 'matricule';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => Hash::make($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\VerifiesEmails;
|
||||
|
||||
class VerificationController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Email Verification Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling email verification for any
|
||||
| user that recently registered with the application. Emails may also
|
||||
| be re-sent if the user didn't receive the original email message.
|
||||
|
|
||||
*/
|
||||
|
||||
use VerifiesEmails;
|
||||
|
||||
/**
|
||||
* Where to redirect users after verification.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('signed')->only('verify');
|
||||
$this->middleware('throttle:6,1')->only('verify', 'resend');
|
||||
}
|
||||
}
|
||||
|
|
@ -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\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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
use AuthorizesRequests;
|
||||
use DispatchesJobs;
|
||||
use ValidatesRequests;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -23,7 +23,7 @@ class PanierController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
/** @var \App\User $user */
|
||||
/** @var \App\Models\User $user */
|
||||
$user = \auth()->user();
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection $paniers */
|
||||
|
|
@ -41,7 +41,7 @@ class PanierController extends Controller
|
|||
*/
|
||||
public function getBaskets()
|
||||
{
|
||||
/** @var \App\User $user */
|
||||
/** @var \App\Models\User $user */
|
||||
$user = \auth()->user();
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Collection $paniers */
|
||||
|
|
@ -123,8 +123,7 @@ class PanierController extends Controller
|
|||
/** @var \App\Models\Panier $basket */
|
||||
$basket = Panier::whereId($request->basket_id)->firstOrFail();
|
||||
|
||||
// TODO: Replace this with deleteOrFail after laravel bump.
|
||||
$basket->delete();
|
||||
$basket->deleteOrFail();
|
||||
|
||||
return response()->json();
|
||||
}
|
||||
|
|
@ -139,7 +138,7 @@ class PanierController extends Controller
|
|||
*/
|
||||
public function showBasket(Panier $panier)
|
||||
{
|
||||
/** @var \App\User|null $user */
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = auth()->user();
|
||||
|
||||
// * Ne pas afficher le panier si il n'est pas pas publié et
|
||||
|
|
@ -152,7 +151,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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Traits\ArcadiaLink;
|
||||
use App\Http\Traits\MediaTools;
|
||||
use App\Models\Historique;
|
||||
use App\Models\Media;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Media;
|
||||
use App\Models\Site;
|
||||
use App\Models\Historique;
|
||||
use App\Http\Traits\MediaTools;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UploadController extends Controller
|
||||
{
|
||||
|
||||
use MediaTools;
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
// ---- Vérification du token de sécurité
|
||||
$token = $request->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');
|
||||
/** @var array<\Illuminate\Http\UploadedFile> */
|
||||
$files = $request->file('files');
|
||||
|
||||
foreach($file as $files){
|
||||
$is_last_chunk = false;
|
||||
foreach ($files as $file) {
|
||||
$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,418 +61,448 @@ class UploadController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
$extension = strtolower($files->getClientOriginalExtension());
|
||||
$originalName = str_replace(".".$extension, "", $files->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($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);
|
||||
$file->move($uploadPath, $filename);
|
||||
|
||||
// si c'est le dernier morceux d'un fichier
|
||||
if($is_last_chunk) {
|
||||
if($dossier = opendir($uploadPath)) {
|
||||
// * si c'est le dernier morceux d'un fichier
|
||||
if ($is_last_chunk) {
|
||||
if ($dossier = opendir($uploadPath)) {
|
||||
$dirFiles = array();
|
||||
// on compile tous les chunk du fichier
|
||||
while(false !== ($fichier = readdir($dossier))){
|
||||
if($fichier != '.' && $fichier != '..' ) {
|
||||
if(strpos($fichier, $uid) !== false) {
|
||||
$dirFiles[$fichier] = str_replace(".".$extension, "", str_replace($uid."_", "", $fichier));
|
||||
// * on compile tous les chunk du fichier
|
||||
while (false !== ($fichier = readdir($dossier))) {
|
||||
if ($fichier != '.' && $fichier != '..') {
|
||||
if (strpos($fichier, $uid) !== false) {
|
||||
$dirFiles[$fichier] = str_replace(
|
||||
".{$extension}",
|
||||
"",
|
||||
str_replace("{$uid}_", "", $fichier)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dossier);
|
||||
// on les trie pour les assembler dans le bon ordre
|
||||
// * on les trie pour les assembler dans le bon ordre
|
||||
asort($dirFiles, SORT_NUMERIC);
|
||||
// on les assemble dans un fichier final
|
||||
// * on les assemble dans un fichier final
|
||||
$filename = $uid . '.' . $extension;
|
||||
foreach($dirFiles as $key => $fichier) {
|
||||
$file = fopen($uploadPath.$key, 'rb');
|
||||
$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->getMediaFolder() . "/";
|
||||
|
||||
// * si on upload un média pour remplacer un fichier par un autre
|
||||
if ($replaceMediaId != 0) {
|
||||
// * on récupère le média à modifier
|
||||
/** @var \App\Models\Media|null */
|
||||
$media = Media::where('id', $replaceMediaId)->first();
|
||||
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
if (!Storage::move("uploads/{$filename}", $destinationPath . $filename)) {
|
||||
throw new \ErrorException(
|
||||
"Could not move uploaded file $filename into {$destinationPath}{$filename}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 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()."/";
|
||||
|
||||
// si on upload un média pour remplacer un fichier par un autre
|
||||
if($replaceMediaId != 0) {
|
||||
// on récupère le média à modifier
|
||||
$media= Media::where('id', $replaceMediaId)->first();
|
||||
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/".$filename, $destinationPath.$filename);
|
||||
|
||||
// supprime les fichiers médias stockés sur disque
|
||||
$filesfF= Storage::files($media->folder."/");
|
||||
$filepath = preg_quote($media->folder.$media->uid, '/');
|
||||
$matchingFiles = preg_grep('/^'.$filepath.'/', $filesfF);
|
||||
// * 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);
|
||||
Storage::delete($matchingFiles);
|
||||
|
||||
$media->isDefault = 0;
|
||||
$media->save();
|
||||
} else {
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
if (!Storage::move("uploads/{$filename}", $destinationPath . $filename)) {
|
||||
throw new \ErrorException(
|
||||
"Could not move uploaded file $filename into {$destinationPath}{$filename}"
|
||||
);
|
||||
}
|
||||
|
||||
}else{
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/".$filename, $destinationPath.$filename);
|
||||
|
||||
// on créé un média en bdd
|
||||
$media = new Media();
|
||||
// * on créé un média en bdd
|
||||
$media = new Media();
|
||||
$media->dossier_id = $dossier_id;
|
||||
$media->sujet_id = $sujet_id;
|
||||
// Par défaut FR
|
||||
$media->sujet_id = $sujet_id;
|
||||
// * Par défaut FR
|
||||
$media->langue_id = 1;
|
||||
// Par défaut propriété de la marque
|
||||
// * Par défaut propriété de la marque
|
||||
$media->copyright_id = 3;
|
||||
}
|
||||
}//end if
|
||||
|
||||
$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(Storage::size($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);
|
||||
// * 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);
|
||||
|
||||
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;
|
||||
// Illustration/Vectorielle (2)
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
// ---- 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;
|
||||
// * 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;
|
||||
// * 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;
|
||||
}//end switch
|
||||
|
||||
$id = $media->id;
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
// ---- Index dans Elasticsearch
|
||||
$media = Media::where('id', $media->id)->first();
|
||||
$media->addToIndex();
|
||||
|
||||
// ---- Historique des actions
|
||||
$historique = new historique();
|
||||
if($user = Auth::user()) {
|
||||
$historique = new Historique();
|
||||
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) {
|
||||
$uid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
|
||||
$uid = Str::uuid();
|
||||
}
|
||||
|
||||
$file = $request->file('files');
|
||||
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
|
||||
// * check the error status
|
||||
if ($file->getError() != 0) {
|
||||
Log::error('error ' . $file->getError() . ' in file ' . $request->resumableFilename);
|
||||
}
|
||||
|
||||
// init the destination file (format <filename.ext>.part<#chunk>
|
||||
// the file is stored in a temporary directory
|
||||
if(isset($request->resumableIdentifier) && trim($request->resumableIdentifier)!='') {
|
||||
$temp_dir = 'uploads/' . $request->resumableIdentifier;
|
||||
}
|
||||
$dest_file = $temp_dir . '/' . $request->resumableFilename . '.part' . $request->resumableChunkNumber;
|
||||
$temp_dir = 'uploads';
|
||||
|
||||
// create the temporary directory
|
||||
/**
|
||||
* init the destination file (format <filename.ext>.part<#chunk>
|
||||
* the file is stored in a temporary directory
|
||||
*/
|
||||
if (isset($request->resumableIdentifier) && trim($request->resumableIdentifier) != '') {
|
||||
$temp_dir .= "/{$request->resumableIdentifier}";
|
||||
}
|
||||
$dest_file = "{$temp_dir}/{$request->resumableFilename}.part{$request->resumableChunkNumber}";
|
||||
|
||||
// * create the temporary directory
|
||||
if (!is_dir($temp_dir)) {
|
||||
mkdir($temp_dir, 0777, true);
|
||||
}
|
||||
|
||||
// move the temporary file
|
||||
// * move the temporary file
|
||||
if (!move_uploaded_file($file->getPathname(), $dest_file)) {
|
||||
Log::error('Error saving (move_uploaded_file) chunk ' . $request->resumableChunkNumber.' for file ' . $request->resumableFilename);
|
||||
Log::error(
|
||||
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
"Error saving (move_uploaded_file) chunk $request->resumableChunkNumber for file $request->resumableFilename"
|
||||
);
|
||||
} else {
|
||||
$filename = $uid . '.' . $extension;
|
||||
// check if all the parts present, and create the final destination file
|
||||
$isLast = $this->createFileFromChunks($temp_dir, $request->resumableFilename, $request->resumableChunkSize, $request->resumableTotalSize, $request->resumableTotalChunks, $filename);
|
||||
// * check if all the parts present, and create the final destination file
|
||||
$isLast = $this->createFileFromChunks(
|
||||
$temp_dir,
|
||||
$request->resumableFilename,
|
||||
$request->resumableChunkSize,
|
||||
$request->resumableTotalSize,
|
||||
$request->resumableTotalChunks,
|
||||
$filename
|
||||
);
|
||||
if ($isLast) {
|
||||
$destinationPath = $this->getMediaFolder() . "/";
|
||||
|
||||
$destinationPath = $this->get_mediaFolder()."/";
|
||||
// * si on upload un média pour remplacer un fichier par un autre
|
||||
if ($replaceMediaId != 0) {
|
||||
// * on récupère le média à modifier
|
||||
/** @var \App\Models\Media $media */
|
||||
$media = Media::where('id', $replaceMediaId)->firstOrFail();
|
||||
|
||||
// si on upload un média pour remplacer un fichier par un autre
|
||||
if($replaceMediaId != 0) {
|
||||
// on récupère le média à modifier
|
||||
$media= Media::where('id', $replaceMediaId)->first();
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
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);
|
||||
// * 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);
|
||||
Storage::delete($matchingFiles);
|
||||
|
||||
$media->isDefault = 0;
|
||||
$media->save();
|
||||
} else {
|
||||
// * On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/" . $filename, $destinationPath . $filename);
|
||||
|
||||
}else{
|
||||
// On déplace le fichier dans le répertoire des médias
|
||||
Storage::move("uploads/".$filename, $destinationPath.$filename);
|
||||
|
||||
// on créé un média en bdd
|
||||
$media = new Media();
|
||||
// * on créé un média en bdd
|
||||
$media = new Media();
|
||||
$media->dossier_id = $dossier_id;
|
||||
$media->sujet_id = $sujet_id;
|
||||
// Par défaut FR
|
||||
$media->sujet_id = $sujet_id;
|
||||
// * Par défaut FR
|
||||
$media->langue_id = 1;
|
||||
// Par défaut propriété de la marque
|
||||
// * Par défaut propriété de la marque
|
||||
$media->copyright_id = 3;
|
||||
}
|
||||
}//end if
|
||||
|
||||
$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));
|
||||
// * 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);
|
||||
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->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;
|
||||
// * 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;
|
||||
// * 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;
|
||||
}//end switch
|
||||
|
||||
// ---- 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;
|
||||
// Illustration/Vectorielle (2)
|
||||
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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
$id = $media->id;
|
||||
$id = $media->id;
|
||||
$media = Media::find($id);
|
||||
// ---- Index dans Elasticsearch
|
||||
$media = Media::where('id', $media->id)->first();
|
||||
$media->addToIndex();
|
||||
|
||||
// ---- Historique des actions
|
||||
$historique = new historique();
|
||||
if($user = Auth::user()) {
|
||||
$historique = new Historique();
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all the parts exist, and
|
||||
* gather all the parts of the file together
|
||||
*
|
||||
* @param string $temp_dir - the temporary directory holding all the parts of the file
|
||||
* @param string $fileName - the original file name
|
||||
* @param string $chunkSize - each chunk size (in bytes)
|
||||
* @param string $totalSize - original file size (in bytes)
|
||||
* @return bool
|
||||
* @param string $temp_dir The temporary directory holding all the parts of the file.
|
||||
* @param string $fileName The original file name.
|
||||
* @param integer $chunkSize Each chunk size (in bytes).
|
||||
* @param integer $totalSize Original file size (in bytes).
|
||||
* @param integer $total_files
|
||||
* @param string $finalName
|
||||
* @return boolean
|
||||
*/
|
||||
private function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize, $total_files, $finalName)
|
||||
{
|
||||
|
||||
// count all the parts of this file
|
||||
private function createFileFromChunks(
|
||||
string $temp_dir,
|
||||
string $fileName,
|
||||
int $chunkSize,
|
||||
int $totalSize,
|
||||
int $total_files,
|
||||
string $finalName
|
||||
): bool {
|
||||
// * count all the parts of this file
|
||||
$total_files_on_server_size = 0;
|
||||
$temp_total = 0;
|
||||
foreach(scandir($temp_dir) as $file) {
|
||||
$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.
|
||||
// * 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);
|
||||
// * 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}"));
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -478,25 +510,26 @@ class UploadController extends Controller
|
|||
return false;
|
||||
}
|
||||
|
||||
// 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');
|
||||
// * rename the temporary directory (to avoid access from other
|
||||
// * concurrent chunks uploads) and than delete it
|
||||
if (rename($temp_dir, $temp_dir . '_UNUSED')) {
|
||||
$this->rrmdir($temp_dir . '_UNUSED');
|
||||
} else {
|
||||
$this->rrmdir($temp_dir);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}//end if
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a directory RECURSIVELY
|
||||
*
|
||||
* @param string $dir - directory path
|
||||
* @param string $dir Directory path.
|
||||
* @return void
|
||||
* @link http://php.net/manual/en/function.rmdir.php
|
||||
*/
|
||||
private function rrmdir($dir)
|
||||
private function rrmdir(string $dir): void
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -20,7 +20,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
$users = User::all();
|
||||
|
|
@ -36,7 +36,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
$roles = config('roles.label');
|
||||
|
|
@ -56,7 +56,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
$validatedData = $request->validate([
|
||||
|
|
@ -122,7 +122,7 @@ class UserController extends Controller
|
|||
*/
|
||||
public function checkMatricule(Request $request)
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
$response = [];
|
||||
|
|
@ -157,7 +157,7 @@ class UserController extends Controller
|
|||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(User $user)
|
||||
|
|
@ -175,12 +175,12 @@ class UserController extends Controller
|
|||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(User $user)
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
|
||||
|
|
@ -204,12 +204,12 @@ class UserController extends Controller
|
|||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, User $user)
|
||||
{
|
||||
/** @var \App\User $localUser */
|
||||
/** @var \App\Models\User $localUser */
|
||||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
$validatedData = $request->validate([
|
||||
|
|
@ -257,7 +257,7 @@ class UserController extends Controller
|
|||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Http\Requests\DestroyUserRequest $request
|
||||
* @param \App\User $user
|
||||
* @param \App\Models\User $user
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(DestroyUserRequest $request, User $user)
|
||||
|
|
@ -266,7 +266,7 @@ class UserController extends Controller
|
|||
$localUser = auth()->user();
|
||||
$localUser->authorizeRoles(config('roles.const.ADMIN'));
|
||||
|
||||
/** @var \App\User */
|
||||
/** @var \App\Models\User */
|
||||
$userPourRemplacer = User::whereId($request->created_by)->firstOrFail();
|
||||
|
||||
try {
|
||||
|
|
@ -276,8 +276,7 @@ class UserController extends Controller
|
|||
$media->owner()->associate($userPourRemplacer);
|
||||
$media->saveOrFail();
|
||||
});
|
||||
// TODO: use deleteOrFail after upgrate to laravel 8.
|
||||
if ($user->delete()) {
|
||||
if ($user->deleteOrFail()) {
|
||||
session()->flash('success', trans('L\'utilisateur à été supprimé'));
|
||||
return redirect(route('user.index'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,13 @@ class Kernel extends HttpKernel
|
|||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
\App\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
|
|
@ -24,22 +27,22 @@ class Kernel extends HttpKernel
|
|||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
'throttle:api',
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
@ -48,33 +51,18 @@ class Kernel extends HttpKernel
|
|||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The priority-sorted list of middleware.
|
||||
*
|
||||
* This forces non-global middleware to always be in the given order.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewarePriority = [
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\Authenticate::class,
|
||||
\Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\Illuminate\Auth\Middleware\Authorize::class,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ class Authenticate extends Middleware
|
|||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string|null
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
|
@ -9,9 +9,7 @@ class EncryptCookies extends Middleware
|
|||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
|
|||
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
|
|
@ -10,15 +12,19 @@ class RedirectIfAuthenticated
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @param string|null ...$guards
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/');
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ class TrimStrings extends Middleware
|
|||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
|
|
|||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts()
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,22 +2,26 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies = '*';
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
protected $headers = Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,10 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
|||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $addHttpCookie = true;
|
||||
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
protected $except = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace App\Http\Requests;
|
|||
|
||||
use App\Rules\HasMinimumRole;
|
||||
use App\Rules\IsValidRole;
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DestroyUserRequest extends FormRequest
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Traits;
|
||||
|
||||
use Elasticquent\ElasticquentTrait;
|
||||
|
||||
trait ElasticTrait {
|
||||
|
||||
trait ElasticTrait
|
||||
{
|
||||
use ElasticquentTrait;
|
||||
|
||||
/**
|
||||
|
|
@ -11,16 +13,15 @@ trait ElasticTrait {
|
|||
*
|
||||
* Does this index exist?
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public static function indexExists()
|
||||
{
|
||||
$instance = new static;
|
||||
$client = $instance->getElasticSearchClient();
|
||||
$index = array(
|
||||
$instance = new static();
|
||||
$client = $instance->getElasticSearchClient();
|
||||
$index = array(
|
||||
'index' => $instance->getIndexName(),
|
||||
);
|
||||
return $client->indices()->exists($index);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,191 +1,239 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Traits;
|
||||
|
||||
use App\Models\Format;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
trait MediaTools {
|
||||
trait MediaTools
|
||||
{
|
||||
public function getFileSize($file_path)
|
||||
{
|
||||
return $this->fixIntegerOverflow(filesize($file_path));
|
||||
}
|
||||
|
||||
public function get_file_size($file_path) {
|
||||
return $this->fix_integer_overflow(filesize($file_path));
|
||||
}
|
||||
/**
|
||||
* Create thumbnail image for a Media
|
||||
*
|
||||
* @param Media $media
|
||||
* @return void
|
||||
* @throws \ImagickException On errors.
|
||||
*/
|
||||
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 = \floatval($format->largeur);
|
||||
if (\floatval($format->hauteur) == 0) {
|
||||
$targetHeight = \floatval(floor(($media->hauteur * $format->largeur) / $media->largeur));
|
||||
} else {
|
||||
$targetHeight = \floatval($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);
|
||||
}
|
||||
/**
|
||||
* Create Sys thumbnail image for a Media.
|
||||
*
|
||||
* @param \App\Models\Media $media
|
||||
* @return void
|
||||
* @throws \ImagickException On errors.
|
||||
*/
|
||||
public function createSysThumb(Media $media)
|
||||
{
|
||||
$mediaPath = public_path("/{$media->folder}{$media->uid}.{$media->extension}");
|
||||
$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 {
|
||||
/** @var string */
|
||||
$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){
|
||||
$im->transformImageColorspace(\Imagick::COLORSPACE_RGB);
|
||||
}
|
||||
*/
|
||||
|
||||
/* Handle CMJN - DOESN'T WORK
|
||||
if ($im->getImageColorspace() === \Imagick::COLORSPACE_CMYK){
|
||||
$im->transformImageColorspace(\Imagick::COLORSPACE_RGB);
|
||||
}*/
|
||||
|
||||
// create preview
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'preview')->first();
|
||||
$fp = public_path()."/".$media->folder.$media->uid.'_preview.'.$extension;
|
||||
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 preview
|
||||
/** @var \App\Models\Format $format */
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')
|
||||
->where('libelle', '=', 'preview')->firstOrFail();
|
||||
$fp = public_path("/{$media->folder}{$media->uid}_preview.{$extension}");
|
||||
if ($media->extension == "gif") {
|
||||
if ($media->largeur >= $format->largeur || $media->hauteur >= $format->hauteur || $media->largeur == "") {
|
||||
$im = $im->coalesceImages();
|
||||
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
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('libelle', '=', 'thumb')->first();
|
||||
if ($extension != "png"){
|
||||
// * create thumb
|
||||
/** @var \App\Models\Format $format */
|
||||
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')
|
||||
->where('libelle', '=', 'thumb')->firstOrFail();
|
||||
if ($extension != "png") {
|
||||
$im->setImageBackgroundColor('#ffffff');
|
||||
$im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE);
|
||||
$im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
|
||||
$im->stripImage();
|
||||
}
|
||||
$fp = public_path()."/".$media->folder.$media->uid.'_thumb.'.$extension;
|
||||
$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 = "";
|
||||
/**
|
||||
* Returns the media folder path name
|
||||
*
|
||||
* @return string
|
||||
* @throws \ErrorException If creating the folder fails.
|
||||
*/
|
||||
public function getMediaFolder(): string
|
||||
{
|
||||
$mediaPath = "medias/";
|
||||
$directories = Storage::allDirectories($mediaPath);
|
||||
$selectedFolder = "";
|
||||
|
||||
// on obtient le dernier dossier créé
|
||||
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éé
|
||||
/** @var string $foldername */
|
||||
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();
|
||||
if (!Storage::makeDirectory($selectedFolder)) {
|
||||
throw new \ErrorException("Could not create $selectedFolder");
|
||||
}
|
||||
} else {
|
||||
// * on compte le nombre de fichier
|
||||
$files = Storage::allFiles($selectedFolder);
|
||||
// * si on en a plus de 1000, on créé un nouveau dossier
|
||||
if (count($files) > 1000) {
|
||||
$selectedFolder = $mediaPath . uniqid();
|
||||
if (!Storage::makeDirectory($selectedFolder)) {
|
||||
throw new \ErrorException("Could not create $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');
|
||||
/**
|
||||
* Convert file size to human readable string
|
||||
*
|
||||
* @param integer $octet
|
||||
* @param integer $precision
|
||||
* @return string
|
||||
*/
|
||||
public function formatBytes(int $octet, int $precision = 2): string
|
||||
{
|
||||
// * Array contenant les differents unités
|
||||
$unite = array('octet', 'Ko', 'Mo', 'Go');
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (true) {
|
||||
// * octet
|
||||
case $octet < 1000:
|
||||
return $octet . $unite[0];
|
||||
// * ko
|
||||
case $octet < 1000000:
|
||||
return $octet . $unite[1];
|
||||
// * Mo ou Go
|
||||
default:
|
||||
if ($octet < 1000000000) {
|
||||
// * Mo
|
||||
$mo = round($octet / (1024 * 1024), $precision);
|
||||
return $mo . $unite[2];
|
||||
} else {
|
||||
// * Go
|
||||
$go = round($octet / (1024 * 1024 * 1024), $precision);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives (not found)',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -120,7 +120,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
'File %s could not be moved to archives',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
/**
|
||||
* Get the concerned disk
|
||||
*
|
||||
* @return Filesystem
|
||||
* @return \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
protected function getDisk(): Filesystem
|
||||
{
|
||||
|
|
@ -164,38 +164,38 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
/**
|
||||
* Logs data
|
||||
*
|
||||
* @param string $message
|
||||
* @param LogType $logtype
|
||||
* @param string $message
|
||||
* @param LogType|null $logtype
|
||||
* @return void
|
||||
* @throws \ErrorException If logtype is not handled.
|
||||
*/
|
||||
protected function log(string $message, LogType $logtype = null): void
|
||||
{
|
||||
if (!$logtype) {
|
||||
$logtype = LogType::debug();
|
||||
$logtype = LogType::debug;
|
||||
}
|
||||
$message = sprintf('%s : %s', get_class($this), $message);
|
||||
switch ($logtype->value) {
|
||||
case LogType::debug()->value:
|
||||
switch ($logtype) {
|
||||
case LogType::debug:
|
||||
Log::debug($message);
|
||||
break;
|
||||
case LogType::info()->value:
|
||||
case LogType::info:
|
||||
Log::info($message);
|
||||
break;
|
||||
case LogType::log()->value:
|
||||
case LogType::log:
|
||||
Log::log($message);
|
||||
break;
|
||||
case LogType::warning()->value:
|
||||
case LogType::warning:
|
||||
Log::warning($message);
|
||||
break;
|
||||
case LogType::error()->value:
|
||||
case LogType::error:
|
||||
Log::error($message);
|
||||
break;
|
||||
case LogType::critical()->value:
|
||||
case LogType::critical:
|
||||
Log::critical($message);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->name));
|
||||
} //end switch
|
||||
$this->consolePrint($message, $logtype);
|
||||
}
|
||||
|
|
@ -212,21 +212,21 @@ abstract class XArcadiaFlux implements ShouldQueue
|
|||
{
|
||||
$this->clearProgressBarFromLine();
|
||||
if ($this->console) {
|
||||
switch ($logtype->value) {
|
||||
case LogType::debug()->value:
|
||||
case LogType::info()->value:
|
||||
case LogType::log()->value:
|
||||
switch ($logtype) {
|
||||
case LogType::debug:
|
||||
case LogType::info:
|
||||
case LogType::log:
|
||||
$this->console->info($message);
|
||||
break;
|
||||
case LogType::warning()->value:
|
||||
case LogType::warning:
|
||||
$this->console->comment($message);
|
||||
break;
|
||||
case LogType::error()->value:
|
||||
case LogType::critical()->value:
|
||||
case LogType::error:
|
||||
case LogType::critical:
|
||||
$this->console->error($message);
|
||||
break;
|
||||
default:
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->label));
|
||||
throw new \ErrorException(sprintf('%s : unhandled log type %s', get_class($this), $logtype->name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Jobs\Arcadia;
|
|||
|
||||
use App\Exceptions\AbortXmlImportException;
|
||||
use App\Exceptions\ElasticSearchException;
|
||||
use App\Lib\Utils;
|
||||
use App\Models\ArcadiaLink;
|
||||
use App\Models\Media;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
|
@ -137,10 +136,7 @@ class XmlArcadiaMediasIn extends XmlJobs
|
|||
__LINE__,
|
||||
$e
|
||||
);
|
||||
// ! Someting went wrong
|
||||
report($report);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($report);
|
||||
throw new AbortXmlImportException($report->getMessage());
|
||||
} //end try
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace App\Jobs\Arcadia;
|
|||
use App\Enums\LogType;
|
||||
use App\Exceptions\AbortXmlImportException;
|
||||
use App\Exceptions\InvalidXmlException;
|
||||
use App\Lib\Utils;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -78,7 +78,6 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
callable $saveCallback = null,
|
||||
callable $afterSaveCallback = null
|
||||
): void {
|
||||
/** @var Filesystem */
|
||||
$disk = $this->getDisk();
|
||||
$this->log('Démarrage du traitement');
|
||||
|
||||
|
|
@ -86,7 +85,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
|
||||
$files = $disk->files();
|
||||
|
||||
$total = count(array_filter($files, function ($filename) {
|
||||
$total = count(array_filter($files, function (string $filename) {
|
||||
if ($this->fileHasToBeIgnored($filename)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -95,6 +94,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
|
||||
$this->startProgressBar($total);
|
||||
|
||||
/** @var string $filename */
|
||||
foreach ($files as $filename) {
|
||||
if ($this->fileHasToBeIgnored($filename)) {
|
||||
continue;
|
||||
|
|
@ -121,7 +121,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
throw new InvalidXmlException('XML is Invalid (simplexml_load_string returned false)');
|
||||
}
|
||||
} catch (\ErrorException $e) {
|
||||
throw new InvalidXmlException('XML is Invalid', 0, $e);
|
||||
throw new InvalidXmlException('XML is Invalid', 0, 1, __FILE__, __LINE__, $e);
|
||||
}
|
||||
|
||||
$data = $this->extract($xmlContent);
|
||||
|
|
@ -176,7 +176,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$message,
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::critical()
|
||||
LogType::critical
|
||||
);
|
||||
$this->sendInvalidXmlEmail($filename, $e);
|
||||
$this->moveToInvalid($filename);
|
||||
|
|
@ -189,18 +189,14 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$e->getMessage(),
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::error()
|
||||
LogType::error
|
||||
);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
// * ignore the file
|
||||
} catch (QueryException $e) {
|
||||
$this->log(implode(' ', $e->errorInfo), LogType::critical());
|
||||
$this->log(implode(' ', $e->errorInfo), LogType::critical);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
} catch (FileNotFoundException $e) {
|
||||
// This happens because of concurent xml jobs read.
|
||||
|
|
@ -212,7 +208,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$message,
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::debug()
|
||||
LogType::debug
|
||||
);
|
||||
continue;
|
||||
// * ignore the file
|
||||
|
|
@ -224,11 +220,9 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$e->getMessage(),
|
||||
$e->getLine()
|
||||
),
|
||||
LogType::critical()
|
||||
LogType::critical
|
||||
);
|
||||
report($e);
|
||||
// ! TODO: Remove this after adding kwaadpepper/exception-handler.
|
||||
Utils::sendEmailErrorManually($e);
|
||||
continue;
|
||||
// * ignore the file
|
||||
} //end try
|
||||
|
|
@ -387,7 +381,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
),
|
||||
'filename' => $filename,
|
||||
'exception' => $e->getPrevious()
|
||||
], function ($m) {
|
||||
], function (Message $m) {
|
||||
$m->to(
|
||||
config('mail.contactsList.invalidXml'),
|
||||
'XML Exception Handler'
|
||||
|
|
@ -409,7 +403,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
'File %s could not be moved to invalid folder name',
|
||||
$filename
|
||||
),
|
||||
LogType::warning()
|
||||
LogType::warning
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Some utilities methods
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* Manually send an exception to team instead of going trough the error handler
|
||||
* (requires package kwaadpepper/exception-handler)
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
public static function sendEmailErrorManually(\Throwable $e)
|
||||
{
|
||||
Mail::send([
|
||||
'html' => 'exception-handler.exception',
|
||||
'text' => 'exception-handler.exception-plain'
|
||||
], [
|
||||
'appName' => config('app.name'),
|
||||
'code' => $e->getCode(),
|
||||
'line' => $e->getLine(),
|
||||
'ename' => \get_class($e),
|
||||
'emessage' => self::getAnonymizedMessage($e->getMessage()),
|
||||
'file' => str_replace(\realpath(\sprintf('%s/../', \app_path())), '', $e->getFile()),
|
||||
'stackTrace' => self::getAnonymizedStackTrace($e),
|
||||
'uri' => app()->runningInConsole() ?
|
||||
'CONSOLE' : (
|
||||
(request() and request()->fullUrl()) ?
|
||||
request()->fullUrl() : 'none')
|
||||
], function ($m) {
|
||||
/** @var \Illuminate\Mail\Message $m */
|
||||
$m->to(
|
||||
config('mail.contactsList.serviceweb'),
|
||||
sprintf('%s Exception Handler', config('app.name'))
|
||||
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
|
||||
});
|
||||
Log::alert(sprintf('Envoie d\'une erreur par mail : %s', json_encode($e)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize at least Sql queries
|
||||
*
|
||||
* @param string $message
|
||||
* @return string
|
||||
*/
|
||||
private static function getAnonymizedMessage(string $message): string
|
||||
{
|
||||
$message = \preg_replace('/^(.*)( \(SQL:.*\))$/', '$1', $message) ?? $message;
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize stack trace
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return string
|
||||
*/
|
||||
private static function getAnonymizedStackTrace(\Throwable $e): string
|
||||
{
|
||||
$projectPath = \realpath(\sprintf('%s/../', \app_path()));
|
||||
$traceStack = $e->getTrace();
|
||||
$traceStr = '';
|
||||
$maxStackStage = 0;
|
||||
foreach ($traceStack as $stackStage => $stack) {
|
||||
$maxStackStage = $stackStage;
|
||||
$traceStr .= \sprintf(
|
||||
'#%s %s(%d): ',
|
||||
$stackStage,
|
||||
str_replace($projectPath, '', $stack['file'] ?? ''),
|
||||
$stack['line'] ?? ''
|
||||
);
|
||||
if (isset($stack['class'])) {
|
||||
$traceStr .= "{$stack['class']}->{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
} elseif (isset($stack['function'])) {
|
||||
$traceStr .= "{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
}
|
||||
}
|
||||
$maxStackStage++;
|
||||
$traceStr .= "#$maxStackStage {main}";
|
||||
return $traceStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Args
|
||||
*
|
||||
* @param array $stack
|
||||
* @return string
|
||||
*/
|
||||
private static function handleArgs(array $stack): string
|
||||
{
|
||||
$traceArgs = '';
|
||||
$argsCount = count($stack['args']);
|
||||
for ($i = 0; $i < $argsCount; $i++) {
|
||||
$type = \gettype($stack['args'][$i]);
|
||||
switch ($type) {
|
||||
case 'object':
|
||||
$traceArgs .= sprintf('Object(%s)', \get_class($stack['args'][$i]));
|
||||
break;
|
||||
case 'array':
|
||||
$traceArgs .= sprintf('Array(%d)', \count($stack['args'][$i]));
|
||||
break;
|
||||
case 'string':
|
||||
$traceArgs .= sprintf('String(%d)', \strlen($stack['args'][$i]));
|
||||
break;
|
||||
default:
|
||||
$traceArgs .= \gettype($stack['args'][$i]);
|
||||
}
|
||||
$traceArgs .= ($i !== ($argsCount - 1) ? ',' : '');
|
||||
}
|
||||
return $traceArgs;
|
||||
}
|
||||
}
|
||||
|
|
@ -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]);
|
||||
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ class ArcadiaLink extends Model
|
|||
*/
|
||||
public function getMediaUuidAttribute()
|
||||
{
|
||||
$m = Media::withTrashed()->find($this->media_id);
|
||||
return $m->uid;
|
||||
return optional(Media::withTrashed()->find($this->media_id))->uid;
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class FormatRestriction extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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\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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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\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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Http\Traits\ElasticTrait;
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Elasticquent\ElasticquentTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
|
@ -312,4 +312,19 @@ class Media extends Model
|
|||
{
|
||||
return $this->belongsToMany(Panier::class, 'paniers_medias', 'media_id', 'panier_id');
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Convert the model instance to an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_merge(parent::toArray(), [
|
||||
'created_at' => $this->created_at->formatLocalized('%Y-%m-%d %H:%M:%S'),
|
||||
'updated_at' => $this->updated_at->formatLocalized('%Y-%m-%d %H:%M:%S')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
|
|
|||
|
|
@ -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\User', 'id');
|
||||
}
|
||||
/**
|
||||
* Get the user that owns the recherche.
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User', 'id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Setting extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Site extends Model
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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\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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Dossier;
|
||||
use App\Models\Historique;
|
||||
use App\Models\Marque;
|
||||
use App\Models\Media;
|
||||
use App\Models\Panier;
|
||||
use App\Models\Recherche;
|
||||
use App\Models\Sujet;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory;
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,14 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
|
|
@ -23,16 +17,39 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
if($this->app->environment("prod")){
|
||||
\URL::forceScheme("https");
|
||||
}
|
||||
|
||||
if (config('app.env') !== 'local') {
|
||||
setlocale(LC_TIME, config('app.locale') . "_" . strtoupper(config('app.locale')) . '.utf8');
|
||||
// !!! Fuc**** Lab LDC exception OMG !!!
|
||||
if (!in_array(config('app.env'), ['local', 'testing'])) {
|
||||
URL::forceRootUrl(config('app.url'));
|
||||
\Illuminate\Pagination\AbstractPaginator::currentPathResolver(function () {
|
||||
/** @var \Illuminate\Routing\UrlGenerator $url */
|
||||
$url = app('url');
|
||||
return $url->current();
|
||||
});
|
||||
}
|
||||
|
||||
if (config('app.env') === 'local') {
|
||||
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
|
||||
// * LOCAL HTTPS FIX
|
||||
if (!in_array(config('app.env'), ['local', 'testing'])) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
// * HA PROXY FIX
|
||||
App::singleton('clientIp', function () {
|
||||
if (config('app.env') == 'local') {
|
||||
return request()->getClientIp();
|
||||
} else {
|
||||
return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
|
||||
}
|
||||
});
|
||||
// * LOCAL FORCE eg: for Carbon
|
||||
foreach ([\LC_TIME, \LC_MESSAGES, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY] as $category) {
|
||||
setlocale(
|
||||
// * remove numeric to prevent float seperator to breaking numeric transactions
|
||||
$category,
|
||||
\sprintf('%s_%s.UTF-8', config('app.locale'), \strtoupper(config('app.locale')))
|
||||
);
|
||||
}
|
||||
Carbon::setLocale(config('app.locale'));
|
||||
if (!app()->runningInConsole()) {
|
||||
// * FORCE BOOTSTRAP PAGINATOR (or custom if in front)
|
||||
Paginator::useBootstrap();
|
||||
}//end if
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
|
|
@ -10,11 +9,9 @@ class AuthServiceProvider extends ServiceProvider
|
|||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
protected $policies = [];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
|
|
@ -24,7 +21,5 @@ class AuthServiceProvider extends ServiceProvider
|
|||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Auth\Events\Registered;
|
||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
|
@ -12,7 +11,7 @@ class EventServiceProvider extends ServiceProvider
|
|||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
* @var array<class-string, array<int, class-string>>
|
||||
*/
|
||||
protected $listen = [
|
||||
Registered::class => [
|
||||
|
|
@ -21,14 +20,12 @@ class EventServiceProvider extends ServiceProvider
|
|||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
* Determine if events and listeners should be automatically discovered.
|
||||
*
|
||||
* @return void
|
||||
* @return boolean
|
||||
*/
|
||||
public function boot()
|
||||
public function shouldDiscoverEvents()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,19 +4,22 @@ namespace App\Providers;
|
|||
|
||||
use App\Models\Media;
|
||||
use App\Models\Panier;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
|
|
@ -25,6 +28,17 @@ class RouteServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->configureRateLimiting();
|
||||
|
||||
$this->routes(function () {
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
});
|
||||
|
||||
Route::bind('media', function ($value) {
|
||||
return Media::whereUid($value)->firstOrFail();
|
||||
});
|
||||
|
|
@ -32,47 +46,17 @@ class RouteServiceProvider extends ServiceProvider
|
|||
return Panier::where('uid', $value)
|
||||
->with('owner')->firstOrFail();
|
||||
});
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Scopes;
|
||||
|
||||
use Adldap\Query\Builder;
|
||||
|
|
@ -25,4 +26,4 @@ class OpenLdapScope implements ScopeInterface
|
|||
'givenName',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Scopes;
|
||||
|
||||
use Illuminate\Database\Eloquent\Scope;
|
||||
|
|
@ -10,12 +11,12 @@ class SystemScope implements Scope
|
|||
/**
|
||||
* Apply the scope to a given Eloquent query builder.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return void
|
||||
*/
|
||||
public function apply(Builder $builder, Model $model)
|
||||
{
|
||||
$builder->where('system', 0);
|
||||
$builder->where('system', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
artisan
2
artisan
|
|
@ -11,7 +11,7 @@ define('LARAVEL_START', microtime(true));
|
|||
| Composer provides a convenient, automatically generated class loader
|
||||
| for our application. We just need to utilize it! We'll require it
|
||||
| into the script here so that we do not have to worry about the
|
||||
| loading of any our classes "manually". Feels great to relax.
|
||||
| loading of any of our classes manually. It's great to relax.
|
||||
|
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -8,66 +8,72 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"php": "^8.1",
|
||||
"ext-json": "*",
|
||||
"adldap2/adldap2-laravel": "^6.0",
|
||||
"adldap2/adldap2-laravel": "^6.1.6",
|
||||
"elasticquent/elasticquent": "dev-master",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"guzzlehttp/guzzle": "^7.2",
|
||||
"james-heinrich/getid3": "^1.9",
|
||||
"kwaadpepper/enum": "^2.1",
|
||||
"laravel/framework": "5.8.*",
|
||||
"laravel/tinker": "^1.0",
|
||||
"laravelcollective/html": "^5.8",
|
||||
"slevomat/coding-standard": "^7.0"
|
||||
"kwaadpepper/exception-handler": "^0.0.8",
|
||||
"laravel/framework": "^9.2",
|
||||
"laravel/sanctum": "^2.14.1",
|
||||
"laravel/tinker": "^2.7",
|
||||
"laravel/ui": "^3.0",
|
||||
"laravelcollective/html": "^6.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.2",
|
||||
"beyondcode/laravel-dump-server": "^1.0",
|
||||
"filp/whoops": "^2.0",
|
||||
"fzaninotto/faker": "^1.4",
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/collision": "^2.0",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
"fakerphp/faker": "^1.9.1",
|
||||
"laravel/sail": "^1.0.1",
|
||||
"mockery/mockery": "^1.4.4",
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"phpunit/phpunit": "^9.5.10",
|
||||
"spatie/laravel-ignition": "^1.0",
|
||||
"slevomat/coding-standard": "^7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
},
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
]
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
]
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
|
|
|||
13268
composer.lock
generated
13268
composer.lock
generated
File diff suppressed because it is too large
Load diff
233
config/app.php
233
config/app.php
|
|
@ -1,122 +1,124 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
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' => 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'),
|
||||
|
||||
'asset_url' => env('ASSET_URL', null),
|
||||
'asset_url' => env('ASSET_URL'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 +126,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 +163,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,57 +181,22 @@ 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' => [
|
||||
'aliases' => Facade::defaultAliases()->merge([
|
||||
'Adldap' => Adldap\Laravel\Facades\Adldap::class,
|
||||
'Form' => Collective\Html\FormFacade::class,
|
||||
'Html' => Collective\Html\HtmlFacade::class,
|
||||
'Es' => Elasticquent\ElasticquentElasticsearchFacade::class
|
||||
])->toArray(),
|
||||
|
||||
'App' => Illuminate\Support\Facades\App::class,
|
||||
'Arr' => Illuminate\Support\Arr::class,
|
||||
'Artisan' => Illuminate\Support\Facades\Artisan::class,
|
||||
'Auth' => Illuminate\Support\Facades\Auth::class,
|
||||
'Blade' => Illuminate\Support\Facades\Blade::class,
|
||||
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
|
||||
'Bus' => Illuminate\Support\Facades\Bus::class,
|
||||
'Cache' => Illuminate\Support\Facades\Cache::class,
|
||||
'Config' => Illuminate\Support\Facades\Config::class,
|
||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||
'Password' => Illuminate\Support\Facades\Password::class,
|
||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||
'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
'Request' => Illuminate\Support\Facades\Request::class,
|
||||
'Response' => Illuminate\Support\Facades\Response::class,
|
||||
'Route' => Illuminate\Support\Facades\Route::class,
|
||||
'Schema' => Illuminate\Support\Facades\Schema::class,
|
||||
'Session' => Illuminate\Support\Facades\Session::class,
|
||||
'Storage' => Illuminate\Support\Facades\Storage::class,
|
||||
'Str' => Illuminate\Support\Str::class,
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'Adldap' => Adldap\Laravel\Facades\Adldap::class,
|
||||
'Form' => Collective\Html\FormFacade::class,
|
||||
'Html' => Collective\Html\HtmlFacade::class,
|
||||
'Es' => Elasticquent\ElasticquentElasticsearchFacade::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
122
config/auth.php
122
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' => [
|
||||
|
|
@ -40,56 +40,50 @@ return [
|
|||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'driver' => 'token',
|
||||
'provider' => 'users',
|
||||
'hash' => false,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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: "database", "eloquent"
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => [
|
||||
'users' => [
|
||||
'driver' => 'ldap',
|
||||
'model' => App\User::class,
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// '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 the reset token should 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' => [
|
||||
|
|
@ -97,7 +91,21 @@ return [
|
|||
'provider' => 'users',
|
||||
'table' => 'password_resets',
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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,
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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", "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' => [
|
||||
|
|
@ -37,8 +37,16 @@ return [
|
|||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'encrypted' => true,
|
||||
'useTLS' => true,
|
||||
],
|
||||
'client_options' => [
|
||||
// * Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html
|
||||
],
|
||||
],
|
||||
|
||||
'ably' => [
|
||||
'driver' => 'ably',
|
||||
'key' => env('ABLY_KEY'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
|
|
|
|||
|
|
@ -5,36 +5,37 @@ 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.
|
||||
|
|
||||
| Supported: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb"
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| 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.
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => [
|
||||
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
'serialize' => false
|
||||
],
|
||||
|
||||
'array' => [
|
||||
|
|
@ -45,6 +46,7 @@ return [
|
|||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
|
|
@ -84,19 +86,23 @@ return [
|
|||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 the APC, database, memcached, Redis, or DynamoDB cache
|
||||
| stores there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'),
|
||||
|
||||
];
|
||||
|
|
|
|||
34
config/cors.php
Normal file
34
config/cors.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
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
|
||||
|
|
||||
*/
|
||||
|
||||
'paths' => ['api/*', 'sanctum/csrf-cookie'],
|
||||
|
||||
'allowed_methods' => ['*'],
|
||||
|
||||
'allowed_origins' => ['*'],
|
||||
|
||||
'allowed_origins_patterns' => [],
|
||||
|
||||
'allowed_headers' => ['*'],
|
||||
|
||||
'exposed_headers' => [],
|
||||
|
||||
'max_age' => 0,
|
||||
|
||||
'supports_credentials' => false,
|
||||
|
||||
];
|
||||
|
|
@ -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' => [
|
||||
|
|
@ -69,7 +69,7 @@ return [
|
|||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'schema' => 'public',
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
|
|
@ -83,54 +83,58 @@ return [
|
|||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'predis'),
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'predis'),
|
||||
'cluster' => env('REDIS_CLUSTER', 'phpredis'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_DB', 0),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'password' => env('REDIS_PASSWORD', null),
|
||||
'port' => env('REDIS_PORT', 6379),
|
||||
'database' => env('REDIS_CACHE_DB', 1),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
17
config/exception-handler.php
Normal file
17
config/exception-handler.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
/**
|
||||
* Send mail when app debug is turn off
|
||||
* so you can be warned if an unhandled exception occurs
|
||||
*/
|
||||
'enableMaiLog' => !config('app.debug'),
|
||||
|
||||
/**
|
||||
* Put a developper secured mailbox in here
|
||||
* so you can receive email if things go mad
|
||||
*/
|
||||
'contactsList' => [
|
||||
env('MAIL_LIST_SERVICEWEB', 'equipe.web@ldc.fr')
|
||||
]
|
||||
];
|
||||
|
|
@ -3,42 +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'),
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cloud Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Many applications store files both locally and in the cloud. For this
|
||||
| reason, you may specify a default "cloud" driver here. This driver
|
||||
| will be bound as the Cloud disk implementation in the container.
|
||||
|
|
||||
*/
|
||||
|
||||
'cloud' => env('FILESYSTEM_CLOUD', '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", "rackspace"
|
||||
|
|
||||
|--------------------------------------------------------------------------
|
||||
| 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 set up for each driver as an example of the required values.
|
||||
|
|
||||
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
|
@ -46,27 +33,32 @@ return [
|
|||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => public_path(),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'arcadia' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('export_arcadia'),
|
||||
],
|
||||
'arcadia' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('export_arcadia'),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
'arcadia_link_s' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/send'),
|
||||
'throw' => true,
|
||||
],
|
||||
'arcadia_link_r' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('arcadia_link/receive'),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
|
|
@ -75,9 +67,26 @@ return [
|
|||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => true,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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,20 +33,20 @@ 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' => [
|
||||
'memory' => 1024,
|
||||
'threads' => 2,
|
||||
'time' => 2,
|
||||
'memory' => 65536,
|
||||
'threads' => 1,
|
||||
'time' => 4,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
306
config/ldap.php
306
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),
|
||||
|
|
|
|||
|
|
@ -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\User::class,
|
||||
'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' => [
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue