Compare commits
159 commits
fixunsubsc
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73eeec3e75 | ||
|
|
4890e1d55f | ||
|
|
7115c777ca | ||
|
|
cfff5d676d | ||
|
|
6b86c4f4bc | ||
|
|
bae249c704 | ||
|
|
ae78359251 | ||
|
|
1f34c77256 | ||
|
|
49a02d3e2d | ||
|
|
78e388c9df | ||
|
|
62cd74f250 | ||
|
|
fccb7cd3f6 | ||
|
|
c4f3ae1929 | ||
|
|
b106e9ac67 | ||
|
|
43837f3937 | ||
|
|
aca7083436 | ||
|
|
2689ec1bfc | ||
|
|
6b234cd0cc | ||
|
|
e24bfaf301 | ||
|
|
a5bd28fb69 | ||
|
|
7ca36a0913 | ||
|
|
bca4fa327a | ||
|
|
43b63c8da1 | ||
|
|
a9af7cfe7a | ||
|
|
73e4dc877e | ||
|
|
370019285d | ||
|
|
512009cbe9 | ||
|
|
a0f663bdd9 | ||
|
|
fdde79d369 | ||
|
|
a0b9d408d2 | ||
|
|
1b177d78f6 | ||
|
|
7d89800ca8 | ||
|
|
e2189efbbf | ||
|
|
7ac5a22c9b | ||
|
|
d2ce6edec5 | ||
|
|
00b4e85525 | ||
|
|
7072c92832 | ||
|
|
88af03ceb0 | ||
|
|
9074b02916 | ||
|
|
ecbf1a8837 | ||
|
|
1c0d7bae5e | ||
|
|
c9ba12c99d | ||
|
|
0d61ee8295 | ||
|
|
cb0fa25557 | ||
|
|
0d8b4543e5 | ||
|
|
859b1f3625 | ||
|
|
00865f4eff | ||
|
|
8ab156452f | ||
|
|
e8eefa158a | ||
|
|
0dc4021a18 | ||
|
|
f01db43447 | ||
|
|
37c3e78dc8 | ||
|
|
25c4905d99 | ||
|
|
05de5830f8 | ||
|
|
7d55cf7a39 | ||
|
|
f9e68f6ad6 | ||
|
|
d5f12af30d | ||
|
|
88db8dd345 | ||
|
|
6144d02a76 | ||
|
|
ca36cf55ac | ||
|
|
abb52d7d82 | ||
|
|
862fe3725c | ||
|
|
109199f0a4 | ||
|
|
1856c267c1 | ||
|
|
a3e4c1d08a | ||
|
|
3dbfbe940f | ||
|
|
979a1cf613 | ||
|
|
c0d8fdb73f | ||
|
|
8fd8ccd17d | ||
|
|
901b3c263d | ||
|
|
33cf96b21f | ||
|
|
58bbdafe43 | ||
|
|
94f9e1fd32 | ||
|
|
e0d33a9c2b | ||
|
|
765f9a06df | ||
|
|
1dc9c3e4d1 | ||
|
|
47672f1745 | ||
|
|
74aa0de294 | ||
|
|
a57525226f | ||
|
|
e4656628f7 | ||
|
|
fd8680c327 | ||
|
|
550c035248 | ||
|
|
3f24dc5b06 | ||
|
|
00c8d872c2 | ||
|
|
552cd2616a | ||
|
|
82cefd1c4c | ||
|
|
718bfc11eb | ||
|
|
b6d081ec26 | ||
|
|
81b2bed386 | ||
|
|
451a69151f | ||
|
|
88520498fb | ||
|
|
d4db7c57e6 | ||
|
|
dd13b99968 | ||
|
|
1704708902 | ||
|
|
fe928b1d80 | ||
|
|
61783b8e28 | ||
|
|
993d1358a6 | ||
|
|
7d956a54df | ||
|
|
0eb3b011a3 | ||
|
|
a3ecba6625 | ||
|
|
56fba36df2 | ||
|
|
5014f9196f | ||
|
|
52dbb15a3f | ||
|
|
b796e93d91 | ||
|
|
e793ce664e | ||
|
|
bdb44ab3a7 | ||
|
|
f37200aedf | ||
|
|
cb77f9bb14 | ||
|
|
29d818b5f0 | ||
|
|
d352ae64f1 | ||
|
|
785a6db60f | ||
|
|
2c26ecb874 | ||
|
|
48e2383b5f | ||
|
|
7e99d60b71 | ||
|
|
1bbb8c0f57 | ||
|
|
cb06b8f524 | ||
|
|
b7f38e80ff | ||
|
|
9f85fe88f4 | ||
|
|
abb4372bbe | ||
|
|
c8bd9cfd50 | ||
|
|
cf2a9f2a67 | ||
|
|
03e091db3e | ||
|
|
8dc0042e73 | ||
|
|
2e2df92132 | ||
|
|
9221d331dc | ||
|
|
9b700e7523 | ||
|
|
bb6e498b81 | ||
|
|
cba567ee46 | ||
|
|
98d8640219 | ||
|
|
7ac045500f | ||
|
|
ca208acec7 | ||
|
|
9e80217468 | ||
|
|
43b830b00e | ||
|
|
ac1931b61f | ||
|
|
b817cef0ef | ||
|
|
453f8009b3 | ||
|
|
819d964c15 | ||
|
|
b47aaeaf45 | ||
|
|
a7cda14ed7 | ||
|
|
fc0fbf0167 | ||
|
|
3a7a38d9fb | ||
|
|
bc6193ed99 | ||
|
|
191b83780a | ||
|
|
d6b3cb767e | ||
|
|
fcc2e101d9 | ||
|
|
b46aa0b60e | ||
|
|
a0daf14737 | ||
|
|
96d95c1e97 | ||
|
|
7d768bda93 | ||
|
|
e725547206 | ||
|
|
ac3e5ef369 | ||
|
|
6084c1e7e8 | ||
|
|
c346fb350b | ||
|
|
d74b808fda | ||
|
|
c4e5a9c466 | ||
|
|
9e460153d6 | ||
|
|
2eea3e3ef5 | ||
|
|
aa4de0d001 | ||
|
|
642316cb5b |
267 changed files with 17133 additions and 7374 deletions
25
.env.example
25
.env.example
|
|
@ -21,6 +21,13 @@ DB_DATABASE_2016=legaulois2016
|
|||
DB_USERNAME_2016=
|
||||
DB_PASSWORD_2016=
|
||||
|
||||
## DATABASE OPINSTA
|
||||
DB_DATABASE_OPINSTA=
|
||||
DB_USERNAME_OPINSTA=
|
||||
DB_PASSWORD_OPINSTA=
|
||||
DB_HOST_OPINSTA=
|
||||
DB_PORT_OPINSTA=
|
||||
|
||||
## MIGRATION
|
||||
MIGRATIONPAGINATION=20000
|
||||
|
||||
|
|
@ -42,10 +49,12 @@ MAIL_FROM_ADDRESS=no-reply@legaulois.fr
|
|||
MAIL_FROM_NAME="Contact Le Gaulois (legaulois.fr)"
|
||||
|
||||
## MAIL ADDRESSES
|
||||
MAIL_LIST_SERVICEWEB=informatique.internet@ldc.fr
|
||||
MAIL_LIST_CONTACT=contact@legaulois.fr
|
||||
MAIL_LIST_PASSERELLE=passerelle.ldc@ldc.fr
|
||||
|
||||
# Sentry
|
||||
SENTRY_LARAVEL_DSN=
|
||||
|
||||
## ARCHADIA
|
||||
BOUTIQUE_ARCHADIA_OP_CODE=16
|
||||
|
||||
|
|
@ -68,6 +77,14 @@ MESBR_COUPON_3_CHARCUT=""
|
|||
ANALYTICS_GOOGLE_ID=
|
||||
GOOGLE_MAP_API_KEY=
|
||||
|
||||
# Google Recaptcha
|
||||
GOOGLE_RECAPTCHA_PUBLIC=
|
||||
GOOGLE_RECAPTCHA_PRIVATE=
|
||||
GOOGLE_RECAPTCHA_VERSION=
|
||||
|
||||
# Matomo
|
||||
MATOMO_SITE_ID=
|
||||
|
||||
## MERCANET
|
||||
MERCANET_SECRET=
|
||||
MERCANET_MERCHAND_ID=
|
||||
|
|
@ -75,3 +92,9 @@ MERCANET_ENV=
|
|||
|
||||
# BYPASS THE CRM JUST LOGIN (needs debug mode)
|
||||
NOCRM=false
|
||||
|
||||
#OP INSTA
|
||||
## Démarre le à d-m-YYYY
|
||||
OPINSTA_START=
|
||||
## Fin le à d-m-YYYY
|
||||
OPINSTA_END=
|
||||
|
|
|
|||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -28,3 +28,5 @@ yarn-error.log
|
|||
mix-manifest.json
|
||||
workspace.code-workspace
|
||||
storage/crm_migration.csv
|
||||
auth.json
|
||||
.npmrc
|
||||
|
|
@ -1,45 +1,11 @@
|
|||
image: $CI_REGISTRY/service-web-lab/ldc-web-images-docker/ldcweb-qa:php7.3-1.0
|
||||
include:
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'lint/lint7.3.yml'
|
||||
- project: 'ldc-web/shared-ci'
|
||||
ref: 'main'
|
||||
file: 'security/security7.3.yml'
|
||||
|
||||
stages:
|
||||
- Security
|
||||
- CodingStandards
|
||||
|
||||
composer-security:
|
||||
stage: Security
|
||||
script:
|
||||
- local-php-security-checker --format=json --path=./composer.lock > composer-security-checker-report.json
|
||||
artifacts:
|
||||
when: on_failure
|
||||
expose_as: 'composer-security-checker'
|
||||
paths:
|
||||
- composer-security-checker-report.json
|
||||
allow_failure: true
|
||||
|
||||
npm-security:
|
||||
stage: Security
|
||||
script:
|
||||
- audit-ci -p npm -o json > npm-security-checker-report.json
|
||||
artifacts:
|
||||
when: on_failure
|
||||
expose_as: 'npm-security-checker'
|
||||
paths:
|
||||
- npm-security-checker-report.json
|
||||
allow_failure: true
|
||||
|
||||
phpcs:
|
||||
stage: CodingStandards
|
||||
before_script:
|
||||
- composer install
|
||||
cache:
|
||||
paths:
|
||||
- vendor/
|
||||
script:
|
||||
- vendor/bin/phpcs --report=junit --report-file=phpcs-report.xml
|
||||
artifacts:
|
||||
when: on_failure
|
||||
expose_as: 'phpcs'
|
||||
paths:
|
||||
- phpcs-report.xml
|
||||
reports:
|
||||
junit: phpcs-report.xml
|
||||
allow_failure: false
|
||||
- lint
|
||||
- security
|
||||
|
|
|
|||
11
.gitlab/issue_templates/bug.md
Normal file
11
.gitlab/issue_templates/bug.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
## Comportement constaté
|
||||
|
||||
|
||||
## Comportement attendu
|
||||
|
||||
|
||||
## Solution envisagée
|
||||
|
||||
|
||||
## Étapes pour la reproduction du bug
|
||||
*
|
||||
7
.gitlab/issue_templates/feature.md
Normal file
7
.gitlab/issue_templates/feature.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
## Présentation du besoin
|
||||
|
||||
|
||||
## Implémentation
|
||||
|
||||
|
||||
## Maquettes, documentations...
|
||||
|
|
@ -24,7 +24,7 @@ class XmlTracaReader extends Command
|
|||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return integer
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use App\Jobs\DeleteOldNotifications;
|
|||
use App\Jobs\DeleteOrders;
|
||||
use App\Jobs\PurgeNotifications as JobsPurgeNotifications;
|
||||
use App\Jobs\PurgeOldResetPasswords;
|
||||
use App\Jobs\SendOcbMissingBreederReminder;
|
||||
use App\Jobs\UpdateReductions as JobsUpdateReductions;
|
||||
use App\Jobs\XmlEleveursReader as JobsXmlEleveursReader;
|
||||
use App\Jobs\XmlIncoReader as JobsXmlIncoReader;
|
||||
|
|
@ -52,16 +51,19 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//$schedule->job(SendOcbMissingBreederReminder::class)->onOneServer()->dailyAt('07:30');
|
||||
// $schedule->job(SendOcbMissingBreederReminder::class)->dailyAt('07:30');
|
||||
$schedule->job(DeleteOrders::class)->dailyAt('14:00');
|
||||
$schedule->job(DeleteOldMessages::class)->dailyAt('14:15');
|
||||
$schedule->job(DeleteOldNotifications::class)->dailyAt('14:30');
|
||||
$schedule->job(JobsUpdateReductions::class)->dailyAt('14:45');
|
||||
$schedule->job(JobsXmlIncoReader::class)->name('xml-inco-reader')->onOneServer()->dailyAt('15:00');
|
||||
$schedule->job(JobsXmlTracaReader::class)->name('xml-traca-reader')->onOneServer()->dailyAt('15:15');
|
||||
$schedule->job(JobsXmlEleveursReader::class)->name('xml-eleveurs-reader')->onOneServer()->dailyAt('15:30');
|
||||
$schedule->job(JobsXSCVMepReader::class)->name('csv-mep-reader')->onOneServer()->dailyAt('16:00');
|
||||
$schedule->job(JobsXmlIncoReader::class)->name('xml-inco-reader')->dailyAt('15:00');
|
||||
$schedule->job(JobsXmlTracaReader::class)->name('xml-traca-reader')->dailyAt('15:15');
|
||||
$schedule->job(JobsXmlEleveursReader::class)->name('xml-eleveurs-reader')->dailyAt('15:30');
|
||||
$schedule->job(JobsXSCVMepReader::class)->name('csv-mep-reader')->dailyAt('16:00');
|
||||
$schedule->job(JobsPurgeNotifications::class)->dailyAt('00:15');
|
||||
$schedule->job(PurgeOldResetPasswords::class)->dailyAt('00:25');
|
||||
|
||||
// * Remove Old traca
|
||||
$schedule->command('xml:clean_olds')->dailyAt('06:00');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class ArticleCategory extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class BreedingBlocType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -17,6 +22,11 @@ final class BreedingBlocType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class ContactFormCivility extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class ContactFormCivility extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -26,6 +36,11 @@ final class ContactFormCivility extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -14,19 +14,30 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class ContactFormType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'none' => 0,
|
||||
'abuse' => 1,
|
||||
// * special case passerelle
|
||||
'complain' => 3,
|
||||
// special case passerelle
|
||||
'recipe' => 5,
|
||||
'games' => 9,
|
||||
// * special case page nl
|
||||
'onepage' => 10,
|
||||
// special case page nl
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -39,6 +50,11 @@ final class ContactFormType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class Days extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -30,6 +35,11 @@ final class Days extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -44,6 +54,11 @@ final class Days extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
|
||||
abstract class Departaimant extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class DepartaimantCollectionType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class DepartaimantCollectionType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum label
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -26,6 +36,11 @@ final class DepartaimantCollectionType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Json serialize implementation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -107,6 +107,11 @@ namespace App\Enums;
|
|||
*/
|
||||
final class DepartaimantCurrent extends Departaimant
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -214,6 +219,11 @@ final class DepartaimantCurrent extends Departaimant
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum label
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class DepartaimantStatus extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -22,6 +27,11 @@ final class DepartaimantStatus extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -32,11 +42,21 @@ final class DepartaimantStatus extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* To Array
|
||||
*
|
||||
* @return \Kwaadpepper\Enum\BaseEnum[]
|
||||
*/
|
||||
public static function toArray(): array
|
||||
{
|
||||
$array = [];
|
||||
|
|
@ -49,6 +69,11 @@ final class DepartaimantStatus extends BaseEnumRoutable
|
|||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Json serialize implementation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ namespace App\Enums;
|
|||
*/
|
||||
final class DepartaimantVintage extends Departaimant
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -210,6 +215,11 @@ final class DepartaimantVintage extends Departaimant
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class EleveurOcbStatus extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -21,6 +26,12 @@ final class EleveurOcbStatus extends BaseEnumRoutable
|
|||
'yes' => 3
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -31,6 +42,11 @@ final class EleveurOcbStatus extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class EngagementBlocType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -24,6 +29,11 @@ final class EngagementBlocType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class EngagementType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class EngagementType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class GMapDataType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class GeneralConfigType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -22,6 +27,11 @@ final class GeneralConfigType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class GeoType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class GeoType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class InputType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class NotificationType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -24,6 +29,11 @@ final class NotificationType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class NutritionBlocType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -29,6 +34,11 @@ final class NutritionBlocType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class NutritionPageType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class NutritionPageType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -5,25 +5,32 @@ namespace App\Enums;
|
|||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* @method static self egg()
|
||||
* @method static self rabbit()
|
||||
* @method static self poultry()
|
||||
*/
|
||||
final class OCBType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'egg' => 0,
|
||||
'rabbit' => 1,
|
||||
'poultry' => 2
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
'egg' => __('Oeuf'),
|
||||
'rabbit' => __('Lapin'),
|
||||
'poultry' => __('Volaille')
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class OrderStatus extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -24,6 +29,11 @@ final class OrderStatus extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class OrderType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class OrderType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class PoultryBlocType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -20,6 +25,11 @@ final class PoultryBlocType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class PoultryPageType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class PoultryPageType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class PresentationType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class PresentationType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class RangeColor extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -35,6 +40,12 @@ final class RangeColor extends BaseEnumRoutable
|
|||
'color11' => 'color-11'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class RecipeDifficulty extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -22,6 +27,11 @@ final class RecipeDifficulty extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -32,6 +42,11 @@ final class RecipeDifficulty extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the value as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return (string)$this->label;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class RecipeFilter extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
$labels = self::labels();
|
||||
|
|
@ -24,6 +29,11 @@ final class RecipeFilter extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class RecipeFilterTimes extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
$labels = self::labels();
|
||||
|
|
@ -22,6 +27,11 @@ final class RecipeFilterTimes extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
|
|||
*/
|
||||
final class RecipeType extends BaseEnumRoutable
|
||||
{
|
||||
/**
|
||||
* Enum values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
|
|
@ -18,6 +23,11 @@ final class RecipeType extends BaseEnumRoutable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum labels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Exception;
|
|||
/**
|
||||
* This class Exception is used to skip a row import from
|
||||
* database migration (2016 -> 2020)
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class AbortContactMailer extends Exception
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Exception;
|
|||
/**
|
||||
* This class Exception is used to skip a row import from
|
||||
* database migration (2016 -> 2020)
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class AbortRowImportException extends Exception
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use Exception;
|
|||
/**
|
||||
* This class Exception is used in CB payement process
|
||||
* database migration (2016 -> 2020)
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class CBPayementError extends Exception
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
|
@ -29,9 +28,32 @@ class Handler extends ExceptionHandler
|
|||
'password_confirmation',
|
||||
];
|
||||
|
||||
public function render($request, Throwable $e)
|
||||
/**
|
||||
* register function
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// redirect to connection if user is in BO and session timeout
|
||||
$this->reportable(function (\Throwable $e) {
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* render function
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Throwable $e
|
||||
* @return void|\Symfony\Component\HttpFoundation\Response
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
*/
|
||||
public function render($request, \Throwable $e)
|
||||
{
|
||||
// phpcs:enable
|
||||
// Redirect to connection if user is in BO and session timeout.
|
||||
if ($request->is('bo', 'bo/*') and \get_class($e) === TokenMismatchException::class) {
|
||||
if (\in_array('GET', $request->route()->methods)) {
|
||||
return \redirect()->route($request->route()->getName());
|
||||
|
|
|
|||
9
app/Exceptions/InstaApiLimitReachedException.php
Normal file
9
app/Exceptions/InstaApiLimitReachedException.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InstaApiLimitReachedException extends Exception
|
||||
{
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use Exception;
|
|||
/**
|
||||
* This class Exception is used to skip a row import from
|
||||
* database migration (2016 -> 2020)
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@ldc.fr>
|
||||
*/
|
||||
class RedirectTo extends Exception
|
||||
|
|
|
|||
|
|
@ -5,26 +5,36 @@ namespace App\Http\Controllers;
|
|||
use App\Enums\GeneralConfigType;
|
||||
use App\Models\Actu;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ActuController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$tags = Tag::has('actus')->get();
|
||||
$actus = Actu::where('status', true)
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Tag> */
|
||||
$tags = Tag::query()->whereHas('actus', function (Builder $q) {
|
||||
$q->where('status', true);
|
||||
})->get();
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Actu> */
|
||||
$actus = Actu::query()->where('status', true)
|
||||
->with('tags:id')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get(['id'])
|
||||
->mapWithKeys(function ($actu) {
|
||||
->map(function ($actu) {
|
||||
return [
|
||||
$actu->id => [
|
||||
'id' => $actu->id,
|
||||
'tags' => $actu->tags->mapWithKeys(function ($tag) {
|
||||
return [$tag->id => $tag->id];
|
||||
})->all()
|
||||
]
|
||||
'id' => $actu->id,
|
||||
'tags' => $actu->tags->map(function ($tag) {
|
||||
return $tag->id;
|
||||
})->all()
|
||||
];
|
||||
})->all();
|
||||
|
||||
$generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null;
|
||||
$generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::actu())->first() : null;
|
||||
return view('front.actu.index', [
|
||||
|
|
@ -35,6 +45,12 @@ class ActuController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a news
|
||||
*
|
||||
* @param \App\Models\Actu $actu
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function view(Actu $actu)
|
||||
{
|
||||
$relatedActus = Actu::whereHas('tags', function ($q) use ($actu) {
|
||||
|
|
@ -50,6 +66,12 @@ class ActuController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a news for JS usage (ajax)
|
||||
*
|
||||
* @param \App\Models\Actu $actu
|
||||
* @return string Base64 rendered view.
|
||||
*/
|
||||
public function renderActu(Actu $actu)
|
||||
{
|
||||
if (!request()->wantsJson()) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ class AuthController extends Controller
|
|||
{
|
||||
/**
|
||||
* Affiche le formulaire utilise view share vars
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
|
|
@ -37,6 +39,9 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Enregistre le customer dans la base de données
|
||||
*
|
||||
* @param \App\Http\Requests\CustomerRegisterRequest $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function registerSubmit(CustomerRegisterRequest $request)
|
||||
{
|
||||
|
|
@ -76,13 +81,17 @@ class AuthController extends Controller
|
|||
if ($e->getApiError()->equals(ApiError::validationFailed())) {
|
||||
return back()->withErrors($e->getMessage());
|
||||
}
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} catch (ValidationException $e) {
|
||||
return back()->withErrors($e->getMessage());
|
||||
} catch (\Exception | \TypeError | CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM..
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} //end try
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
|
|
@ -90,6 +99,9 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Active le compte d'un customer
|
||||
*
|
||||
* @param string $hashcode
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function activate(string $hashcode)
|
||||
{
|
||||
|
|
@ -107,15 +119,22 @@ class AuthController extends Controller
|
|||
} catch (ApiErrorException $e) {
|
||||
if ($e->getApiError()->equals(ApiError::customerAlreadyActive())) {
|
||||
return view('front.auth.activate')
|
||||
->with('message', 'Votre compte est déjà activé, vous pouvez dès à présent vous connecter avec celui-ci.');
|
||||
->with(
|
||||
'message',
|
||||
'Votre compte est déjà activé, vous pouvez dès à présent vous connecter avec celui-ci.'
|
||||
);
|
||||
}
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return view('front.auth.activate')
|
||||
->with('message', 'Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} catch (CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return view('front.auth.activate')
|
||||
->with('message', 'Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} //end try
|
||||
|
|
@ -124,6 +143,9 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Retourne la page de connexion
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function authenticate(Request $request)
|
||||
{
|
||||
|
|
@ -136,6 +158,11 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Gère l'authentification des customers
|
||||
*
|
||||
* @param \App\Http\Requests\LoginRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws ValidationException ValidationException.
|
||||
* @throws ApiErrorException ApiErrorException.
|
||||
*/
|
||||
public function authenticateSubmit(LoginRequest $request)
|
||||
{
|
||||
|
|
@ -146,27 +173,27 @@ class AuthController extends Controller
|
|||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
$crm = app('crmAPI');
|
||||
|
||||
// If login debug mode
|
||||
// If login debug mode.
|
||||
if (config('app.debug') && config('crm.NOCRM')) {
|
||||
$loginIsValid = true;
|
||||
} else {
|
||||
$loginIsValid = $crm->login($request->email, $request->password);
|
||||
}
|
||||
|
||||
// ne devrait pas survenir, $crm->login throws ApiError::authFailed()
|
||||
// Ne devrait pas survenir, $crm->login throws ApiError::authFailed().
|
||||
if (!$loginIsValid) {
|
||||
// mauvais identifiants
|
||||
// Mauvais identifiants.
|
||||
return back()->withErrors("Email ou mot de passe incorrect.");
|
||||
}
|
||||
|
||||
// Dans tout les cas : récupérer le crm user pour vérifier si il doit être complété
|
||||
// Dans tout les cas : récupérer le crm user pour vérifier si il doit être complété.
|
||||
$crmCustomer = $crm->getCustomer($request->email);
|
||||
|
||||
// Test is user data valid ?
|
||||
try {
|
||||
// On va tester de mettre a jour uniquement les champs
|
||||
// requis pour mes br afin de detecter si ils doivent etre mis à jour
|
||||
// la validation va se faire par la crm (ou le client)
|
||||
// On va tester de mettre a jour uniquement les champs.
|
||||
// Requis pour mes br afin de detecter si ils doivent etre mis à jour.
|
||||
// La validation va se faire par la crm (ou le client).
|
||||
$crmCustomer->fill([
|
||||
'birth_date' => $crmCustomer->birth_date,
|
||||
'address' => $crmCustomer->address,
|
||||
|
|
@ -175,7 +202,7 @@ class AuthController extends Controller
|
|||
'city' => $crmCustomer->city
|
||||
]);
|
||||
|
||||
// On valide les données selon les critères du site LG
|
||||
// On valide les données selon les critères du site LG.
|
||||
$rules = collect((new UpdateInfosRequest())->rules());
|
||||
$validator = Validator::make(
|
||||
[
|
||||
|
|
@ -207,7 +234,7 @@ class AuthController extends Controller
|
|||
Session::push('needCrmInfoUpdate', true);
|
||||
} //end try
|
||||
|
||||
// Si pas de compte local mais existe en CRM
|
||||
// Si pas de compte local mais existe en CRM.
|
||||
if (!$customer) {
|
||||
$customer = $this->createLocalCustomer($crmCustomer);
|
||||
}
|
||||
|
|
@ -216,8 +243,10 @@ class AuthController extends Controller
|
|||
} catch (ApiErrorException $e) {
|
||||
return $this->handleLoginApiErrorException($e, $request);
|
||||
} catch (CrmException | \Exception $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} //end try
|
||||
}
|
||||
|
|
@ -225,9 +254,11 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Handle Api error exception
|
||||
*
|
||||
* @param ApiErrorException $e
|
||||
* @param LoginRequest $request
|
||||
* @return void
|
||||
* @param \LDC\LDCCRM\Exceptions\ApiErrorException $e
|
||||
* @param \App\Http\Requests\LoginRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Exception Exception.
|
||||
*/
|
||||
private function handleLoginApiErrorException(ApiErrorException $e, LoginRequest $request)
|
||||
{
|
||||
|
|
@ -237,10 +268,10 @@ class AuthController extends Controller
|
|||
$crm = app('crmAPI');
|
||||
switch ($e->getApiError()) {
|
||||
case ApiError::authFailed():
|
||||
// mauvais identifiants
|
||||
// Mauvais identifiants.
|
||||
return back()->withErrors("Email ou mot de passe incorrect.");
|
||||
case ApiError::customerNotActivated():
|
||||
// le compte n'est pas activé
|
||||
// Le compte n'est pas activé.
|
||||
if (!$customer) {
|
||||
try {
|
||||
if (!($crmCustomer = $crm->getCustomer($request->email))) {
|
||||
|
|
@ -251,8 +282,10 @@ class AuthController extends Controller
|
|||
}
|
||||
$customer = $this->createLocalCustomer($crmCustomer);
|
||||
} catch (CrmException | ApiErrorException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
}
|
||||
}
|
||||
|
|
@ -263,8 +296,10 @@ class AuthController extends Controller
|
|||
le mail de confirmation. Un lien d\'activation vous a été renvoyé.')
|
||||
);
|
||||
default:
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// une erreur non gérée
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur non gérée.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} //end switch
|
||||
}
|
||||
|
|
@ -272,7 +307,7 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Create a local customer
|
||||
*
|
||||
* @param \LDC\LDCCRM\Models\Customer $customer
|
||||
* @param \LDC\LDCCRM\Models\Customer as CrmCustomer $crmCustomer
|
||||
* @return \app\Models\Customers
|
||||
*/
|
||||
private function createLocalCustomer(CrmCustomer $crmCustomer): Customers
|
||||
|
|
@ -295,9 +330,12 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Login a customer
|
||||
*
|
||||
* @param Customers $customer
|
||||
* @param boolean $remember
|
||||
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
* @param \App\Models\Customers $customer
|
||||
* @param boolean $remember
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Exception Exception.
|
||||
* @throws \RuntimeException RuntimeException.
|
||||
*/
|
||||
private function processLogin(Customers $customer, bool $remember)
|
||||
{
|
||||
|
|
@ -313,7 +351,7 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Deconnexion
|
||||
*
|
||||
* @return void
|
||||
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
|
|
@ -326,11 +364,12 @@ class AuthController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Fomulaire reset mot de passe
|
||||
* sur la page login
|
||||
* Fomulaire reset mot de passe sur la page login
|
||||
*
|
||||
* @param Request $request
|
||||
* @return void
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse|void
|
||||
* @throws \Exception Exception.
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function passwordReset(Request $request)
|
||||
{
|
||||
|
|
@ -342,7 +381,7 @@ class AuthController extends Controller
|
|||
return $this->sendResetPasswordLink($request->email);
|
||||
}
|
||||
|
||||
// Le customer n'existe pas en Local, donc il faut le créer d'abord
|
||||
// Le customer n'existe pas en Local, donc il faut le créer d'abord.
|
||||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
$crm = app('crmAPI');
|
||||
|
||||
|
|
@ -350,21 +389,25 @@ class AuthController extends Controller
|
|||
if (!($crmCustomer = $crm->getCustomer($request->email))) {
|
||||
return back()->withErrors(__('Cette adresse email n\'est pas enregistrée dans nos services.'));
|
||||
}
|
||||
// TODO remove this test
|
||||
// TODO remove this test.
|
||||
if (!$crmCustomer->hashcode) {
|
||||
Utils::sendEmailErrorManually(new \Exception(sprintf(
|
||||
'Reset pwd user hascode was null for %s,%s,%s,%s',
|
||||
$crmCustomer->hashcode,
|
||||
$crmCustomer->email,
|
||||
$crmCustomer->city,
|
||||
$crmCustomer->lastname
|
||||
)));
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException(new \Exception(sprintf(
|
||||
'Reset pwd user hascode was null for %s,%s,%s,%s',
|
||||
$crmCustomer->hashcode,
|
||||
$crmCustomer->email,
|
||||
$crmCustomer->city,
|
||||
$crmCustomer->lastname
|
||||
)));
|
||||
}
|
||||
}
|
||||
$customer = $this->createLocalCustomer($crmCustomer);
|
||||
return $this->sendResetPasswordLink($customer->email);
|
||||
} catch (CrmException | ApiErrorException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} //end try
|
||||
}
|
||||
|
|
@ -372,12 +415,12 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Send password reset email
|
||||
*
|
||||
* @param [type] $email
|
||||
* @return void
|
||||
* @param string $email
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function sendResetPasswordLink(string $email): RedirectResponse
|
||||
{
|
||||
// Suppression des anciens tokens
|
||||
// Suppression des anciens tokens.
|
||||
PasswordReset::where('email', $email)->delete();
|
||||
|
||||
$token = Str::random(80);
|
||||
|
|
@ -397,10 +440,11 @@ class AuthController extends Controller
|
|||
|
||||
/**
|
||||
* Print the view used to change the password of a user when he required it
|
||||
* @param $token Token used to identificate the user to change the password of
|
||||
*
|
||||
* @param string $token Token used to identificate the user to change the password of.
|
||||
* @return View The view to print
|
||||
*/
|
||||
public function viewChangePassword($token)
|
||||
public function viewChangePassword(string $token)
|
||||
{
|
||||
$pwdReset = PasswordReset::where('token', $token)->first();
|
||||
if (!$pwdReset) {
|
||||
|
|
@ -415,12 +459,13 @@ class AuthController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Modification du mot de passe par lien via le formulaire
|
||||
* reset mot de passe
|
||||
* Modification du mot de passe par lien via le formulaire reset mot de passe
|
||||
*
|
||||
* @param ResetCustomerPassword $request
|
||||
* @param string $token
|
||||
* @return void
|
||||
* @param \App\Http\Requests\ResetCustomerPassword $request
|
||||
* @param string $token
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \LDC\LDCCRM\Exceptions\CrmException CrmException.
|
||||
*/
|
||||
public function changePassword(ResetCustomerPassword $request, string $token)
|
||||
{
|
||||
|
|
@ -431,14 +476,14 @@ class AuthController extends Controller
|
|||
$crm = app('crmAPI');
|
||||
|
||||
try {
|
||||
// ne devrait pas survenir, $crm->login throws ApiError::authFailed()
|
||||
// Ne devrait pas survenir, $crm->login throws ApiError::authFailed().
|
||||
if ($crm->login($customer->email, $request->password)) {
|
||||
// mauvais identifiants
|
||||
// Mauvais identifiants.
|
||||
return back()->withErrors('Vous ne pouvez pas utiliser un de vos anciens mot de passe.');
|
||||
}
|
||||
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
|
||||
} catch (ApiErrorException $e) {
|
||||
// continue
|
||||
// Continue.
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -449,8 +494,10 @@ class AuthController extends Controller
|
|||
$crmCustomer->password = $request->password;
|
||||
$crmCustomer->save();
|
||||
} catch (\TypeError | CrmException | ApiErrorException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} catch (ValidationException $e) {
|
||||
return back()->withErrors(sprintf('Nouveau mot de passe : %s', $e->getMessage()));
|
||||
|
|
@ -464,8 +511,9 @@ class AuthController extends Controller
|
|||
/**
|
||||
* Mettre à jour le mot de passe lorsque l'on est connecté
|
||||
*
|
||||
* @param CustomerUpdatePassword $request
|
||||
* @return void
|
||||
* @param \App\Http\Requests\CustomerUpdatePassword $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function changePasswordWhenAuthenticated(CustomerUpdatePassword $request)
|
||||
{
|
||||
|
|
@ -475,11 +523,11 @@ class AuthController extends Controller
|
|||
/** @var \LDC\LDCCRM\CrmApiV2 */
|
||||
$crm = app('crmAPI');
|
||||
|
||||
// Test old password
|
||||
// Test old password.
|
||||
try {
|
||||
// ne devrait pas survenir, $crm->login throws ApiError::authFailed()
|
||||
// Ne devrait pas survenir, $crm->login throws ApiError::authFailed().
|
||||
if (!$crm->login($customer->email, $request->password_old)) {
|
||||
// mauvais identifiants
|
||||
// Mauvais identifiants.
|
||||
return back()->withErrors('L\'ancien mot de passe ne correspond pas.');
|
||||
}
|
||||
|
||||
|
|
@ -491,12 +539,16 @@ class AuthController extends Controller
|
|||
if ($e->getApiError()->equals(ApiError::authFailed())) {
|
||||
return back()->withErrors('L\'ancien mot de passe ne correspond pas.');
|
||||
}
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} catch (\TypeError | CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
// Une erreur critique est survenue avec la CRM
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
// Une erreur critique est survenue avec la CRM.
|
||||
return back()->withErrors('Une erreur est survenue, merci de réessayer ultérieurement.');
|
||||
} catch (ValidationException $e) {
|
||||
return back()->withErrors(sprintf('Nouveau mot de passe : %s', $e->getMessage()));
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ class MomentsController extends Controller
|
|||
|
||||
/**
|
||||
* Passe un moment en moment star. Si il y avait déjà un moment star, il ne l'est plus et le nouveau le remplace
|
||||
*
|
||||
* @param id L'id du moment qui doit devenir moment star
|
||||
*/
|
||||
public function setStar($id)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ namespace App\Http\Controllers\Bo;
|
|||
use App\Enums\OCBType;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\SearchRequest;
|
||||
use App\Http\Requests\StoreOcbBreeder;
|
||||
use App\Http\Requests\UpdateOcbBreeder;
|
||||
use App\Http\Requests\Bo\StoreOcbBreeder;
|
||||
use App\Http\Requests\Bo\UpdateOcbBreeder;
|
||||
use App\Models\OCBBreeder;
|
||||
use App\Traits\UpdateModelStatus;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -15,6 +15,13 @@ class OCBBreedersController extends Controller
|
|||
{
|
||||
use UpdateModelStatus;
|
||||
|
||||
/**
|
||||
* Viewany ocb breeder
|
||||
*
|
||||
* @param \App\Http\Requests\SearchRequest $request
|
||||
* @param \App\Enums\OCBType $type
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index(SearchRequest $request, OCBType $type)
|
||||
{
|
||||
$b = OCBBreeder::where('ocbType', $type->value);
|
||||
|
|
@ -34,11 +41,22 @@ class OCBBreedersController extends Controller
|
|||
return view('bo.ocbbreeders.index', compact('b', 'type', 'searchFields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create ocb breeder
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.ocbbreeders.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store ocb breeder
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\StoreOcbBreeder $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreOcbBreeder $request)
|
||||
{
|
||||
$b = new OCBBreeder();
|
||||
|
|
@ -76,6 +94,13 @@ class OCBBreedersController extends Controller
|
|||
->with('success', trans('Enregistré !'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit ocb breeder
|
||||
*
|
||||
* @param \App\Enums\OCBType $type
|
||||
* @param \App\Models\OCBBreeder $breeder
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function edit(OCBType $type, OCBBreeder $breeder)
|
||||
{
|
||||
return view('bo.ocbbreeders.edit', [
|
||||
|
|
@ -84,6 +109,13 @@ class OCBBreedersController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update ocb breeder
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\UpdateOcbBreeder $request
|
||||
* @param \App\Models\OCBBreeder $breeder
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateOcbBreeder $request, OCBBreeder $breeder)
|
||||
{
|
||||
$breeder->fill($request->validated());
|
||||
|
|
@ -122,6 +154,12 @@ class OCBBreedersController extends Controller
|
|||
->with('success', trans('Enregistré !'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy ocb breeder
|
||||
*
|
||||
* @param \App\Models\OCBBreeder $b
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(OCBBreeder $b)
|
||||
{
|
||||
$b->delete();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ use App\Enums\OCBType;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\StoreOcbContentRequest;
|
||||
use App\Http\Requests\Bo\UpdateOcbContentRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\OCBContent;
|
||||
use App\Traits\UpdateModelStatus;
|
||||
|
||||
|
|
@ -17,7 +16,7 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Viewany ocb
|
||||
*
|
||||
* @param OCBType $type
|
||||
* @param \App\Enums\OCBType $type
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index(OCBType $type)
|
||||
|
|
@ -41,7 +40,7 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Store ocb
|
||||
*
|
||||
* @param StoreOcbContentRequest $request
|
||||
* @param \App\Http\Requests\Bo\StoreOcbContentRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreOcbContentRequest $request)
|
||||
|
|
@ -57,7 +56,7 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Edit page
|
||||
*
|
||||
* @param OCBContent $ocb
|
||||
* @param \App\Models\OCBContent $ocb
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function edit(OCBContent $ocb)
|
||||
|
|
@ -69,8 +68,8 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Update ocb
|
||||
*
|
||||
* @param UpdateOcbContentRequest $request
|
||||
* @param OCBContent $ocb
|
||||
* @param \App\Http\Requests\Bo\UpdateOcbContentRequest $request
|
||||
* @param OCBContent $ocb
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateOcbContentRequest $request, OCBContent $ocb)
|
||||
|
|
@ -88,7 +87,7 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Destroy ocb content
|
||||
*
|
||||
* @param OCBContent $ocb
|
||||
* @param \App\Models\OCBContent $ocb
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(OCBContent $ocb)
|
||||
|
|
@ -103,8 +102,8 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Change ocb order
|
||||
*
|
||||
* @param OCBContent $current
|
||||
* @param mixed $action
|
||||
* @param \App\Models\OCBContent $current
|
||||
* @param mixed $action
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changeOrder(OCBContent $current, $action)
|
||||
|
|
@ -135,7 +134,7 @@ class OCBContentController extends Controller
|
|||
/**
|
||||
* Get Last order
|
||||
*
|
||||
* @param OCBType $type
|
||||
* @param \App\Enums\OCBType $type
|
||||
* @return integer
|
||||
*/
|
||||
private function getLastOrder(OCBType $type): int
|
||||
|
|
|
|||
|
|
@ -26,12 +26,17 @@ use Illuminate\Http\UploadedFile;
|
|||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ProductsController extends Controller
|
||||
{
|
||||
use UpdateModelStatus;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \App\Http\Requests\SearchProduct $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(SearchProduct $request)
|
||||
{
|
||||
$ranges = Range::all(['id', 'name']);
|
||||
|
|
@ -60,9 +65,15 @@ class ProductsController extends Controller
|
|||
return view('bo.products.index', compact('p', 'searchFields', 'ranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// Limitation aux champs dont on a besoin sur certaines requêtes pour ne pas surcharger ces dernières
|
||||
// Limitation aux champs dont on a besoin sur certaines
|
||||
// requêtes pour ne pas surcharger ces dernières.
|
||||
$pictograms = ProductPictograms::paginate();
|
||||
$pictosDatas = [];
|
||||
foreach ($pictograms as $picto) {
|
||||
|
|
@ -87,89 +98,103 @@ class ProductsController extends Controller
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\StoreProductRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(StoreProductRequest $request)
|
||||
{
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$seo_title = $request->seo_title;
|
||||
$seo_description = $request->seo_description;
|
||||
$tags = $request->tags;
|
||||
$subtitle = $request->subtitle;
|
||||
$info1 = $request->info1;
|
||||
$info2 = $request->info2;
|
||||
$description = $request->description;
|
||||
$numberPortion = intval($request->number_portion);
|
||||
$typePortion = $request->type_portion;
|
||||
$theoreticalAverageWeight = $request->theoretical_average_weight;
|
||||
$otherFormat = $request->other_format;
|
||||
$rangeId = $request->range_id;
|
||||
$meatTypeId = $request->meat_type_id;
|
||||
$consumptionTimesId = $request->consumption_times_id;
|
||||
$labelId = (\is_string($request->label_id) and \strlen($request->label_id)) ? $request->label_id : null;
|
||||
$preparationAdvice = $request->preparation_advice;
|
||||
$ingredients = $request->ingredients;
|
||||
$tips = $request->tips;
|
||||
$recipeId = $request->recipe_id;
|
||||
$videoLink = $request->video_link;
|
||||
$status = 0;
|
||||
$pictos = json_decode($request->pictos);
|
||||
return DB::transaction(function () use ($request) {
|
||||
$name = $request->name;
|
||||
$seo_title = $request->seo_title;
|
||||
$seo_description = $request->seo_description;
|
||||
$tags = $request->tags;
|
||||
$subtitle = $request->subtitle;
|
||||
$info1 = $request->info1;
|
||||
$info2 = $request->info2;
|
||||
$description = $request->description;
|
||||
$numberPortion = intval($request->number_portion);
|
||||
$typePortion = $request->type_portion;
|
||||
$theoreticalAverageWeight = $request->theoretical_average_weight;
|
||||
$otherFormat = $request->other_format;
|
||||
$rangeId = $request->range_id;
|
||||
$meatTypeId = $request->meat_type_id;
|
||||
$consumptionTimesId = $request->consumption_times_id;
|
||||
$labelId = (\is_string($request->label_id) and
|
||||
\strlen($request->label_id)) ? $request->label_id : null;
|
||||
$preparationAdvice = $request->preparation_advice;
|
||||
$ingredients = $request->ingredients;
|
||||
$tips = $request->tips;
|
||||
$recipeId = $request->recipe_id;
|
||||
$videoLink = $request->video_link;
|
||||
$status = 0;
|
||||
$pictos = json_decode($request->pictos);
|
||||
|
||||
$p = new Products();
|
||||
$p = new Products();
|
||||
|
||||
$this->storeUploadedImage($request, $p, 'picture');
|
||||
$this->storeUploadedImage($request, $p, 'pictureVideo');
|
||||
$this->storeUploadedImage($request, $p, 'picture');
|
||||
$this->storeUploadedImage($request, $p, 'pictureVideo');
|
||||
|
||||
$p->name = $name;
|
||||
$p->slug = $slug;
|
||||
$p->seo_title = $seo_title;
|
||||
$p->seo_description = $seo_description;
|
||||
$p->tags = $tags;
|
||||
$p->subtitle = $subtitle;
|
||||
$p->info1 = $info1;
|
||||
$p->info2 = $info2;
|
||||
$p->description = $description;
|
||||
$p->number_portion = $numberPortion;
|
||||
$p->type_portion = $typePortion;
|
||||
$p->theoretical_average_weight = $theoreticalAverageWeight;
|
||||
$p->other_format = $otherFormat;
|
||||
$p->range_id = $rangeId;
|
||||
$p->sub_range_id = $request->sub_range_id ?: null;
|
||||
$p->meat_type_id = $meatTypeId;
|
||||
$p->consumption_times_id = $consumptionTimesId;
|
||||
$p->label_id = $labelId;
|
||||
$p->preparation_advice = $preparationAdvice;
|
||||
$p->ingredients = $ingredients;
|
||||
$p->tips = $tips;
|
||||
if (!empty($recipeId)) {
|
||||
$p->recipe_id = $recipeId;
|
||||
}
|
||||
$p->video_link = $videoLink;
|
||||
$p->status = $status;
|
||||
$p->order = $this->getLastOrder();
|
||||
$p->star = 0;
|
||||
$p->show_rsm = 0;
|
||||
$p->xml_inco_id = $request->xml_inco;
|
||||
$p->saveOrFail();
|
||||
$p->name = $name;
|
||||
$p->seo_title = $seo_title;
|
||||
$p->seo_description = $seo_description;
|
||||
$p->tags = $tags;
|
||||
$p->subtitle = $subtitle;
|
||||
$p->info1 = $info1;
|
||||
$p->info2 = $info2;
|
||||
$p->description = $description;
|
||||
$p->number_portion = $numberPortion;
|
||||
$p->type_portion = $typePortion;
|
||||
$p->theoretical_average_weight = $theoreticalAverageWeight;
|
||||
$p->other_format = $otherFormat;
|
||||
$p->range_id = $rangeId;
|
||||
$p->sub_range_id = $request->sub_range_id ?: null;
|
||||
$p->meat_type_id = $meatTypeId;
|
||||
$p->consumption_times_id = $consumptionTimesId;
|
||||
$p->label_id = $labelId;
|
||||
$p->preparation_advice = $preparationAdvice;
|
||||
$p->ingredients = $ingredients;
|
||||
$p->tips = $tips;
|
||||
if (!empty($recipeId)) {
|
||||
$p->recipe_id = $recipeId;
|
||||
}
|
||||
$p->video_link = $videoLink;
|
||||
$p->status = $status;
|
||||
$p->order = $this->getLastOrder();
|
||||
$p->star = 0;
|
||||
$p->show_rsm = 0;
|
||||
$p->xml_inco_id = $request->xml_inco;
|
||||
$p->saveOrFail();
|
||||
|
||||
// Gestion des pictos
|
||||
$pictosIds = [];
|
||||
foreach ($pictos as $picto) {
|
||||
$pictosIds[] = $picto->id;
|
||||
}
|
||||
$p->pictograms()->sync($pictosIds);
|
||||
// Gestion des pictos.
|
||||
$pictosIds = [];
|
||||
foreach ($pictos as $picto) {
|
||||
$pictosIds[] = $picto->id;
|
||||
}
|
||||
$p->pictograms()->sync($pictosIds);
|
||||
|
||||
// Gestion des valeurs nutritionelles
|
||||
$inv = new IncoNutritionalValues();
|
||||
$inv->fill($request->validated());
|
||||
$inv->product()->associate($p);
|
||||
$inv->save();
|
||||
// Gestion des valeurs nutritionelles.
|
||||
$inv = new IncoNutritionalValues();
|
||||
$inv->fill($request->validated());
|
||||
$inv->product()->associate($p);
|
||||
$inv->save();
|
||||
|
||||
return redirect()->route('bo.products.edit', $p);
|
||||
return redirect()->route('bo.products.edit', $p);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Products $p
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Products $p)
|
||||
{
|
||||
// Limitation aux champs dont on a besoin sur certaines requêtes pour ne pas surcharger ces dernières
|
||||
// Limitation aux champs dont on a besoin
|
||||
// sur certaines requêtes pour ne pas surcharger ces dernières.
|
||||
$pictograms = ProductPictograms::all();
|
||||
$pictosDatas = [];
|
||||
foreach ($pictograms as $picto) {
|
||||
|
|
@ -204,85 +229,96 @@ class ProductsController extends Controller
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\UpdateProductRequest $request
|
||||
* @param \App\Models\Products $p
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(UpdateProductRequest $request, Products $p)
|
||||
{
|
||||
$name = $request->name;
|
||||
$slug = Str::slug($name);
|
||||
$seo_description = $request->seo_description;
|
||||
$seo_title = $request->seo_title;
|
||||
$picture = $request->picture;
|
||||
$tags = $request->tags;
|
||||
$subtitle = $request->subtitle;
|
||||
$info1 = $request->info1;
|
||||
$info2 = $request->info2;
|
||||
$description = $request->description;
|
||||
$numberPortion = intval($request->number_portion);
|
||||
$typePortion = $request->type_portion;
|
||||
$theoreticalAverageWeight = $request->theoretical_average_weight;
|
||||
$otherFormat = $request->other_format;
|
||||
$rangeId = $request->range_id;
|
||||
$meatTypeId = $request->meat_type_id;
|
||||
$consumptionTimesId = $request->consumption_times_id;
|
||||
$labelId = (\is_string($request->label_id) and \strlen($request->label_id)) ? $request->label_id : null;
|
||||
$preparationAdvice = $request->preparation_advice;
|
||||
$ingredients = $request->ingredients;
|
||||
$tips = $request->tips;
|
||||
$recipeId = $request->recipe_id;
|
||||
$videoLink = $request->video_link;
|
||||
$pictureVideo = $request->picture_video;
|
||||
$status = $request->status === null ? 0 : 1;
|
||||
$show_rsm = $request->show_rsm === null ? 0 : 1;
|
||||
$pictos = json_decode($request->pictos);
|
||||
return DB::transaction(function () use ($request, $p) {
|
||||
$name = $request->name;
|
||||
$seo_description = $request->seo_description;
|
||||
$seo_title = $request->seo_title;
|
||||
$tags = $request->tags;
|
||||
$subtitle = $request->subtitle;
|
||||
$info1 = $request->info1;
|
||||
$info2 = $request->info2;
|
||||
$description = $request->description;
|
||||
$numberPortion = intval($request->number_portion);
|
||||
$typePortion = $request->type_portion;
|
||||
$theoreticalAverageWeight = $request->theoretical_average_weight;
|
||||
$otherFormat = $request->other_format;
|
||||
$rangeId = $request->range_id;
|
||||
$meatTypeId = $request->meat_type_id;
|
||||
$consumptionTimesId = $request->consumption_times_id;
|
||||
$labelId = (\is_string($request->label_id) and
|
||||
\strlen($request->label_id)) ? $request->label_id : null;
|
||||
$preparationAdvice = $request->preparation_advice;
|
||||
$ingredients = $request->ingredients;
|
||||
$tips = $request->tips;
|
||||
$recipeId = $request->recipe_id;
|
||||
$videoLink = $request->video_link;
|
||||
$status = $request->status === null ? 0 : 1;
|
||||
$show_rsm = $request->show_rsm === null ? 0 : 1;
|
||||
$pictos = json_decode($request->pictos);
|
||||
|
||||
$this->storeUploadedImage($request, $p, 'picture');
|
||||
$this->storeUploadedImage($request, $p, 'pictureVideo');
|
||||
$this->storeUploadedImage($request, $p, 'picture');
|
||||
$this->storeUploadedImage($request, $p, 'pictureVideo');
|
||||
|
||||
// Gestion des valeurs nutritionelles
|
||||
/** @var \App\Models\IncoNutritionalValues */
|
||||
$inv = $p->incoNutritionalValues ?? new IncoNutritionalValues();
|
||||
$inv->fill($request->validated());
|
||||
$inv->product()->associate($p);
|
||||
$inv->save();
|
||||
// Gestion des valeurs nutritionelles.
|
||||
/** @var \App\Models\IncoNutritionalValues */
|
||||
$inv = $p->incoNutritionalValues ?? new IncoNutritionalValues();
|
||||
$inv->fill($request->validated());
|
||||
$inv->product()->associate($p);
|
||||
$inv->save();
|
||||
|
||||
// Gestion des pictos
|
||||
$pictosIds = [];
|
||||
foreach ($pictos as $picto) {
|
||||
$pictosIds[] = $picto->id;
|
||||
}
|
||||
$p->pictograms()->sync($pictosIds);
|
||||
// Gestion des pictos.
|
||||
$pictosIds = [];
|
||||
foreach ($pictos as $picto) {
|
||||
$pictosIds[] = $picto->id;
|
||||
}
|
||||
$p->pictograms()->sync($pictosIds);
|
||||
|
||||
$p->name = $name;
|
||||
$p->slug = $slug;
|
||||
$p->tags = $tags;
|
||||
$p->subtitle = $subtitle;
|
||||
$p->seo_title = $seo_title;
|
||||
$p->seo_description = $seo_description;
|
||||
$p->info1 = $info1;
|
||||
$p->info2 = $info2;
|
||||
$p->description = $description;
|
||||
$p->number_portion = $numberPortion;
|
||||
$p->type_portion = $typePortion;
|
||||
$p->theoretical_average_weight = $theoreticalAverageWeight;
|
||||
$p->other_format = $otherFormat;
|
||||
$p->range_id = $rangeId;
|
||||
$p->sub_range_id = $request->sub_range_id ?: null;
|
||||
$p->meat_type_id = $meatTypeId;
|
||||
$p->consumption_times_id = $consumptionTimesId;
|
||||
$p->label_id = $labelId;
|
||||
$p->preparation_advice = $preparationAdvice;
|
||||
$p->ingredients = $ingredients;
|
||||
$p->tips = $tips;
|
||||
if (!empty($recipeId)) {
|
||||
$p->recipe_id = $recipeId;
|
||||
}
|
||||
$p->video_link = $videoLink;
|
||||
$p->show_rsm = $show_rsm;
|
||||
$p->status = $status;
|
||||
$p->saveOrFail();
|
||||
|
||||
return redirect()->route('bo.products.edit', $p->id)->with('success', 'Enregistré !');
|
||||
$p->name = $name;
|
||||
$p->tags = $tags;
|
||||
$p->subtitle = $subtitle;
|
||||
$p->seo_title = $seo_title;
|
||||
$p->seo_description = $seo_description;
|
||||
$p->info1 = $info1;
|
||||
$p->info2 = $info2;
|
||||
$p->description = $description;
|
||||
$p->number_portion = $numberPortion;
|
||||
$p->type_portion = $typePortion;
|
||||
$p->theoretical_average_weight = $theoreticalAverageWeight;
|
||||
$p->other_format = $otherFormat;
|
||||
$p->range_id = $rangeId;
|
||||
$p->sub_range_id = $request->sub_range_id ?: null;
|
||||
$p->meat_type_id = $meatTypeId;
|
||||
$p->consumption_times_id = $consumptionTimesId;
|
||||
$p->label_id = $labelId;
|
||||
$p->preparation_advice = $preparationAdvice;
|
||||
$p->ingredients = $ingredients;
|
||||
$p->tips = $tips;
|
||||
if (!empty($recipeId)) {
|
||||
$p->recipe_id = $recipeId;
|
||||
}
|
||||
$p->video_link = $videoLink;
|
||||
$p->show_rsm = $show_rsm;
|
||||
$p->status = $status;
|
||||
$p->saveOrFail();
|
||||
return redirect()->route('bo.products.edit', $p->id)->with('success', 'Enregistré !');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Models\Products $product
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Products $product)
|
||||
{
|
||||
if (!$product->recipes()->count()) {
|
||||
|
|
|
|||
|
|
@ -10,17 +10,33 @@ use Illuminate\Support\Facades\File;
|
|||
|
||||
class SubRangeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Viewany subrange
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$subranges = SubRange::paginate();
|
||||
return view('bo.subranges.index', compact('subranges'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create subrange
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.subranges.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store subrange
|
||||
*
|
||||
* @param \App\Http\Requests\StoreSubRange $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function store(StoreSubRange $request)
|
||||
{
|
||||
$subrange = new SubRange($request->validated());
|
||||
|
|
@ -29,11 +45,24 @@ class SubRangeController extends Controller
|
|||
return redirect()->route('bo.subranges.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit subrange
|
||||
*
|
||||
* @param \App\Models\SubRange $subrange
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function edit(SubRange $subrange)
|
||||
{
|
||||
return view('bo.subranges.edit', ['subrange' => $subrange]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update subrange
|
||||
*
|
||||
* @param \App\Http\Requests\UpdateSubRange $request
|
||||
* @param \App\Models\SubRange $subrange
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateSubRange $request, SubRange $subrange)
|
||||
{
|
||||
$subrange->fill($request->validated());
|
||||
|
|
@ -43,6 +72,12 @@ class SubRangeController extends Controller
|
|||
->with('success', 'Enregistré !');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy subrange
|
||||
*
|
||||
* @param \App\Models\SubRange $subrange
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function destroy(SubRange $subrange)
|
||||
{
|
||||
if (File::exists($subrange->picture)) {
|
||||
|
|
@ -57,6 +92,12 @@ class SubRangeController extends Controller
|
|||
->with('warning', 'Le contenu a bien été supprimé');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove subrange picture
|
||||
*
|
||||
* @param \App\Models\SubRange $subrange
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function removeImage(SubRange $subrange)
|
||||
{
|
||||
if (File::exists($subrange->picture)) {
|
||||
|
|
|
|||
|
|
@ -406,6 +406,7 @@ class BoutiqueController extends Controller
|
|||
|
||||
/**
|
||||
* Get Mercanet ref and responseCode for request
|
||||
*
|
||||
* @return array['ref' => 'value', 'responseCode' => 'value']
|
||||
*/
|
||||
private function getMercanetData(Request $request): array
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ class BreedingPageController extends Controller
|
|||
*/
|
||||
public function list(BreedingPageType $pageType)
|
||||
{
|
||||
$pages = BreedingPage::where('type', $pageType)->whereStatus(true)->get();
|
||||
$bannerUrl = $this->getBannerUrlFromGeneralConfig($pageType);
|
||||
$pages = BreedingPage::where('type', $pageType)->whereStatus(true)->get();
|
||||
$bannerUrl = $this->getBannerUrlFromGeneralConfig($pageType);
|
||||
$headerText = $this->getTextHeaderFromGeneralConfig($pageType);
|
||||
|
||||
return view('front.breeding-page.list', compact('pages', 'pageType', 'bannerUrl', 'headerText'));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ use App\Http\Requests\DownloadBRFileRequest;
|
|||
use App\Http\Requests\SendMessageRequest;
|
||||
use App\Http\Requests\SurveyAnswersRequest;
|
||||
use App\Http\Requests\UpdateInfosRequest;
|
||||
use App\Lib\Utils;
|
||||
use App\Models\Articles;
|
||||
use App\Models\BlockList;
|
||||
use App\Models\Customers;
|
||||
|
|
@ -38,7 +37,7 @@ class ClubController extends Controller
|
|||
{
|
||||
$this->middleware(function ($request, $next) {
|
||||
// IF session has need crm completion
|
||||
// then redirect to completion page
|
||||
// Then redirect to completion page.
|
||||
if (
|
||||
Session::has('needCrmInfoUpdate') and
|
||||
$request->route() and
|
||||
|
|
@ -51,7 +50,13 @@ class ClubController extends Controller
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Index
|
||||
*
|
||||
* @param \App\Enums\ArticleCategory|null $tag
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function index(ArticleCategory $tag = null)
|
||||
{
|
||||
self::getNotifications();
|
||||
|
|
@ -63,7 +68,7 @@ class ClubController extends Controller
|
|||
|
||||
$nbCustomers = Customers::count();
|
||||
|
||||
// Cas de catégorie d'article
|
||||
// Cas de catégorie d'article.
|
||||
$category = $tag;
|
||||
|
||||
return view('front.club.index', compact(
|
||||
|
|
@ -75,6 +80,12 @@ class ClubController extends Controller
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* infos
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws Exception Exception.
|
||||
*/
|
||||
public function infos()
|
||||
{
|
||||
self::getNotifications();
|
||||
|
|
@ -100,7 +111,10 @@ class ClubController extends Controller
|
|||
*
|
||||
* nom, prénom, adresse, code postal, ville
|
||||
*
|
||||
* @param Request $request
|
||||
* @param \App\Http\Requests\UpdateInfosRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Illuminate\Validation\ValidationException ValidationException.
|
||||
*/
|
||||
public function updateInfos(UpdateInfosRequest $request)
|
||||
{
|
||||
|
|
@ -116,6 +130,12 @@ class ClubController extends Controller
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* missingCrmInfos
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws Exception Exception.
|
||||
*/
|
||||
public function missingCrmInfos()
|
||||
{
|
||||
self::getNotifications();
|
||||
|
|
@ -131,6 +151,15 @@ class ClubController extends Controller
|
|||
return view('front.club.missingInfos', compact('customer', 'crmCustomer'));
|
||||
}
|
||||
|
||||
/**
|
||||
* missingCrmInfosSubmit
|
||||
*
|
||||
* @param \App\Http\Requests\UpdateInfosRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Illuminate\Validation\ValidationException ValidationException.
|
||||
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException RouteNotFoundException.
|
||||
*/
|
||||
public function missingCrmInfosSubmit(UpdateInfosRequest $request)
|
||||
{
|
||||
if (($result = $this->updateUserInfo($request)) === true) {
|
||||
|
|
@ -148,9 +177,11 @@ class ClubController extends Controller
|
|||
/**
|
||||
* Updates user info
|
||||
*
|
||||
* @param UpdateInfosRequest $request
|
||||
* @return boolean|string return strictly true if success,
|
||||
* false il failed, could be a string with message error if failed
|
||||
* @param \App\Http\Requests\UpdateInfosRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse|string|boolean return strictly true if success,
|
||||
* false il failed, could be a string with message error if failed
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Illuminate\Validation\ValidationException ValidationException.
|
||||
*/
|
||||
private function updateUserInfo(UpdateInfosRequest $request)
|
||||
{
|
||||
|
|
@ -160,7 +191,7 @@ class ClubController extends Controller
|
|||
return \redirect()->back();
|
||||
}
|
||||
|
||||
// TODO : Activer le changement d'email quand ce sera possible dans la CRM
|
||||
// TODO : Activer le changement d'email quand ce sera possible dans la CRM.
|
||||
/** @var \LDC\LDCCRM\Models\Customer */
|
||||
$crmCustomer = $customer->apiData;
|
||||
|
||||
|
|
@ -169,7 +200,7 @@ class ClubController extends Controller
|
|||
unset($data['month']);
|
||||
unset($data['year']);
|
||||
|
||||
// remove phone if empty
|
||||
// Remove phone if empty.
|
||||
if (isset($data['phone']) and !strlen($data['phone'])) {
|
||||
unset($data['phone']);
|
||||
}
|
||||
|
|
@ -183,10 +214,14 @@ class ClubController extends Controller
|
|||
if ($e->getApiError()->equals(ApiError::validationFailed())) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
return false;
|
||||
} catch (CrmException | \TypeError $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -194,6 +229,8 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Call the notifications page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function notifications()
|
||||
{
|
||||
|
|
@ -202,12 +239,12 @@ class ClubController extends Controller
|
|||
$customer = auth('customer')->user();
|
||||
$notificationsIds = $customer->getAllNotifications()
|
||||
->pluck('id')->toArray();
|
||||
// Handle multiple access to this critical part
|
||||
// Handle multiple access to this critical part.
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Hack to prevent duplicates
|
||||
// Hack to prevent duplicates.
|
||||
$customer->readNotifications()->sync([]);
|
||||
// Sync notifications
|
||||
// Sync notifications.
|
||||
$customer->readNotifications()->sync($notificationsIds);
|
||||
} catch (QueryException $e) {
|
||||
DB::rollBack();
|
||||
|
|
@ -218,6 +255,8 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Call the cart page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function cart()
|
||||
{
|
||||
|
|
@ -228,6 +267,8 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Call the favorites recipes page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function favoritesRecipes()
|
||||
{
|
||||
|
|
@ -238,6 +279,9 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Call the reductions page
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws Exception Exception.
|
||||
*/
|
||||
public function reductions()
|
||||
{
|
||||
|
|
@ -268,6 +312,13 @@ class ClubController extends Controller
|
|||
return view('front.club.reductions', compact('murBr'));
|
||||
}
|
||||
|
||||
/**
|
||||
* reductionsGet
|
||||
*
|
||||
* @param \App\Http\Requests\DownloadBRFileRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response
|
||||
* @throws \Exception Exception.
|
||||
*/
|
||||
public function reductionsGet(DownloadBRFileRequest $request)
|
||||
{
|
||||
/** @var \App\Lib\MesBR */
|
||||
|
|
@ -304,14 +355,18 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Call the article page with a slug for the article to print
|
||||
* @param $slug Slug of the article
|
||||
* @return View The view that the article have to print
|
||||
*
|
||||
* @param \App\Enums\ArticleCategory $tag
|
||||
* @param \App\Models\Articles $publishedArticle
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
*/
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
public function article(ArticleCategory $tag, Articles $publishedArticle)
|
||||
{
|
||||
// phpcs:enable
|
||||
self::getNotifications();
|
||||
// Check si le customer connecté a déjà répondu
|
||||
// Check si le customer connecté a déjà répondu.
|
||||
$alreadyAnswered = false;
|
||||
if (Auth::guard('customer')->check()) {
|
||||
$answersIds = $publishedArticle->answers()->pluck('id')->toArray();
|
||||
|
|
@ -337,8 +392,11 @@ class ClubController extends Controller
|
|||
|
||||
/**
|
||||
* Handle the request of a customer that answered a survey
|
||||
* @param $request Request
|
||||
* @return View View to go to
|
||||
*
|
||||
* @param \App\Http\Requests\SurveyAnswersRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \InvalidArgumentException InvalidArgumentException.
|
||||
*/
|
||||
public function answerSurvey(SurveyAnswersRequest $request)
|
||||
{
|
||||
|
|
@ -391,8 +449,10 @@ class ClubController extends Controller
|
|||
/**
|
||||
* Send a message to a user
|
||||
*
|
||||
* @param SendMessageRequest $request
|
||||
* @param \App\Http\Requests\SendMessageRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
* @throws \Throwable Throwable.
|
||||
*/
|
||||
public function sendMessage(SendMessageRequest $request)
|
||||
{
|
||||
|
|
@ -440,8 +500,11 @@ class ClubController extends Controller
|
|||
/**
|
||||
* Destroy a message
|
||||
*
|
||||
* @param DeleteMessagesRequest $request
|
||||
* @param \App\Http\Requests\DeleteMessagesRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \LogicException LogicException.
|
||||
* @throws \Throwable Throwable.
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function deleteMessage(DeleteMessagesRequest $request)
|
||||
{
|
||||
|
|
@ -475,9 +538,10 @@ class ClubController extends Controller
|
|||
/**
|
||||
* Block a customer to prevent him sending messages
|
||||
*
|
||||
* @param BlockCustomerRequest $request
|
||||
* @param boolean $status
|
||||
* @param \App\Http\Requests\BlockCustomerRequest $request
|
||||
* @param boolean $status
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function blockCustomer(BlockCustomerRequest $request, bool $status)
|
||||
{
|
||||
|
|
@ -496,6 +560,11 @@ class ClubController extends Controller
|
|||
return response()->json($blockCustomer);
|
||||
}
|
||||
|
||||
/**
|
||||
* getNotifications
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function getNotifications()
|
||||
{
|
||||
if (!Auth::guard('customer')->check()) {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,18 @@ use App\Jobs\SendPasserelleMail;
|
|||
use App\Models\Contact as Contact;
|
||||
use App\Models\MailContactData;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show contact Form
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Enums\ContactFormType|null $type
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function contact(Request $request, ContactFormType $type = null)
|
||||
{
|
||||
$user = null;
|
||||
|
|
@ -24,46 +32,80 @@ class ContactController extends Controller
|
|||
return view('front.contact.contact', compact('type', 'user', 'status', 'username'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit contact Form
|
||||
*
|
||||
* @param \App\Http\Requests\ContactFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function contactSubmit(ContactFormRequest $request)
|
||||
{
|
||||
try {
|
||||
$data = new MailContactData($request->all());
|
||||
if ($request->type == ContactFormType::onepage()->value) {
|
||||
SendNLMail::dispatchAfterResponse($data);
|
||||
} else {
|
||||
SendArchadiaMail::dispatchAfterResponse($data);
|
||||
return DB::transaction(function () use ($request) {
|
||||
try {
|
||||
$data = new MailContactData($request->all());
|
||||
if ($request->type == ContactFormType::onepage()->value) {
|
||||
SendNLMail::dispatchAfterResponse($data);
|
||||
} else {
|
||||
SendArchadiaMail::dispatchAfterResponse($data);
|
||||
}
|
||||
Contact::incrementStat($data->type);
|
||||
return back()->with('status', true);
|
||||
} catch (AbortContactMailer $e) {
|
||||
Log::error('Fail to build mail from contact page ', ['exception' => $e]);
|
||||
}
|
||||
Contact::incrementStat($data->type);
|
||||
return back()->with('status', true);
|
||||
} catch (AbortContactMailer $e) {
|
||||
Log::error('Fail to build mail from contact page ', ['exception' => $e]);
|
||||
}
|
||||
return back()->withInput()->with('status', false);
|
||||
return back()->withInput()->with('status', false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show complain form
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function complain(Request $request)
|
||||
{
|
||||
return $this->contact($request, ContactFormType::complain());
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit complain form
|
||||
*
|
||||
* @param \App\Http\Requests\ContactFormRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function complainSubmit(ContactFormRequest $request)
|
||||
{
|
||||
try {
|
||||
$data = new MailContactData($request->all());
|
||||
SendPasserelleMail::dispatchAfterResponse($data);
|
||||
Contact::incrementStat($data->type);
|
||||
return back()->with('status', true);
|
||||
} catch (AbortContactMailer $e) {
|
||||
Log::error('Fail to build mail from complain page ', ['exception' => $e]);
|
||||
}
|
||||
return back()->withInput()->with('status', false);
|
||||
return DB::transaction(function () use ($request) {
|
||||
try {
|
||||
$data = new MailContactData($request->all());
|
||||
SendPasserelleMail::dispatchAfterResponse($data);
|
||||
Contact::incrementStat($data->type);
|
||||
return back()->with('status', true);
|
||||
} catch (AbortContactMailer $e) {
|
||||
Log::error('Fail to build mail from complain page ', ['exception' => $e]);
|
||||
}
|
||||
return back()->withInput()->with('status', false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Report customer from Club magnet exchange
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function reportCustomer(Request $request)
|
||||
{
|
||||
return $this->contact($request, ContactFormType::abuse());
|
||||
}
|
||||
|
||||
/**
|
||||
* Propose meal recipe
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function proposeRecipe(Request $request)
|
||||
{
|
||||
return $this->contact($request, ContactFormType::recipe());
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Lib\Utils;
|
||||
use App\Models\Customers;
|
||||
use App\Models\Products;
|
||||
use App\Models\Recipes;
|
||||
|
|
@ -38,11 +37,15 @@ class CustomerController extends Controller
|
|||
}
|
||||
} catch (ApiErrorException $e) {
|
||||
if (!$e->getApiError()->equals(ApiError::singleOptinCustomerExists())) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
$message = trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
}
|
||||
} catch (CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
$message = trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
}
|
||||
*/
|
||||
|
|
@ -69,11 +72,15 @@ class CustomerController extends Controller
|
|||
$message = null;
|
||||
} catch (ApiErrorException $e) {
|
||||
if (!$e->getApiError()->equals(ApiError::singleOptinCustomerExists())) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
$message = trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
}
|
||||
} catch (CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
$message = trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
}//end try
|
||||
|
||||
|
|
@ -84,6 +91,14 @@ class CustomerController extends Controller
|
|||
return view('front.singleoptin-unsubscribe', compact('message'));
|
||||
}
|
||||
|
||||
/**
|
||||
* setFavoriteRecipe
|
||||
*
|
||||
* @param \App\Models\Recipes $recipe
|
||||
* @param boolean $status
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function setFavoriteRecipe(Recipes $recipe, bool $status)
|
||||
{
|
||||
/** @var \App\Models\Customer */
|
||||
|
|
@ -96,28 +111,41 @@ class CustomerController extends Controller
|
|||
return response()->json();
|
||||
}
|
||||
|
||||
public function setItemInCart(Products $product, bool $status)
|
||||
/**
|
||||
* Add item in customer shopping list
|
||||
*
|
||||
* @param \App\Models\Products $publishedProduct
|
||||
* @param boolean $status
|
||||
* @return void
|
||||
*/
|
||||
public function setItemInCart(Products $publishedProduct, bool $status): void
|
||||
{
|
||||
/** @var \App\Models\Customer */
|
||||
$customer = Auth::guard('customer')->user();
|
||||
if ($status) {
|
||||
$customer->products()->attach($product);
|
||||
$customer->products()->attach($publishedProduct);
|
||||
} else {
|
||||
$customer->products()->detach($product);
|
||||
$customer->products()->detach($publishedProduct);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
/**
|
||||
* delete
|
||||
*
|
||||
* @param integer $id
|
||||
* @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function delete(int $id)
|
||||
{
|
||||
// TODO : Implémenter la suppression lorsque la CRM sera prête pour le faire aussi
|
||||
// TODO : Implémenter la suppression lorsque la CRM sera prête pour le faire aussi.
|
||||
dd('Not implemented yet');
|
||||
// Suppression d'un compte client
|
||||
// Suppression d'un compte client.
|
||||
$customer = Customers::findOrFail($id);
|
||||
$customer->recipes()->delete();
|
||||
$customer->products()->delete();
|
||||
$customer->answers()->delete();
|
||||
|
||||
// TODO : Suppression via la CRM
|
||||
// TODO : Suppression via la CRM.
|
||||
|
||||
/** @var \Illuminate\Auth\SessionGuard */
|
||||
$guard = Auth::guard('customer');
|
||||
|
|
|
|||
99
app/Http/Controllers/Fo/OpInstaController.php
Normal file
99
app/Http/Controllers/Fo/OpInstaController.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Fo;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\OpInsta\InstaMedia;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class OpInstaController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show OpInsta page
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$this->assertConfigIsValid();
|
||||
$has_started = $this->hasStarted();
|
||||
|
||||
$instaMediaList = InstaMedia::query()->orderBy('id')->get()
|
||||
->map(function (InstaMedia $media) {
|
||||
$path = \explode('/', \rtrim(\parse_url(
|
||||
$media->permalink,
|
||||
\PHP_URL_PATH
|
||||
), '/'));
|
||||
|
||||
$media->pictures = $this->fetchPicture(\collect($path)->last());
|
||||
return $media;
|
||||
});
|
||||
|
||||
return \view('front.opinsta.index', \compact('instaMediaList', 'has_started'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assert config is valid
|
||||
*
|
||||
* @return void
|
||||
* @throws \ErrorException If config is invalid.
|
||||
*/
|
||||
private function assertConfigIsValid(): void
|
||||
{
|
||||
try {
|
||||
$start = config('opinsta.start');
|
||||
$end = config('opinsta.end');
|
||||
|
||||
Validator::validate([
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
], [
|
||||
'start' => 'date_format:d-m-Y|before:end',
|
||||
'end' => 'date_format:d-m-Y|after:start',
|
||||
]);
|
||||
} catch (ValidationException $e) {
|
||||
$message = \collect($e->errors())->map(function ($el) {
|
||||
return \collect($el)->implode(', ');
|
||||
})->implode(', ');
|
||||
throw new \ErrorException("Op install config is invalid, {$message}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Le jeu a démaré ?
|
||||
*
|
||||
* Démarre à la date de départ (0h00) et s'arrête à la date de fin (23h59)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function hasStarted(): bool
|
||||
{
|
||||
$start = Carbon::createFromFormat('d-m-Y', config('opinsta.start'), 'Europe/Paris')->setTime(0, 0);
|
||||
$end = Carbon::createFromFormat('d-m-Y', config('opinsta.end'), 'Europe/Paris')->setTime(0, 0);
|
||||
$now = Carbon::now('Europe/Paris')->setTime(0, 0);
|
||||
return $now->isBetween($start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Media Picture Object
|
||||
*
|
||||
* @param string $ig_media_hash
|
||||
* @return array<integer,string[]>
|
||||
*/
|
||||
private function fetchPicture(string $ig_media_hash): array
|
||||
{
|
||||
return Cache::remember(
|
||||
"media_picture_ajax_fetch{$ig_media_hash}",
|
||||
// * 3H cache
|
||||
3 * 60 * 60,
|
||||
function () use ($ig_media_hash) {
|
||||
return InstaMedia::fetchInstagramMediaPictures($ig_media_hash);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Enums\Days;
|
||||
use App\Http\Requests\SingleOptinRequest;
|
||||
use App\Lib\Utils;
|
||||
use App\Models\HomeSliderPictures;
|
||||
use App\Models\NewsSliderPictures;
|
||||
use App\Models\OCBBreeder;
|
||||
|
|
@ -18,6 +17,11 @@ use LDC\LDCCRM\Models\SingleOptin;
|
|||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* index
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$slides = HomeSliderPictures::where([
|
||||
|
|
@ -27,11 +31,11 @@ class HomeController extends Controller
|
|||
|
||||
$newsSlides = NewsSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get();
|
||||
|
||||
// Images d'éleveur
|
||||
// Images d'éleveur.
|
||||
$breeder = OCBBreeder::ocbValidated()->select('picture', 'first_name', 'last_name')
|
||||
->inRandomOrder()->first();
|
||||
|
||||
// Les produits star
|
||||
// Les produits star.
|
||||
$starProducts = Products::select('picture', 'name', 'slug')->where([['star', 1], ['status', 1]])
|
||||
->inRandomOrder()->limit(3)->get();
|
||||
|
||||
|
|
@ -40,7 +44,7 @@ class HomeController extends Controller
|
|||
->where([['star', 0], ['status', 1]])->inRandomOrder()->limit(3 - $starProducts->count())->get());
|
||||
}
|
||||
|
||||
// Montant réductions
|
||||
// Montant réductions.
|
||||
$montantReduction = Reduction::whereStatus(true)->sum('value');
|
||||
|
||||
return view('home', compact('slides', 'newsSlides', 'breeder', 'starProducts', 'montantReduction'));
|
||||
|
|
@ -48,8 +52,11 @@ class HomeController extends Controller
|
|||
|
||||
/**
|
||||
* Call the CRM to add a single optin
|
||||
* @param string $email Email to add as a single optin
|
||||
* @return string Message to print to the customer
|
||||
*
|
||||
* @param \App\Http\Requests\SingleOptinRequest $request
|
||||
* @return string|array|null|\Illuminate\Contracts\Translation\Translator
|
||||
* @throws \LDC\LDCCRM\Exceptions\ValidationException ValidationException.
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function addOptIn(SingleOptinRequest $request)
|
||||
{
|
||||
|
|
@ -57,18 +64,27 @@ class HomeController extends Controller
|
|||
SingleOptin::setStatus($request->email, true);
|
||||
return __("Votre inscription à la newsletter a été prise en compte");
|
||||
} catch (ApiErrorException $e) {
|
||||
// Il y a deja un customerInfo avec optin a true pour ce customer
|
||||
// Il y a deja un customerInfo avec optin a true pour ce customer.
|
||||
if ($e->getApiError()->equals(ApiError::singleOptinCustomerExists())) {
|
||||
return trans('Vous êtes déjà inscrit avec cette adresse email');
|
||||
}
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
return trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
} catch (CrmException $e) {
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
return trans('Une erreur est survenue, merci de réessayer ultérieurement');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* joinUs
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function joinUs()
|
||||
{
|
||||
return view('front.joinus', ['joinus' => PageJoinus::firstOrFail()]);
|
||||
|
|
|
|||
|
|
@ -77,31 +77,4 @@ class OCBController extends Controller
|
|||
->inRandomOrder()->first();
|
||||
return view('front.ocb.poultry', compact('breeder', 'ocbContents'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show ocb rabbit content
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function rabbit()
|
||||
{
|
||||
$ocbContents = OCBContent::where('type', OCBType::rabbit())
|
||||
->where('status', true)
|
||||
->orderBy('order')
|
||||
->get();
|
||||
return view('front.ocb.rabbit', compact('ocbContents'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show ocb egg content
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function egg()
|
||||
{
|
||||
$ocbContents = OCBContent::where('type', OCBType::egg())
|
||||
->orderBy('order')
|
||||
->where('status', true)->get();
|
||||
return view('front.ocb.egg', compact('ocbContents'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace App\Http\Controllers\OpBrCharcut;
|
||||
|
||||
use App\Http\Requests\OpBrCharcut\ParticipateRequest;
|
||||
use App\Mail\NotifAdmin;
|
||||
use App\Mail\ReductionWon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
|
@ -24,8 +23,9 @@ class EnterCodeController extends Controller
|
|||
/**
|
||||
* Participate Method
|
||||
*
|
||||
* @param ParticipateRequest $request
|
||||
* @param \App\Http\Requests\OpBrCharcut\ParticipateRequest $request
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
public function participate(ParticipateRequest $request)
|
||||
{
|
||||
|
|
@ -33,16 +33,15 @@ class EnterCodeController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Détermine si un BR doit être servi
|
||||
* renvoi la vue de gain BR
|
||||
* Détermine si un BR doit être servi, renvoi la vue de gain BR
|
||||
*
|
||||
* @param
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
* @param mixed $code
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
private function serveCouponWin($code)
|
||||
{
|
||||
//ici on a besoin que d'un identifiant pas de tout le coupon
|
||||
// Ici on a besoin que d'un identifiant pas de tout le coupon.
|
||||
$crmCoupon = $this->updateCoupon(config('opbrcharcut.MESBR_COUPON_1'), 1);
|
||||
if (!$crmCoupon) {
|
||||
return back()->withErrors("Une erreur est survenue, merci de réessayez ultérieurement.");
|
||||
|
|
@ -58,7 +57,7 @@ class EnterCodeController extends Controller
|
|||
|
||||
$user = Auth::guard('customer')->user();
|
||||
Mail::to($user->email)->send(new ReductionWon($user->apiData, $crmCoupon));
|
||||
//Marquer le code comme utilisé par le user
|
||||
// Marquer le code comme utilisé par le user.
|
||||
$code->code_used = 1;
|
||||
$code->customer()->associate($user);
|
||||
$code->save();
|
||||
|
|
@ -69,7 +68,9 @@ class EnterCodeController extends Controller
|
|||
* Update a coupon
|
||||
*
|
||||
* @param mixed $id_coupon
|
||||
* @return \App\Models\Reduction|null
|
||||
* @param mixed $qtty
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
private function updateCoupon($id_coupon, $qtty)
|
||||
{
|
||||
|
|
@ -92,21 +93,31 @@ class EnterCodeController extends Controller
|
|||
|
||||
$result = $mesBRCharc->updatePanier($crmCustomer, $updateCustID, $id_coupon, $qtty);
|
||||
if ($result["status"] === "OK") {
|
||||
//ici on a besoin que savoir que c'était OK
|
||||
// Ici on a besoin que savoir que c'était OK.
|
||||
$reduction = $result["link"];
|
||||
} else {
|
||||
Mail::to(config('mail.contactsList.serviceweb'))
|
||||
->send(new NotifAdmin(\sprintf(
|
||||
'MESBR : Une erreur est survenue. Code : %s Message : %s',
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException(new \Exception(\sprintf(
|
||||
'MESBR - BR CHARCUTERIE : Une erreur est survenue. Code : %s Message : %s',
|
||||
$result["code"],
|
||||
$result["message"]
|
||||
)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return $reduction;
|
||||
}
|
||||
|
||||
/**
|
||||
* updateCustomer
|
||||
*
|
||||
* @param mixed $hascode
|
||||
* @param mixed $email
|
||||
* @param mixed $country
|
||||
* @return mixed
|
||||
* @throws \Illuminate\Contracts\Container\BindingResolutionException BindingResolutionException.
|
||||
*/
|
||||
private function updateCustomer($hascode, $email, $country)
|
||||
{
|
||||
/** @var \App\Lib\MesBR */
|
||||
|
|
@ -119,13 +130,13 @@ class EnterCodeController extends Controller
|
|||
);
|
||||
|
||||
if ($updateCust->status === 'KO') {
|
||||
Mail::to(config('mail.contactsList.serviceweb'))
|
||||
->send(new NotifAdmin(\sprintf(
|
||||
'MESBR : Une erreur est survenue. Code : %s Message : %s',
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException(new \Exception(\sprintf(
|
||||
'MESBR - BR CHARCUTERIE : Une erreur est survenue. Code : %s Message : %s',
|
||||
$updateCust->code,
|
||||
$updateCust->message
|
||||
)));
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class ProductsController extends Controller
|
|||
return view('front.products.index', compact('productsSlides', 'ranges', 'meatTypes', 'ct', 'labels'));
|
||||
}
|
||||
|
||||
public function filter(Model $model, SubRange $subrange = null)
|
||||
public function filter(Model $model, SubRange $slugSubRange = null)
|
||||
{
|
||||
// On récupère les mêmes données qu'au dessus pour l'affichage
|
||||
$productsSlides = ProductSliderPictures::where('status', 1)->orderBy('order', 'ASC')->get();
|
||||
|
|
@ -52,11 +52,11 @@ class ProductsController extends Controller
|
|||
/** @var \App\Models\Range */
|
||||
$gamme = $model;
|
||||
$subranges = $gamme->subranges()->orderBy('order')->get();
|
||||
if ($subrange) {
|
||||
if ($slugSubRange) {
|
||||
$title = $gamme->name;
|
||||
$productsList = $gamme->products()
|
||||
->where('status', true)
|
||||
->where('sub_range_id', $subrange->id)
|
||||
->where('sub_range_id', $slugSubRange->id)
|
||||
->orderBy('order')
|
||||
->get();
|
||||
} else {
|
||||
|
|
@ -88,7 +88,9 @@ class ProductsController extends Controller
|
|||
default:
|
||||
abort(404);
|
||||
break;
|
||||
}//end switch
|
||||
} //end switch
|
||||
|
||||
$subrange = $slugSubRange;
|
||||
|
||||
return view('front.products.index', compact(
|
||||
'productsList',
|
||||
|
|
@ -106,11 +108,17 @@ class ProductsController extends Controller
|
|||
));
|
||||
}
|
||||
|
||||
public function show(Products $product)
|
||||
/**
|
||||
* Display product
|
||||
*
|
||||
* @param \App\Models\Products $frontProduct
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
||||
*/
|
||||
public function show(Products $frontProduct)
|
||||
{
|
||||
$recipeVideo = $product->recipe()->first();
|
||||
$recipeVideo = $frontProduct->recipe()->first();
|
||||
|
||||
$recipes = $product->recipes()->get();
|
||||
$recipes = $frontProduct->recipes()->get();
|
||||
$ids = [];
|
||||
foreach ($recipes as $r) {
|
||||
$ids[] = $r->id;
|
||||
|
|
@ -119,6 +127,7 @@ class ProductsController extends Controller
|
|||
$generalConfig = app()->view->getShared()['GeneralConfigGlobal'] ?? null;
|
||||
$generalConfig = $generalConfig ? $generalConfig->where('type', GeneralConfigType::rsm())->first() : null;
|
||||
$recipes = Recipes::whereIn('id', $ids)->where('status', true)->get();
|
||||
$product = $frontProduct;
|
||||
|
||||
return view('front.products.product', compact('product', 'recipes', 'recipeVideo', 'generalConfig'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ class Kernel extends HttpKernel
|
|||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'redirect-slugs' => \App\Http\Middleware\RedirectOldSlugs::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
|
|
|
|||
112
app/Http/Middleware/RedirectOldSlugs.php
Normal file
112
app/Http/Middleware/RedirectOldSlugs.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Enums\BreedingPageType;
|
||||
use App\Models\BreedingPage;
|
||||
use App\Models\OldSlugable;
|
||||
use App\Models\Products;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RedirectOldSlugs
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
return $this->handleOldSlug(
|
||||
$request,
|
||||
'publishedBreedingPage',
|
||||
BreedingPage::class,
|
||||
['breedingPageType'],
|
||||
function ($oldSlug, $breedingPageType) {
|
||||
if (
|
||||
\is_object($oldSlug) and
|
||||
\is_object($breedingPageType) and
|
||||
\get_class($breedingPageType) === BreedingPageType::class
|
||||
) {
|
||||
/** @var \App\Models\BreedingPage */
|
||||
$publishedBreedingPage = BreedingPage::query()
|
||||
->where('id', $oldSlug->old_slugable_id)->firstOrFail();
|
||||
return redirect(route('breeding-page.show', [
|
||||
'breedingPageType' => $breedingPageType,
|
||||
'publishedBreedingPage' => $publishedBreedingPage
|
||||
]), 301);
|
||||
}
|
||||
}
|
||||
) ?? $this->handleOldSlug(
|
||||
$request,
|
||||
'publishedProduct',
|
||||
Products::class,
|
||||
[],
|
||||
function ($oldSlug) {
|
||||
if (\is_object($oldSlug)) {
|
||||
/** @var \App\Models\Products */
|
||||
$publishedProduct = Products::query()
|
||||
->where('id', $oldSlug->old_slugable_id)->firstOrFail();
|
||||
return redirect(route('product.show', [
|
||||
'publishedProduct' => $publishedProduct->slug
|
||||
]), 301);
|
||||
}
|
||||
}
|
||||
) ?? $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method for handling old slugs
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request The actual request.
|
||||
* @param string $routeParameterName The route parameter name concerned by the old slug.
|
||||
* @param string $className The model class name that is old slugable.
|
||||
* @param array $otherParameters Other parameters in the route.
|
||||
* @param callable $handleRedirectAttempt The callback where to actually to the redirect.
|
||||
* @return null|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function handleOldSlug(
|
||||
Request $request,
|
||||
string $routeParameterName,
|
||||
string $className,
|
||||
array $otherParameters,
|
||||
callable $handleRedirectAttempt
|
||||
): ?RedirectResponse {
|
||||
$parameter = $request->route($routeParameterName);
|
||||
$otherParameters = \collect($otherParameters)->map(function (string $parameterName) use ($request) {
|
||||
return $request->route($parameterName);
|
||||
});
|
||||
/** @var boolean */
|
||||
$anyParameterNull = $otherParameters->reduce(function ($carry, $parameter) {
|
||||
return \is_null($carry) ? \is_null($parameter) : \is_null($parameter) and \is_null($carry);
|
||||
});
|
||||
|
||||
// * Ignore already resolved
|
||||
if (\is_object($parameter)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// * Ignore other routes (not corresponding parameters)
|
||||
if (\is_null($parameter) or $anyParameterNull) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$parameterOldSlug = OldSlugable::where('slug', $parameter)
|
||||
->where('old_slugable_type', $className)->first();
|
||||
|
||||
$response = \call_user_func_array($handleRedirectAttempt, \array_merge(
|
||||
[$parameterOldSlug],
|
||||
$otherParameters->all()
|
||||
));
|
||||
|
||||
// * The model was not resolved.
|
||||
if (!$response and \is_string($parameter)) {
|
||||
\abort(404);
|
||||
}
|
||||
|
||||
return (\is_object($response) and \get_class($response) === RedirectResponse::class) ? $response : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,19 +3,38 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class SecureHeaders
|
||||
{
|
||||
// Enumerate headers which you do not want in your application's responses.
|
||||
// Great starting point would be to go check out @Scott_Helme's:
|
||||
// https://securityheaders.com/
|
||||
/**
|
||||
* Enumerate headers which you do not want in your application's responses.
|
||||
* Great starting point would be to go check out @Scott_Helme's:
|
||||
* https://securityheaders.com/
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $unwantedHeaderList = [
|
||||
'X-Powered-By',
|
||||
'Server',
|
||||
];
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
View::share('nonce', $nonce = \uniqid());
|
||||
// * For VueJS dev tool to execute
|
||||
$jsDev = config('app.debug') ? "'unsafe-eval' 'unsafe-inline'" : "'nonce-{$nonce}' 'strict-dynamic'";
|
||||
$reportUri = Route::has('cspReportUri') ?
|
||||
\sprintf('report-uri %s', \parse_url(route('cspReportUri'), \PHP_URL_PATH)) : '';
|
||||
$this->removeUnwantedHeaders($this->unwantedHeaderList);
|
||||
$response = $next($request);
|
||||
$response->headers->set('Referrer-Policy', 'no-referrer-when-downgrade');
|
||||
|
|
@ -24,19 +43,48 @@ class SecureHeaders
|
|||
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
|
||||
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;');
|
||||
$cspPolicies = [
|
||||
'frame-src ' . implode(" ", [
|
||||
'\'self\'',
|
||||
'https://www.youtube.com',
|
||||
'https://vimeo.com/',
|
||||
'https://player.vimeo.com/',
|
||||
'https://www.google.com/recaptcha/',
|
||||
'https://recaptcha.google.com/recaptcha/'
|
||||
]) . ';',
|
||||
"style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://fonts.googleapis.com;",
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.cloudflare.com https://www.googletagmanager.com https://www.google-analytics.com https://maps.googleapis.com https://fonts.googleapis.com;"
|
||||
'script-src ' . implode(" ", [
|
||||
'\'self\'',
|
||||
'\'unsafe-inline\'',
|
||||
'\'unsafe-eval\'',
|
||||
'https://cdnjs.cloudflare.com',
|
||||
'https://*.googletagmanager.com',
|
||||
'https://www.google-analytics.com',
|
||||
'https://maps.googleapis.com',
|
||||
'https://fonts.googleapis.com',
|
||||
'https://www.google.com/recaptcha/',
|
||||
'https://www.gstatic.com/recaptcha/',
|
||||
'https://yl.s-web.fr',
|
||||
]) . ' ' . $jsDev . ';'
|
||||
];
|
||||
$response->headers->set(
|
||||
'Content-Security-Policy',
|
||||
implode(' ', $cspPolicies)
|
||||
implode(' ', $cspPolicies) . $reportUri
|
||||
);
|
||||
$response->headers->set('Feature-Policy', 'fullscreen \'self\';');
|
||||
$response->headers->set('Feature-Policy', \implode(',', [
|
||||
'fullscreen', 'accelerometer', 'encrypted-media',
|
||||
'gyroscope', 'picture-in-picture'
|
||||
]) . ';');
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function removeUnwantedHeaders($headerList)
|
||||
/**
|
||||
* Remove unwanted headers
|
||||
*
|
||||
* @param array $headerList
|
||||
* @return void
|
||||
*/
|
||||
private function removeUnwantedHeaders(array $headerList)
|
||||
{
|
||||
foreach ($headerList as $header) {
|
||||
header_remove($header);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use App\Enums\EleveurOcbStatus;
|
||||
use App\Enums\GeoType;
|
||||
|
|
@ -121,7 +121,7 @@ class StoreOcbBreeder extends FormRequest
|
|||
foreach ($this->inuavs as $inuav) {
|
||||
$q = $q->where('inuavs', 'LIKE', "%$inuav%");
|
||||
}
|
||||
// update condition
|
||||
// *update condition
|
||||
if ($this->breeder) {
|
||||
$q->where('id', '!=', $this->breeder->id);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class BoutiqueBuyRequest extends FormRequest
|
|||
{
|
||||
return [
|
||||
'coords' => trans('vos coordonnées'),
|
||||
'coords.civility' => trans('civilitée dans vos coordonnées'),
|
||||
'coords.civility' => trans('civilité dans vos coordonnées'),
|
||||
'coords.firstname' => trans('prénom dans vos coordonnées'),
|
||||
'coords.lastname' => trans('nom dans vos coordonnées'),
|
||||
'coords.address' => trans('adresse dans vos coordonnées'),
|
||||
|
|
@ -76,7 +76,7 @@ class BoutiqueBuyRequest extends FormRequest
|
|||
'coords.city' => trans('ville dans vos coordonnées'),
|
||||
'coords.email' => trans('e-mail dans vos coordonnées'),
|
||||
'shipping' => trans('votre adresse de livraison'),
|
||||
'shipping.civility' => trans('civilitée dans votre adresse de livraison'),
|
||||
'shipping.civility' => trans('civilité dans votre adresse de livraison'),
|
||||
'shipping.firstname' => trans('prénom dans votre adresse de livraison'),
|
||||
'shipping.lastname' => trans('nom dans votre adresse de livraison'),
|
||||
'shipping.address' => trans('adresse dans votre adresse de livraison'),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Http\Requests;
|
|||
|
||||
use App\Enums\ContactFormCivility;
|
||||
use App\Enums\ContactFormType;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
||||
|
||||
|
|
@ -26,6 +27,8 @@ class ContactFormRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
|
||||
if ($this->type == ContactFormType::onepage()->value) {
|
||||
app()->setLocale('nl');
|
||||
}
|
||||
|
|
@ -38,12 +41,14 @@ class ContactFormRequest extends FormRequest
|
|||
'required',
|
||||
new EnumIsValidRule(ContactFormType::class)
|
||||
],
|
||||
'lastname' => 'required|min:2',
|
||||
'firstname' => 'required|min:2',
|
||||
// * max arcadia 50 chars
|
||||
'lastname' => 'required|min:2|max:50',
|
||||
// * max arcadia 50 chars
|
||||
'firstname' => 'required|min:2|max:50',
|
||||
'address' => 'required|min:4',
|
||||
'email' => 'required|email:rfc,dns,spoof',
|
||||
'postal' => 'required|min:3|max:10',
|
||||
// max arcadia 10 chars
|
||||
// * max arcadia 10 chars
|
||||
'town' => 'required|min:3|max:90',
|
||||
'phone' => 'required|min:8|max:14',
|
||||
'onepagesubject' => 'sometimes|min:10|max:250',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
|
@ -36,6 +37,8 @@ class CustomerRegisterRequest extends FormRequest
|
|||
*/
|
||||
public function rules()
|
||||
{
|
||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
|
||||
return [
|
||||
'email' => 'required|email:rfc,dns,spoof,filter|max:255|unique:customers,email',
|
||||
'username' => 'required|string|min:1|max:255|unique:customers,username',
|
||||
|
|
@ -78,13 +81,22 @@ class CustomerRegisterRequest extends FormRequest
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return [
|
||||
'postcode' => 'Code postal'
|
||||
'postcode' => 'Code postal',
|
||||
'username' => 'pseudo'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -17,13 +17,19 @@ class UpdateEngagement extends FormRequest
|
|||
*/
|
||||
public function authorize()
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$this->merge([
|
||||
'status' => $this->status === null ? 0 : 1
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? true : false
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +40,8 @@ class UpdateEngagement extends FormRequest
|
|||
public function rules()
|
||||
{
|
||||
$rules = [
|
||||
'title' => 'required|string|min:7'
|
||||
'title' => 'required|string|min:7',
|
||||
'status' => 'required|boolean'
|
||||
];
|
||||
if ($this->engagement->type == EngagementType::header()) {
|
||||
$rules = array_merge($rules, [
|
||||
|
|
@ -129,9 +136,14 @@ class UpdateEngagement extends FormRequest
|
|||
}//end if
|
||||
break;
|
||||
case InputType::url()->value:
|
||||
if ($iptName === "link") {
|
||||
$ruleAtt = "sometimes";
|
||||
} else {
|
||||
$ruleAtt = "required";
|
||||
}
|
||||
$rules = array_merge($rules, [
|
||||
"content.$i.content.$iptName.value" => [
|
||||
'required', 'url',
|
||||
$ruleAtt, 'url',
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
try {
|
||||
|
|
@ -172,10 +184,10 @@ class UpdateEngagement extends FormRequest
|
|||
"content.$i.content.$iptName.value" => 'boolean'
|
||||
]);
|
||||
break;
|
||||
}//end switch
|
||||
}//end foreach
|
||||
}//end foreach
|
||||
}//end if
|
||||
} //end switch
|
||||
} //end foreach
|
||||
} //end foreach
|
||||
} //end if
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
app/Jobs/Arcadia/RemoveOldXmlEntries.php
Normal file
24
app/Jobs/Arcadia/RemoveOldXmlEntries.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs\Arcadia;
|
||||
|
||||
use App\Models\XmlTraceability;
|
||||
|
||||
class RemoveOldXmlEntries
|
||||
{
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
try {
|
||||
$q = XmlTraceability::query();
|
||||
$q->where('updated_at', '<=', now()->subMonths(config('tracea.keepAbatage', 24)));
|
||||
$q->delete();
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
59
app/Jobs/IncrementContactStatsJob.php
Normal file
59
app/Jobs/IncrementContactStatsJob.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Enums\ContactFormType;
|
||||
use App\Models\Contact;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class IncrementContactStatsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var \App\Enums\ContactFormType
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Enums\ContactFormType $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ContactFormType $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$insert = function (ContactFormType $type) {
|
||||
$contact = Contact::where('date', '=', Carbon::now()->isoFormat('YYYY-MM-DD'))->firstOrNew();
|
||||
// * Can't do $contact->counter[$type->value]++ => ErrorException
|
||||
$d = $contact->values;
|
||||
$d[$type->value]++;
|
||||
$contact->values = $d;
|
||||
$contact->saveOrFail();
|
||||
};
|
||||
try {
|
||||
$insert($this->type);
|
||||
} catch (\Exception $e) {
|
||||
// * Handle user requests colisions
|
||||
$insert($this->type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ class SendArchadiaMail implements ShouldQueue
|
|||
|
||||
/**
|
||||
* To be serialized by jobs system
|
||||
*
|
||||
* @var MailContactData
|
||||
* */
|
||||
private $data;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class SendNLMail implements ShouldQueue
|
|||
|
||||
/**
|
||||
* To be serialized by jobs system
|
||||
*
|
||||
* @var MailContactData
|
||||
* */
|
||||
private $data;
|
||||
|
|
@ -23,6 +24,7 @@ class SendNLMail implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Models\MailContactData $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailContactData $data)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class SendOrderToArchadia implements ShouldQueue
|
|||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class SendPasserelleMail implements ShouldQueue
|
|||
|
||||
/**
|
||||
* To be serialized by jobs system
|
||||
*
|
||||
* @var MailContactData
|
||||
* */
|
||||
private $data;
|
||||
|
|
@ -24,6 +25,7 @@ class SendPasserelleMail implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \App\Models\MailContactData $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailContactData $data)
|
||||
|
|
|
|||
|
|
@ -469,7 +469,6 @@ class XmlIncoReader extends XmlJobs
|
|||
* <TYP_PORTION><![CDATA[Approximatif]]></TYP_PORTION>
|
||||
* extracted as "TYP_PORTION" => "Approximatif"
|
||||
*
|
||||
*
|
||||
* @param \SimpleXMLElement|false $sxe
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -484,15 +483,18 @@ class XmlIncoReader extends XmlJobs
|
|||
if ($value->count()) {
|
||||
$extraction = $this->extract($value);
|
||||
|
||||
if(count($extraction)
|
||||
&& array_key_exists("code",$extraction)
|
||||
&& array_key_exists("libelle",$extraction)) {
|
||||
$val = strval($extraction['libelle']);
|
||||
if (
|
||||
count($extraction)
|
||||
&& array_key_exists("code", $extraction)
|
||||
&& array_key_exists("libelle", $extraction)
|
||||
) {
|
||||
$val = strval($extraction['libelle']);
|
||||
$extract[$key] = strlen($val) ? $val : null;
|
||||
continue;
|
||||
}
|
||||
|
||||
$extract[$key][] = $extraction; //$this->extract($value);
|
||||
$extract[$key][] = $extraction;
|
||||
// $this->extract($value);
|
||||
continue;
|
||||
}
|
||||
$value = strval($value);
|
||||
|
|
@ -501,7 +503,7 @@ class XmlIncoReader extends XmlJobs
|
|||
} else {
|
||||
$extract[$key] = strlen($value) ? $value : null;
|
||||
}
|
||||
}
|
||||
}//end foreach
|
||||
return $extract;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Jobs;
|
|||
use App\Enums\LogType;
|
||||
use App\Exceptions\AbortXmlImportException;
|
||||
use App\Exceptions\InvalidXmlException;
|
||||
use App\Lib\Utils;
|
||||
use ErrorException;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
|
@ -53,13 +52,16 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
/**
|
||||
* Parse Data from the XML and gives it to the callback
|
||||
*
|
||||
* @param string $entityName
|
||||
* @param string $modelClass
|
||||
* @param string $entityName
|
||||
* @param string $modelClass
|
||||
* @param callable $callback
|
||||
* @return void
|
||||
* @throws InvalidXmlException InvalidXmlException.
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
*/
|
||||
// phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||
protected function parseData(string $entityName, string $modelClass, callable $callback = null): void
|
||||
{
|
||||
// phpcs:enable
|
||||
/** @var Filesystem */
|
||||
$disk = $this->getDisk();
|
||||
$this->log('Démarrage du traitement');
|
||||
|
|
@ -110,7 +112,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
$lines[] = $line;
|
||||
}
|
||||
|
||||
// Mise en base des données
|
||||
// Mise en base des données.
|
||||
foreach ($lines as $line) {
|
||||
/** @var array Unique Key columns */
|
||||
$uniqueColumnsKey = [];
|
||||
|
|
@ -125,6 +127,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
} catch (InvalidXmlException $e) {
|
||||
$message = $e->getMessage();
|
||||
if (get_class($e) === QueryException::class) {
|
||||
/** @var \Illuminate\Database\QueryException $e */
|
||||
$message = implode(' ', $e->errorInfo);
|
||||
}
|
||||
$this->log(
|
||||
|
|
@ -151,7 +154,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
);
|
||||
$this->sendErrorParseEmailToServiceWeb($e);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
} catch (AbortXmlImportException $e) {
|
||||
$this->log(
|
||||
sprintf(
|
||||
|
|
@ -164,9 +167,9 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
);
|
||||
$this->sendErrorParseEmailToServiceWeb($e);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
} catch (FileNotFoundException | QueryException $e) {
|
||||
// This happens because of concurent xml jobs read
|
||||
// This happens because of concurent xml jobs read.
|
||||
$message = $e->getMessage();
|
||||
if (get_class($e) === QueryException::class) {
|
||||
$message = implode(' ', $e->errorInfo);
|
||||
|
|
@ -181,12 +184,12 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
LogType::debug()
|
||||
);
|
||||
continue;
|
||||
// ignore the file
|
||||
// Ignore the file.
|
||||
}//end try
|
||||
$this->moveToArchives($filename);
|
||||
}//end foreach
|
||||
|
||||
// Clear old archives
|
||||
// Clear old archives.
|
||||
$this->clearOldArchives();
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +225,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
*
|
||||
* @param array $fields
|
||||
* @return array
|
||||
* @throws AbortXmlImportException
|
||||
* @throws AbortXmlImportException AbortXmlImportException.
|
||||
*/
|
||||
protected function processFields(array $fields): array
|
||||
{
|
||||
|
|
@ -235,7 +238,7 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
throw new AbortXmlImportException(sprintf('The field %s is not allowed to be null', $key));
|
||||
}
|
||||
if (is_array($field)) {
|
||||
// Flatten data
|
||||
// Flatten data.
|
||||
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($field));
|
||||
foreach ($it as $k => $f) {
|
||||
$ko = strtolower(sprintf('%s.%s', $key, $k));
|
||||
|
|
@ -317,11 +320,26 @@ abstract class XmlJobs extends XArcadiaFlux
|
|||
return $isXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* sendErrorParseEmailToServiceWeb
|
||||
*
|
||||
* @param Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function sendErrorParseEmailToServiceWeb(Throwable $e)
|
||||
{
|
||||
Utils::sendEmailErrorManually($e);
|
||||
if (app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sendInvalidXmlEmail
|
||||
*
|
||||
* @param string $filename
|
||||
* @param Throwable $e
|
||||
* @return void
|
||||
*/
|
||||
protected function sendInvalidXmlEmail(string $filename, Throwable $e)
|
||||
{
|
||||
$message = $e->getPrevious()->getMessage();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,18 @@ use App\Models\XmlTraceability;
|
|||
|
||||
class XmlTracaReader extends XmlJobs
|
||||
{
|
||||
/**
|
||||
* Le disque a utiliser
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $disk = 'tracabilite';
|
||||
|
||||
/**
|
||||
* Les colonnes a prendre dans le flux.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $takeColumns = [
|
||||
'NO_LOT' => 'lot_code',
|
||||
'NO_OPA' => 'opa_code',
|
||||
|
|
@ -17,17 +27,51 @@ class XmlTracaReader extends XmlJobs
|
|||
'CODE_TRACA_PROD_ELAB' => 'produit_elab'
|
||||
];
|
||||
|
||||
/**
|
||||
* Les données sont encapsulés dans le xml
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $encapsulate = true;
|
||||
|
||||
/**
|
||||
* Les champs qui peuvents être null
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $nullableFields = [
|
||||
'opa_code', 'inuav_code',
|
||||
'abatage_code', 'abatage_date'
|
||||
];
|
||||
|
||||
/**
|
||||
* La clé unique pour la table
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $uniqueKeyField = ['lot_code'];
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->parseData('ENRLOT', XmlTraceability::class);
|
||||
$this->parseData(
|
||||
'ENRLOT',
|
||||
XmlTraceability::class,
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function (\SimpleXMLElement $xmlContent, array &$line) {
|
||||
$abatage_date = \explode('.', $line['abatage_date']);
|
||||
// * Inverser année et jours a cause du flux
|
||||
$line['abatage_date'] = \sprintf(
|
||||
'20%s/%s/%s',
|
||||
$abatage_date[2],
|
||||
$abatage_date[1],
|
||||
$abatage_date[0]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
190
app/Lib/Helpers/ExceptionsHelper.php
Normal file
190
app/Lib/Helpers/ExceptionsHelper.php
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib\Helpers;
|
||||
|
||||
class ExceptionsHelper
|
||||
{
|
||||
/**
|
||||
* Handle sentry event
|
||||
*
|
||||
* @param \Sentry\Event $event
|
||||
* @return null|\Sentry\Event
|
||||
*/
|
||||
public static function sentryEventHandler(\Sentry\Event $event): ?\Sentry\Event
|
||||
{
|
||||
// Remove unwanted reports.
|
||||
$event->setModules([]);
|
||||
$event->setOsContext(null);
|
||||
|
||||
/** @var \Sentry\ExceptionDataBag[] */
|
||||
$exceptionBag = [];
|
||||
foreach ($event->getExceptions() as $exceptionDataBag) {
|
||||
$exceptionBag[] = self::getAnonymizedSentryException($exceptionDataBag);
|
||||
}
|
||||
$event->setExceptions($exceptionBag);
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonimize Sentry Exception bag
|
||||
*
|
||||
* @param \Sentry\ExceptionDataBag $exceptionDataBag
|
||||
* @return \Sentry\ExceptionDataBag
|
||||
*/
|
||||
private static function getAnonymizedSentryException(
|
||||
\Sentry\ExceptionDataBag $exceptionDataBag
|
||||
): \Sentry\ExceptionDataBag {
|
||||
$exceptionDataBag->setValue(self::getAnonymizedMessage($exceptionDataBag->getValue()));
|
||||
if ($stackTrace = $exceptionDataBag->getStacktrace()) {
|
||||
$exceptionDataBag->setStacktrace(self::getAnonymizedSentryStackTrace($stackTrace));
|
||||
}
|
||||
return $exceptionDataBag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymise sentry stacktrace
|
||||
*
|
||||
* @param \Sentry\Stacktrace $stackTrace
|
||||
* @return \Sentry\Stacktrace
|
||||
*/
|
||||
private static function getAnonymizedSentryStackTrace(\Sentry\Stacktrace $stackTrace): \Sentry\Stacktrace
|
||||
{
|
||||
/** @var \Sentry\Frame[] */
|
||||
$frames = \array_reverse($stackTrace->getFrames(), true);
|
||||
$i = \count($frames) - 1;
|
||||
// * Remove all but keep first (index.php).
|
||||
while ($i-- > 0) {
|
||||
$stackTrace->removeFrame(count($stackTrace->getFrames()) - 1);
|
||||
}
|
||||
foreach ($frames as $index => $frame) {
|
||||
$frame->setPostContext([]);
|
||||
$frame->setPreContext([]);
|
||||
$frame->setContextLine('');
|
||||
$frame->setVars(self::getAnonymizedSentryParams($frame->getVars()));
|
||||
$stackTrace->addFrame($frame);
|
||||
if ($index === 0) {
|
||||
$stackTrace->removeFrame(count($stackTrace->getFrames()) - 1);
|
||||
}
|
||||
}
|
||||
return $stackTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get anonymized sentry params
|
||||
*
|
||||
* @param mixed[] $params
|
||||
* @return string[]
|
||||
*/
|
||||
private static function getAnonymizedSentryParams(array $params): array
|
||||
{
|
||||
foreach ($params as &$param) {
|
||||
$type = \strtolower(\gettype($param));
|
||||
if (\is_string($param)) {
|
||||
$type = \explode(' ', \trim($param))[0] ?? null;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'Lambda':
|
||||
case 'Object':
|
||||
continue 2;
|
||||
case 'array':
|
||||
$param = sprintf('Array(%d)', \count($param));
|
||||
continue 2;
|
||||
default:
|
||||
if (\is_numeric($param)) {
|
||||
$param = \ucfirst($type);
|
||||
continue 2;
|
||||
}
|
||||
if (\is_string($param)) {
|
||||
$param = sprintf('String(%d)', \strlen($param));
|
||||
continue 2;
|
||||
}
|
||||
} //end switch
|
||||
} //end foreach
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Anonymize at least Sql queries
|
||||
*
|
||||
* @param string $message
|
||||
* @return string
|
||||
*/
|
||||
public static function getAnonymizedMessage(string $message): string
|
||||
{
|
||||
$message = \preg_replace('/^(.*)( \(SQL:.*\))$/', '$1', $message) ?? $message;
|
||||
if ($sqlPos = \strpos($message, 'to use near')) {
|
||||
$message = \mb_strcut($message, 0, $sqlPos);
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anonymize stack trace
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @return string
|
||||
*/
|
||||
public static function getAnonymizedStackTrace(\Throwable $e): string
|
||||
{
|
||||
$projectPath = \realpath(\sprintf('%s/../', \app_path()));
|
||||
$traceStack = $e->getTrace();
|
||||
$traceStr = '';
|
||||
$maxStackStage = 0;
|
||||
foreach ($traceStack as $stackStage => $stack) {
|
||||
$maxStackStage = $stackStage;
|
||||
$traceStr .= \sprintf(
|
||||
'#%s %s(%d): ',
|
||||
$stackStage,
|
||||
str_replace($projectPath, '', $stack['file'] ?? ''),
|
||||
$stack['line'] ?? ''
|
||||
);
|
||||
if (isset($stack['class'])) {
|
||||
$traceStr .= "{$stack['class']}->{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
} elseif (isset($stack['function'])) {
|
||||
$traceStr .= "{$stack['function']}(";
|
||||
if (isset($stack['args'])) {
|
||||
$traceStr .= self::handleArgs($stack);
|
||||
}
|
||||
$traceStr .= ")\n";
|
||||
}
|
||||
} //end foreach
|
||||
$maxStackStage++;
|
||||
$traceStr .= "#$maxStackStage {main}";
|
||||
return $traceStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Args
|
||||
*
|
||||
* @param array $stack
|
||||
* @return string
|
||||
*/
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
65
app/Lib/Helpers/ToolboxHelper.php
Normal file
65
app/Lib/Helpers/ToolboxHelper.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib\Helpers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class ToolboxHelper
|
||||
{
|
||||
/**
|
||||
* Validate recaptcha
|
||||
*
|
||||
* @param Request $request
|
||||
* @param boolean $isV3
|
||||
* @return void
|
||||
*/
|
||||
public static function validateRecaptcha(Request $request, bool $isV3 = true)
|
||||
{
|
||||
Validator::validate($request->all(), [
|
||||
'g-recaptcha-response' => [
|
||||
'required', 'string',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
function ($attribute, $value, $fail) use ($isV3) {
|
||||
try {
|
||||
$response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [
|
||||
'secret' => config('services.google.recaptcha.private'),
|
||||
'response' => \strval($value),
|
||||
'remoteip' => app('clientIp')
|
||||
]);
|
||||
if ($e = $response->toException()) {
|
||||
throw $e;
|
||||
}
|
||||
if ($isV3) {
|
||||
if (
|
||||
!$response->json('success') or
|
||||
!$response->json('challenge_ts') or
|
||||
Carbon::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
|
||||
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST) or
|
||||
!$response->json('score')
|
||||
) {
|
||||
throw new \RuntimeException();
|
||||
}
|
||||
if (\floatval($response->json('score')) < 0.8) {
|
||||
$fail("Vous n'avez pas obtenu un score assez élevé lors de la validation du recaptcha");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!$response->json('success') or
|
||||
!$response->json('challenge_ts') or
|
||||
Carbon::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
|
||||
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST)
|
||||
) {
|
||||
throw new \RuntimeException();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$fail('Erreur lors de la validation du formulaire veuillez réssayer');
|
||||
} //end try
|
||||
}
|
||||
]
|
||||
], [], ['g-recaptcha-response' => 'reCaptcha']);
|
||||
}
|
||||
}
|
||||
91
app/Lib/Instagram/ApiFetcher.php
Normal file
91
app/Lib/Instagram/ApiFetcher.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib\Instagram;
|
||||
|
||||
use App\Exceptions\InstaApiLimitReachedException as InstaApiException;
|
||||
use Illuminate\Http\Client\HttpClientException;
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
/**
|
||||
* Fetch Instagram Top Media List
|
||||
*
|
||||
* @package App\Lib
|
||||
*/
|
||||
class ApiFetcher
|
||||
{
|
||||
/**
|
||||
* Try to fetch media pictures from a permalink using og data.
|
||||
*
|
||||
* @param string $url
|
||||
* @return array
|
||||
* @throws \RuntimeException If a call error or a response parsing error occurs.
|
||||
*/
|
||||
public function fetchMediaPicturesFromPostPermalink(string $url): array
|
||||
{
|
||||
try {
|
||||
$response = $this->httpCall('GET', $url);
|
||||
$html = $response->body();
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadHTML($html);
|
||||
|
||||
$scripts = $dom->getElementsByTagName('script');
|
||||
return collect($scripts)->filter()->map(function (\DOMElement $script) {
|
||||
if ($script->getAttribute('type') != 'application/ld+json') {
|
||||
return null;
|
||||
}
|
||||
$entity = json_decode($script->nodeValue, true);
|
||||
if ($entity['@type'] !== 'SocialMediaPosting') {
|
||||
return null;
|
||||
}
|
||||
return \collect($entity['image'])->map(function (array $picture) {
|
||||
return $picture['url'];
|
||||
})->all();
|
||||
})->filter(function ($el) {
|
||||
return !empty($el);
|
||||
})->first() ?? [];
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
|
||||
} //end try
|
||||
}
|
||||
|
||||
/**
|
||||
* Call url and fetch result in array.
|
||||
*
|
||||
* @param string $method The HTTP VERB to use (GET, POST).
|
||||
* @param string|\Psr\Http\Message\UriInterface $uri The uri to call.
|
||||
* @param array $parameters The call parameters to pass on.
|
||||
* @return \Illuminate\Http\Client\Response
|
||||
* @throws \Error If the request method is not supported.
|
||||
* @throws \RuntimeException If something goes wrong.
|
||||
* @throws \App\Exceptions\InstaApiException If the api denies access for some reason.
|
||||
*/
|
||||
private function httpCall(
|
||||
string $method,
|
||||
$uri = '',
|
||||
array $parameters = []
|
||||
): Response {
|
||||
try {
|
||||
if (!\in_array(\strtoupper($method), ['GET', 'POST'])) {
|
||||
throw new \Error("Unsupported method {$method}");
|
||||
}
|
||||
/** @var \Illuminate\Http\Client\Response */
|
||||
$response = Http::timeout(\config('app.debug') ? 3 : 30)
|
||||
->retry(2, 100)
|
||||
->{strtolower($method)}($uri, $parameters);
|
||||
// * Throw an exception if an error occured.
|
||||
$response->throw();
|
||||
|
||||
return $response;
|
||||
} catch (HttpClientException $e) {
|
||||
/** @var \Illuminate\Http\Client\Response $response */
|
||||
if ($e instanceof \Illuminate\Http\Client\RequestException and $e->getCode() === 403) {
|
||||
$response = $e->response;
|
||||
$message = $response->json('error.message');
|
||||
$code = $response->json('error.code');
|
||||
throw new InstaApiException($message, $code, $e);
|
||||
}
|
||||
throw new \RuntimeException($e);
|
||||
} //end try
|
||||
}
|
||||
}
|
||||
50
app/Lib/Instagram/Objects/TopMedia.php
Normal file
50
app/Lib/Instagram/Objects/TopMedia.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Lib\Instagram\Objects;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* Top Media object
|
||||
*
|
||||
* @property integer $insta_id A unique instagram id that can be used for api calls.
|
||||
* @property string $type The instagram object type, commonly IMAGE or CAROUSEL_ALBUM.
|
||||
* @property string $username The instagram user name, scrapped using OG description.
|
||||
* @property string $caption The object text content.
|
||||
* @property string $permalink The uri where is stored the Instagram object.
|
||||
* @property \Carbon\Carbon $timestamp UTC timestamp from instagram api.
|
||||
* @property integer $comments_count The number of comments.
|
||||
* @property null|integer $like_count The number of likes.
|
||||
*
|
||||
* @package App\Lib\Instagram\Objects
|
||||
*/
|
||||
class TopMedia extends \stdClass
|
||||
{
|
||||
/**
|
||||
* Set this object data from Ig api data
|
||||
*
|
||||
* @param object $ig_media
|
||||
* @return void
|
||||
*/
|
||||
public function setData(object $ig_media): void
|
||||
{
|
||||
$this->insta_id = \intval($ig_media->id);
|
||||
$this->type = $ig_media->media_type;
|
||||
$this->permalink = $ig_media->permalink;
|
||||
$this->timestamp = Carbon::parse($ig_media->timestamp);
|
||||
$this->comments_count = \intval($ig_media->comments_count);
|
||||
$this->like_count = \optional($ig_media)->like_count ? \intval($ig_media->like_count) : null;
|
||||
$this->caption = $ig_media->caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this object username
|
||||
*
|
||||
* @param string $username
|
||||
* @return void
|
||||
*/
|
||||
public function setUserName(string $username): void
|
||||
{
|
||||
$this->username = $username;
|
||||
}
|
||||
}
|
||||
|
|
@ -558,6 +558,7 @@ class Mercanet
|
|||
|
||||
/**
|
||||
* Filter http request parameters
|
||||
*
|
||||
* @param array $requestParameters
|
||||
*/
|
||||
private function filterRequestParameters(array $httpRequest)
|
||||
|
|
@ -595,6 +596,7 @@ class Mercanet
|
|||
|
||||
/**
|
||||
* Checks if the response is valid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isValid()
|
||||
|
|
@ -658,6 +660,7 @@ class Mercanet
|
|||
|
||||
/**
|
||||
* Retrieves a response parameter
|
||||
*
|
||||
* @param string $param
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Lib;
|
|||
class MesBR
|
||||
{
|
||||
private $endpoint;
|
||||
|
||||
private $refCamp;
|
||||
|
||||
public function __construct($endpoint, $refCamp)
|
||||
|
|
|
|||
|
|
@ -9,20 +9,23 @@ namespace App\Lib;
|
|||
class MesBROld
|
||||
{
|
||||
private $endpoint;
|
||||
|
||||
private $refSite;
|
||||
|
||||
private $refCamp;
|
||||
|
||||
public function __construct($endpoint, $refSite, $refCamp)
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
$this->refSite = $refSite;
|
||||
$this->refCamp = $refCamp;
|
||||
$this->refSite = $refSite;
|
||||
$this->refCamp = $refCamp;
|
||||
}
|
||||
|
||||
/** Update contact *
|
||||
* NOT USED - SHOULD BE DELETED
|
||||
*
|
||||
* @param $oCrmUser
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateContact($oCrmUser)
|
||||
{
|
||||
|
|
@ -46,9 +49,10 @@ class MesBROld
|
|||
}
|
||||
|
||||
/** Update panier *
|
||||
*
|
||||
* @param $oCrmUser
|
||||
* @param $couponId
|
||||
* @param int $quantity
|
||||
* @param integer $quantity
|
||||
* @return array
|
||||
*/
|
||||
public function updatePanier($oCrmUser, $refid, $couponId, $quantity = 1)
|
||||
|
|
@ -56,7 +60,7 @@ class MesBROld
|
|||
$datas = [
|
||||
'refsite' => $this->refSite,
|
||||
'refcamp' => $this->refCamp,
|
||||
//TODO : ici il faut une id qui est ajoutée au code barre du coupon donc un hascode c'est trop long
|
||||
// TODO : ici il faut une id qui est ajoutée au code barre du coupon donc un hascode c'est trop long
|
||||
'refadherent' => $refid,
|
||||
'nom' => $oCrmUser->lastname,
|
||||
'prenom' => $oCrmUser->firstname,
|
||||
|
|
@ -66,7 +70,7 @@ class MesBROld
|
|||
'pays' => $this->getCountry($oCrmUser->country),
|
||||
'panier' => "($quantity)$couponId"
|
||||
];
|
||||
$res = $this->callAPI("GET", "/updatebasket", $datas);
|
||||
$res = $this->callAPI("GET", "/updatebasket", $datas);
|
||||
if (!$res) {
|
||||
error_log("MESBR - CODE : 999 - MESSAGE : Cannot read API Response (non json)");
|
||||
return ['status' => 'KO', 'code' => 999, 'message' => 'Cannot read API Response (non json)'];
|
||||
|
|
@ -76,7 +80,7 @@ class MesBROld
|
|||
return ['status' => 'KO', 'code' => $res->Code, 'message' => $res->Message];
|
||||
}
|
||||
$panierVerification = $this->endpoint . '/showbasket?basketid=' . $res->Panier->Panier;
|
||||
$panier_link = $this->endpoint . '/?basketid=' . $res->Panier->Panier;
|
||||
$panier_link = $this->endpoint . '/?basketid=' . $res->Panier->Panier;
|
||||
return ['status' => 'OK', 'link' => $panier_link, 'verif' => $panierVerification, 'basketId' => $res->Panier->Panier];
|
||||
}
|
||||
/** Génère le lien vers le mur (ou panier préprogrammé) **/
|
||||
|
|
@ -94,7 +98,8 @@ class MesBROld
|
|||
return 442;
|
||||
break;
|
||||
default:
|
||||
return 250; //France
|
||||
return 250;
|
||||
// France
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -104,20 +109,23 @@ class MesBROld
|
|||
switch ($method) {
|
||||
case "POST":
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
if ($data)
|
||||
if ($data) {
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
break;
|
||||
case "PUT":
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
if ($data)
|
||||
if ($data) {
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($data)
|
||||
if ($data) {
|
||||
$url = sprintf("%s?%s", $url, http_build_query($data));
|
||||
}
|
||||
}
|
||||
curl_setopt($curl, CURLOPT_URL, $this->endpoint . $url);
|
||||
curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE);
|
||||
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$result = curl_exec($curl);
|
||||
if (!$result) {
|
||||
|
|
|
|||
|
|
@ -7,14 +7,11 @@ use Exception;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use SplFileInfo;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Some utilities methods
|
||||
|
|
@ -28,6 +25,7 @@ class Utils
|
|||
* Replace stange accents
|
||||
*
|
||||
* https://stackoverflow.com/questions/3371697/replacing-accented-characters-php
|
||||
*
|
||||
* @author Jérémy Munsch <jeremy.munsch@jeremydev.ovh>
|
||||
* @param string $subject
|
||||
* @return string
|
||||
|
|
@ -132,7 +130,7 @@ class Utils
|
|||
public static function assertNoInternalUrls(string $field, string $text): string
|
||||
{
|
||||
$routes = Route::getRoutes();
|
||||
// url replace and email replace
|
||||
// Url replace and email replace.
|
||||
$text = preg_replace_callback(
|
||||
'/(?P<url>(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))/',
|
||||
function ($matches) use ($routes, $field) {
|
||||
|
|
@ -140,9 +138,9 @@ class Utils
|
|||
$url = $match;
|
||||
try {
|
||||
$request = Request::create($url);
|
||||
// if a route is match then it do not throws exception
|
||||
// If a route is match then it do not throws exception.
|
||||
if ($routes->match($request)->getPrefix() === 'bo') {
|
||||
// removes the matched url
|
||||
// Removes the matched url.
|
||||
throw ValidationException::withMessages([
|
||||
$field => trans($field) . " : Il est interdit de coller une url du Back Office Le Gaulois dans ce champ"
|
||||
]);
|
||||
|
|
@ -219,40 +217,6 @@ class Utils
|
|||
return $fullPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::emails.exception',
|
||||
'text' => 'exception-handler::emails.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)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an unique pseudo
|
||||
*
|
||||
|
|
@ -273,66 +237,4 @@ class Utils
|
|||
}
|
||||
return $pseudo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']
|
||||
);
|
||||
$traceStr .= "{$stack['class']}->{$stack['function']}(";
|
||||
$traceArgs = '';
|
||||
if (isset($stack['args'])) {
|
||||
$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) ? ',' : '');
|
||||
}
|
||||
$traceStr .= $traceArgs;
|
||||
}//end if
|
||||
$traceStr .= ")\n";
|
||||
}//end foreach
|
||||
$maxStackStage++;
|
||||
$traceStr .= "#$maxStackStage {main}";
|
||||
return $traceStr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class ContactComplainMail extends ContactMail
|
|||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\MailContactData $data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailContactData $data)
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NotifAdmin extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
private $msg;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($msg)
|
||||
{
|
||||
$this->msg = $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$msg = $this->msg;
|
||||
return $this->subject(config('app.name') . " : Erreur")->view('front.notif-admin', compact('msg'));
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ class Order extends Mailable
|
|||
protected function makePdfFile(): string
|
||||
{
|
||||
/** @var \Meneses\LaravelMpdf\LaravelMpdfWrapper */
|
||||
$mpdf = app('mpdf.wrapper');
|
||||
$mpdf = app('laravel-mpdf');
|
||||
/** @var \Meneses\LaravelMpdf\LaravelMpdf */
|
||||
$pdf = $mpdf->loadView(
|
||||
'documents.order',
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ class ReductionWon extends Mailable implements ShouldQueue
|
|||
*/
|
||||
public function __construct($user, $linkpanier)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->linkpanier = $linkpanier;
|
||||
$this->user = $user;
|
||||
$this->linkpanier = $linkpanier;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,15 +17,30 @@ class BreedingPage extends Model
|
|||
use HasFactory;
|
||||
use MiniAcfModel;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to Enums.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'type' => BreedingPageType::class,
|
||||
'media_type' => InputType::class
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'title', 'headerContent',
|
||||
'seo_title', 'seo_description',
|
||||
|
|
@ -35,16 +50,31 @@ class BreedingPage extends Model
|
|||
'video', 'content', 'status'
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function (BreedingPage $page) {
|
||||
$page->slug = Str::slug($page->title);
|
||||
static::creating(function (self $model) {
|
||||
$model->slug = Str::slug($model->title);
|
||||
OldSlugable::removeSameSlugs($model, $model->slug);
|
||||
});
|
||||
static::updating(function (BreedingPage $page) {
|
||||
$page->slug = Str::slug($page->title);
|
||||
static::updating(function (self $model) {
|
||||
$model->slug = Str::slug($model->title);
|
||||
if ($model->slug != $model->getOriginal('slug')) {
|
||||
OldSlugable::removeSameSlugs($model, $model->getOriginal('slug'));
|
||||
}
|
||||
OldSlugable::insertSlug($model);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the route key for the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return 'slug';
|
||||
|
|
|
|||
|
|
@ -3,24 +3,49 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Enums\ContactFormType;
|
||||
use App\Jobs\IncrementContactStatsJob;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class Contact extends Model
|
||||
{
|
||||
/**
|
||||
* The primary key for the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'date';
|
||||
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'date' => 'date'
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($contact) {
|
||||
$contact->date = date('Y-m-d');
|
||||
return $contact;
|
||||
static::creating(function (self $model) {
|
||||
$model->date = Carbon::now();
|
||||
$model->all = 1;
|
||||
});
|
||||
static::updating(function ($contact) {
|
||||
$contact->all++;
|
||||
// increment general counter
|
||||
return $contact;
|
||||
static::updating(function (self $model) {
|
||||
// * increment general counter
|
||||
$model->all = $model->all + 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -32,35 +57,63 @@ class Contact extends Model
|
|||
*/
|
||||
public static function incrementStat(ContactFormType $type)
|
||||
{
|
||||
$contact = static::where('date', '=', date('Y-m-d'))->firstOrNew();
|
||||
// Can't do $contact->counter[$type->value]++ => ErrorException
|
||||
$d = $contact->values;
|
||||
$d[$type->value]++;
|
||||
$contact->values = $d;
|
||||
$contact->save();
|
||||
IncrementContactStatsJob::dispatch($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values attribute
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return array
|
||||
*/
|
||||
public function getValuesAttribute($value): array
|
||||
{
|
||||
return $this->unserialize($value ?? serialize($this->counterSkeleton()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set values attribute
|
||||
*
|
||||
* @param array $value
|
||||
* @return string
|
||||
*/
|
||||
public function setValuesAttribute(array $value): string
|
||||
{
|
||||
$this->attributes['values'] = $this->serialize($value);
|
||||
return $this->attributes['values'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize value
|
||||
*
|
||||
* @param array $value
|
||||
* @return string
|
||||
*/
|
||||
private function serialize(array $value)
|
||||
{
|
||||
return serialize($this->merge($this->counterSkeleton(), $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unserialize value
|
||||
*
|
||||
* @param string $value
|
||||
* @return array
|
||||
*/
|
||||
private function unserialize(string $value)
|
||||
{
|
||||
return $this->merge($this->counterSkeleton(), unserialize($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge thow array
|
||||
*
|
||||
* TODO: Replace this with collection or array merge.
|
||||
*
|
||||
* @param array $a
|
||||
* @param array $b
|
||||
* @return array
|
||||
*/
|
||||
private function merge(array $a, array $b): array
|
||||
{
|
||||
foreach ($a as $i => $v) {
|
||||
|
|
@ -71,9 +124,14 @@ class Contact extends Model
|
|||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Counter skeleton
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function counterSkeleton(): array
|
||||
{
|
||||
return collect(ContactFormType::toArray())->mapWithKeys(function ($enum) {
|
||||
return collect(ContactFormType::toArray())->mapWithKeys(function (ContactFormType $enum) {
|
||||
if ($enum->equals(ContactFormType::none())) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace App\Models;
|
|||
|
||||
use App\Enums\DepartaimantCollectionType;
|
||||
use App\Http\Resources\CustomerCrmResource;
|
||||
use App\Lib\Utils;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
|
|
|||
|
|
@ -34,22 +34,52 @@ class DepartaimantsCollection extends Model
|
|||
protected $table = 'departaimants';
|
||||
|
||||
private static $columnTableNamePrefix = 'col';
|
||||
// Le prefix d'un table departaimant
|
||||
|
||||
/**
|
||||
* Le prefix d'un table departaimant
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private static $tableFields = 4;
|
||||
// Le nombre de colonnes des departaimants
|
||||
|
||||
/**
|
||||
* Le nombre de colonnes des departaimants
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private static $departementWidth = 2;
|
||||
// La largeur en bits d'un départaimant
|
||||
|
||||
/**
|
||||
* La largeur en bits d'un départaimant
|
||||
* * to be set in construct
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $attributes = [
|
||||
'type' => 'current'
|
||||
// to be set in construct
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $fillable = [
|
||||
'collection'
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle dynamic static method calls into the model.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
||||
* @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
|
||||
*/
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
// phpcs:enable
|
||||
if ($name === 'defaultType') {
|
||||
return DepartaimantCollectionType::current();
|
||||
}
|
||||
|
|
@ -59,8 +89,8 @@ class DepartaimantsCollection extends Model
|
|||
|
||||
/**
|
||||
* @param array $attributes
|
||||
* @throws TypeError
|
||||
* @throws BadMethodCallException
|
||||
* @throws \TypeError
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Models;
|
|||
use App\Enums\ContactFormCivility;
|
||||
use App\Enums\ContactFormType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Kwaadpepper\Enum\Traits\CastsEnums;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +15,11 @@ class MailContactData extends Model
|
|||
{
|
||||
use CastsEnums;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to Enums.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'type' => ContactFormType::class,
|
||||
'civility' => ContactFormCivility::class
|
||||
|
|
@ -56,6 +62,11 @@ class MailContactData extends Model
|
|||
'consumptionDateYear'
|
||||
];
|
||||
|
||||
/**
|
||||
* The model's attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = [
|
||||
'productName' => '',
|
||||
'productCode' => '',
|
||||
|
|
@ -95,40 +106,39 @@ class MailContactData extends Model
|
|||
/**
|
||||
* Export the model data to a Formatted Passerelle Data array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
/**
|
||||
* Removed
|
||||
* * Removed
|
||||
* 'EMETTEUR_OBJETDEMANDE' => "objet de la reclamation string",
|
||||
* 'EMETTEUR_OPT_IN' => '',
|
||||
* 'REPONSE_ETAT' => 0,
|
||||
* 'TYPE_REPONSE' => 'mail',
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function exportToPasserelleDataArray(): array
|
||||
{
|
||||
// CF PAsserrelle fields .csv
|
||||
// * CF PAsserrelle fields .csv
|
||||
return [
|
||||
// Marque le Gaulois (Obligatoire)
|
||||
// * Marque le Gaulois (Obligatoire)
|
||||
'EMETTEUR_MARQUE' => 1,
|
||||
// Obligatoire
|
||||
// * Obligatoire
|
||||
'EMETTEUR_DATE' => date("Y-m-d"),
|
||||
// Obligatoire
|
||||
// * Obligatoire
|
||||
'EMETTEUR_HEURE' => date("h:i:s"),
|
||||
'EMETTEUR_CIVILITE' => $this->civility->value,
|
||||
// Obligatoire
|
||||
'EMETTEUR_NOM' => $this->lastname,
|
||||
// Obligatoire
|
||||
// * Obligatoire Limité a 50
|
||||
'EMETTEUR_NOM' => Str::limit($this->lastname, 50, ''),
|
||||
// * Obligatoire
|
||||
'EMETTEUR_PRENOM' => $this->firstname,
|
||||
'EMETTEUR_ADRESSE1' => $this->address,
|
||||
'EMETTEUR_ADRESSE2' => '',
|
||||
'EMETTEUR_CP' => $this->postal,
|
||||
// Obligatoire
|
||||
// * Obligatoire
|
||||
'EMETTEUR_VILLE' => $this->town,
|
||||
'EMETTEUR_EMAIL' => $this->email,
|
||||
'EMETTEUR_TELEPHONE' => $this->phone,
|
||||
'EMETTEUR_PAYS' => 'France',
|
||||
'EMETTEUR_NOM_PRODUIT' => $this->productName,
|
||||
// Obligatoire
|
||||
// * Obligatoire
|
||||
'EMETTEUR_EAN13' => $this->productCode,
|
||||
'EMETTEUR_DATE_LIMITE_CONSO' => sprintf(
|
||||
'%s/%s/%s',
|
||||
|
|
@ -149,15 +159,15 @@ class MailContactData extends Model
|
|||
),
|
||||
'LIEU_ACHAT' => $this->buyPlace,
|
||||
|
||||
// FUCK passerelle et leur DTD qui n'existe pas cf: resources/documents
|
||||
// * FUCK passerelle et leur DTD qui n'existe pas cf: resources/documents
|
||||
// * Recla conso ?
|
||||
'EMETTEUR_OBJETDEMANDE' => 3,
|
||||
// Recla conso ?
|
||||
// * doit être vide ?
|
||||
'EMETTEUR_OPT_IN' => '',
|
||||
// doit être vide ?
|
||||
// * c'est quoi ça ?
|
||||
'REPONSE_ETAT' => 0,
|
||||
// c'est quoi ça ?
|
||||
// * ok
|
||||
'TYPE_REPONSE' => 'mail'
|
||||
// ok
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,16 +11,25 @@ use Illuminate\Support\Facades\Storage;
|
|||
use Illuminate\Support\Str;
|
||||
use Kwaadpepper\Enum\Traits\CastsEnums;
|
||||
|
||||
// old Breeders
|
||||
class OCBBreeder extends BreederForGmap
|
||||
{
|
||||
use CastsEnums;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'display' => 'boolean',
|
||||
'inuavs' => 'array'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to Enums.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'presentation_type' => PresentationType::class,
|
||||
'ocbStatus' => EleveurOcbStatus::class,
|
||||
|
|
@ -28,8 +37,18 @@ class OCBBreeder extends BreederForGmap
|
|||
'geo_type' => GeoType::class
|
||||
];
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'ocb_breeders';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'breeder_code',
|
||||
'first_name',
|
||||
|
|
@ -51,6 +70,11 @@ class OCBBreeder extends BreederForGmap
|
|||
'inuavs',
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($breeder) {
|
||||
|
|
@ -96,11 +120,18 @@ class OCBBreeder extends BreederForGmap
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the route key for the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRouteKeyName()
|
||||
{
|
||||
return "slug";
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Get ocb validated breeders query
|
||||
*
|
||||
|
|
@ -111,28 +142,55 @@ class OCBBreeder extends BreederForGmap
|
|||
return static::where('ocbStatus', EleveurOcbStatus::yes());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter picture attribute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getPictureAttribute()
|
||||
{
|
||||
return $this->pictureAttribute('picture');
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter picture_1 attribute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getPicture1Attribute()
|
||||
{
|
||||
return $this->pictureAttribute('picture1');
|
||||
}
|
||||
/**
|
||||
* Getter picture_2 attribute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getPicture2Attribute()
|
||||
{
|
||||
return $this->pictureAttribute('picture2');
|
||||
}
|
||||
/**
|
||||
* Getter picture_3 attribute
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getPicture3Attribute()
|
||||
{
|
||||
return $this->pictureAttribute('picture3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Refactored picture attribute
|
||||
*
|
||||
* @param string $prop
|
||||
* @return mixed
|
||||
*/
|
||||
private function pictureAttribute(string $prop)
|
||||
{
|
||||
$p = $this->attributes[$prop];
|
||||
// For migrated urls from 2016
|
||||
// For migrated urls from 2016.
|
||||
if (
|
||||
is_null($p) or
|
||||
!strlen($p) or
|
||||
|
|
|
|||
|
|
@ -10,12 +10,27 @@ class OCBContent extends Model
|
|||
{
|
||||
use CastsEnums;
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to Enums.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'type' => OCBType::class
|
||||
];
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'ocb_content';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'picture',
|
||||
'content',
|
||||
|
|
@ -24,6 +39,11 @@ class OCBContent extends Model
|
|||
'status'
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($ocbContent) {
|
||||
|
|
|
|||
105
app/Models/OldSlugable.php
Normal file
105
app/Models/OldSlugable.php
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Keeps all old slugs for any model associated
|
||||
* Slug must be unique.
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class OldSlugable extends Model
|
||||
{
|
||||
/**
|
||||
* Indicates if the model should be timestamped.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $fillable = [
|
||||
'slug'
|
||||
];
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
// * EVENT CLOSURES.
|
||||
static::creating(function (self $model) {
|
||||
self::removeSameSlugs($model->oldSlugable, $model->oldSlugable->slug ?? '');
|
||||
});
|
||||
static::created(function (self $model) {
|
||||
$className = (new \ReflectionClass($model->oldSlugable))->getShortName();
|
||||
session()->flash('info', trans(
|
||||
'Le slug [:className -> \':oldSlug\'] redirige maintenant vers [:className -> \':newSlug\']',
|
||||
[
|
||||
'className' => $className,
|
||||
'oldSlug' => $model->slug,
|
||||
'newSlug' => $model->oldSlugable->slug
|
||||
]
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* morphTo product or range
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\morphTo
|
||||
*/
|
||||
public function oldSlugable()
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Insert an oldSlug
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return void
|
||||
* @phpcs:ignore Squiz.Commenting.FunctionComment.EmptyThrows
|
||||
* @throws \Illuminate\Database\ClassMorphViolationException
|
||||
*/
|
||||
public static function insertSlug(Model $model)
|
||||
{
|
||||
if ($model->getOriginal('slug') === $model->slug) {
|
||||
return;
|
||||
}
|
||||
|
||||
$oldSlugable = new self([
|
||||
'slug' => $model->getOriginal('slug')
|
||||
]);
|
||||
$oldSlugable->oldSlugable()->associate($model);
|
||||
$oldSlugable->saveOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove old slugs that are duplicated
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
public static function removeSameSlugs(Model $model, string $slug)
|
||||
{
|
||||
// * Remove Old of class type
|
||||
self::query()
|
||||
->where('slug', $slug)
|
||||
->where('old_slugable_type', \get_class($model))
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ use Kwaadpepper\Serial\Exceptions\SerialCasterException;
|
|||
class Code extends Model
|
||||
{
|
||||
protected $table = 'opbrcharcut_codes';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
|
|
@ -29,7 +30,6 @@ class Code extends Model
|
|||
public $timestamps = false;
|
||||
|
||||
// * RELATIONS
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customers::class);
|
||||
|
|
@ -83,7 +83,7 @@ class Code extends Model
|
|||
);
|
||||
} catch (SerialCasterException $e) {
|
||||
Log::error($e->getMessage() . " code utilisé : " . $serial);
|
||||
//return 0 invalid value for code
|
||||
// return 0 invalid value for code
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue