Compare commits
146 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b9977b779 | ||
|
|
6315c452cb | ||
|
|
fa9ca6000d | ||
|
|
7b7b456ef2 | ||
|
|
8d3d646403 | ||
|
|
436e196f8b | ||
|
|
666d79b32f | ||
|
|
3ed4e6a99f | ||
|
|
80e21dabb7 | ||
|
|
4a8691c3ab | ||
|
|
f6b5dcb42c | ||
|
|
056c265aad | ||
|
|
df39b81e40 | ||
|
|
dd2f3877a2 | ||
|
|
e86852de81 | ||
|
|
4b78418ce4 | ||
|
|
d7c69379c1 | ||
|
|
27d200ecb0 | ||
|
|
9b2e54a6a3 | ||
|
|
7a5d666b0e | ||
|
|
9bf67ce627 | ||
|
|
83cd90096e | ||
|
|
4656dd598e | ||
|
|
7333c9faf7 | ||
|
|
6bca2d4a13 | ||
|
|
e40e70aaff | ||
|
|
aefaf9a0b1 | ||
|
|
8ada25191a | ||
|
|
5f16591b85 | ||
|
|
ee7c1dc2d5 | ||
|
|
aa7715c19c | ||
|
|
348836b1ef | ||
|
|
53fa87fa17 | ||
|
|
ecaff7a068 | ||
|
|
ab85b33052 | ||
|
|
b0b836c5b9 | ||
|
|
cb8eae4a18 | ||
|
|
ec29df898b | ||
|
|
d13760ce4f | ||
|
|
8358e75212 | ||
|
|
e418f01712 | ||
|
|
5eb1df950a | ||
|
|
5d7309e21c | ||
|
|
a56e9a3e63 | ||
|
|
3b6801dc35 | ||
|
|
46828fa2e5 | ||
|
|
84c28399ab | ||
|
|
1b0ec6a3d8 | ||
|
|
ea6bc03cbe | ||
|
|
4338023e59 | ||
|
|
7b9e6cc094 | ||
|
|
0cbf60cf03 | ||
|
|
94156c7db0 | ||
|
|
466881fe9b | ||
|
|
59752b3b2e | ||
|
|
42db4816ea | ||
|
|
29108f8e28 | ||
|
|
bc96ef44b0 | ||
|
|
69fd4a00df | ||
|
|
b4159f0c83 | ||
|
|
eed1ce86d5 | ||
|
|
37913f0206 | ||
|
|
6e3f65b9ea | ||
|
|
72c0652434 | ||
|
|
6f33b697e6 | ||
|
|
4e596fb2b9 | ||
|
|
8f7a91faa9 | ||
|
|
3fef79fa72 | ||
|
|
45e298f2a9 | ||
|
|
8351c315cd | ||
|
|
ec39bb4f6f | ||
|
|
0b8b1bff0a | ||
|
|
79b1435c92 | ||
|
|
b0508da89d | ||
|
|
fb94fcb1f6 | ||
|
|
8de072695b | ||
|
|
3db48686ee | ||
|
|
b0a427df59 | ||
|
|
28625f2bf2 | ||
|
|
b658db5bf7 | ||
|
|
95d552c429 | ||
|
|
76b8b61288 | ||
|
|
88beb346a8 | ||
|
|
e8871467c0 | ||
|
|
77ad125ad2 | ||
|
|
c210e95782 | ||
|
|
dcf995bdc6 | ||
|
|
29016ad3ba | ||
|
|
d3c04bebd9 | ||
|
|
e1961fab93 | ||
|
|
54237e0f78 | ||
|
|
fa7d44d03d | ||
|
|
4d363f8fac | ||
|
|
80a394691c | ||
|
|
1648636bfa | ||
|
|
159cbbebe7 | ||
|
|
a53cfc7d55 | ||
|
|
c498e298d8 | ||
|
|
c1eed482da | ||
|
|
e2d3d7ec28 | ||
|
|
bed9d9dde6 | ||
|
|
19f6454ea3 | ||
|
|
ffdd886ddc | ||
|
|
0d17174052 | ||
|
|
50a99c7344 | ||
|
|
41dba737cb | ||
|
|
ae4ab562dc | ||
|
|
a04a65c232 | ||
|
|
fd987180bb | ||
|
|
58d359155f | ||
|
|
1532e3a31d | ||
|
|
8e9f7f8419 | ||
|
|
d5c0c06294 | ||
|
|
0333649f48 | ||
|
|
6d482c4631 | ||
|
|
14b0382cdb | ||
|
|
54e501cd03 | ||
|
|
d162f87f3e | ||
|
|
1f1d691cbe | ||
|
|
be80ca6c6a | ||
|
|
bf365eadca | ||
|
|
28a8390c41 | ||
|
|
6ee0986b48 | ||
|
|
239307c1b1 | ||
|
|
81089b8e12 | ||
|
|
30ee51d9d1 | ||
|
|
398c762b33 | ||
|
|
a952ea6ac6 | ||
|
|
8318e83d0b | ||
|
|
25d9e1cac6 | ||
|
|
cffa0f34a8 | ||
|
|
9a8e0f8f9a | ||
|
|
5854fc274b | ||
|
|
608629307f | ||
|
|
b32f5161b3 | ||
|
|
f06e87daf5 | ||
|
|
13d998ac9c | ||
|
|
fed7a112c2 | ||
|
|
f34bb70504 | ||
|
|
53ccbb5af8 | ||
|
|
8949c3b427 | ||
|
|
1963b827d8 | ||
|
|
256a8b5542 | ||
|
|
ee1622e1d8 | ||
|
|
6c63d52996 | ||
|
|
b557533b72 |
8902 changed files with 198966 additions and 619193 deletions
5
.browserslistrc
Normal file
5
.browserslistrc
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Browsers that we support
|
||||||
|
|
||||||
|
last 3 version
|
||||||
|
> 0.3%
|
||||||
|
not dead # no browsers without security updates
|
||||||
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.git
|
||||||
|
*.md
|
||||||
21
.editorconfig
Normal file
21
.editorconfig
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.vue]
|
||||||
|
indent_size = 2
|
||||||
60
.env.example
Normal file
60
.env.example
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
APP_NAME=Laravel
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://localhost
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mysql
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=laravel
|
||||||
|
DB_USERNAME=root
|
||||||
|
DB_PASSWORD=
|
||||||
|
|
||||||
|
BROADCAST_DRIVER=log
|
||||||
|
CACHE_DRIVER=file
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=sync
|
||||||
|
SESSION_DRIVER=file
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
|
||||||
|
MAIL_MAILER=smtp
|
||||||
|
MAIL_HOST=mailpit
|
||||||
|
MAIL_PORT=1025
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_ENCRYPTION=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
MAIL_CONTACTFORM_RECEIVER=
|
||||||
|
MAIL_CONTACTFORM_CUSTOMER_SERVICE_RECEIVER=
|
||||||
|
|
||||||
|
# Sentry
|
||||||
|
SENTRY_LARAVEL_DSN=
|
||||||
|
|
||||||
|
# MATOMO
|
||||||
|
MATOMO_SITE_ID=
|
||||||
|
|
||||||
|
# GOOGLE
|
||||||
|
# - RECAPTCHA
|
||||||
|
GOOGLE_RECAPTCHA_PUBLIC=
|
||||||
|
GOOGLE_RECAPTCHA_PRIVATE=
|
||||||
|
GOOGLE_RECAPTCHA_VERSION=
|
||||||
|
|
||||||
|
# UWIL ADMIN SECURE
|
||||||
|
# - LIST SEPARATED WITH ',' (Required)
|
||||||
|
UWIL_ADMIN_SECURE_CIDR_LIST=""
|
||||||
|
# - LIST SEPARATED WITH ',' (Optional)
|
||||||
|
UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST=""
|
||||||
|
|
||||||
|
|
||||||
|
# SAML
|
||||||
|
SAML2_DEFAULT_TENANT_UUID=
|
||||||
|
SAML2_SP_CERT_x509=
|
||||||
|
SAML2_SP_CERT_PRIVATEKEY=
|
||||||
|
SAML2_CONTACT_TECHNICAL_EMAIL=
|
||||||
|
SAML2_CONTACT_SUPPORT_EMAIL=
|
||||||
62
.eslintrc.json
Normal file
62
.eslintrc.json
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:vue/vue3-strongly-recommended",
|
||||||
|
"@vue/eslint-config-typescript"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.vue"],
|
||||||
|
"rules": {
|
||||||
|
"no-undef": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.vue"],
|
||||||
|
"rules": {
|
||||||
|
"indent": "off"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parser": "vue-eslint-parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"ecmaVersion": "latest",
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": ["vue", "@typescript-eslint"],
|
||||||
|
"ignorePatterns": [
|
||||||
|
"webpack.mix.js",
|
||||||
|
"**/*.php",
|
||||||
|
"**/*.svg",
|
||||||
|
"**/vendor/*.js",
|
||||||
|
"**/vendor/**/*.js",
|
||||||
|
"**/vendor/**/*.scss"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"indent": ["error", 4, { "SwitchCase": 1 }],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["error", "double"],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
"vue/script-indent": ["error", 2, { "baseIndent": 0, "switchCase": 1 }],
|
||||||
|
"vue/one-component-per-file": "off"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"import/resolver": {
|
||||||
|
"node": {
|
||||||
|
"extensions": [".js", ".vue", ".ts", ".d.ts"]
|
||||||
|
},
|
||||||
|
"alias": {
|
||||||
|
"extensions": [".vue", ".js", ".ts", ".scss", ".d.ts"],
|
||||||
|
"map": [
|
||||||
|
["~", "./resources/assets"],
|
||||||
|
["@", "./node_modules"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
.styleci.yml export-ignore
|
||||||
58
.gitignore
vendored
Executable file → Normal file
58
.gitignore
vendored
Executable file → Normal file
|
|
@ -1,20 +1,38 @@
|
||||||
app/cache/*
|
.env
|
||||||
app/logs/*
|
.env.backup
|
||||||
app/config/parameters.yml
|
.env.production
|
||||||
*.orig
|
.phpunit.result.cache
|
||||||
*.bak
|
.stylelintcache
|
||||||
*.zip
|
/.fleet
|
||||||
.buildpath
|
/.idea
|
||||||
.project
|
/.phpunit.cache
|
||||||
.settings
|
/.vscode
|
||||||
web/bundles/*
|
/node_modules
|
||||||
web/js/*
|
/bootstrap
|
||||||
web/css/*
|
/public/build
|
||||||
web/img-cache/*
|
/public/cache
|
||||||
web/uploads/offres/
|
/public/hot
|
||||||
web/uploads/images/original/*
|
/public/sitemap.xml
|
||||||
*.php\~
|
/public/storage
|
||||||
/*.gitmodules
|
/storage/*.key
|
||||||
.idea/*
|
/vendor
|
||||||
.DS_Store
|
auth.json
|
||||||
web/.htaccess
|
docker-compose.override.yml
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
.npmrc
|
||||||
|
|
||||||
|
# Ignore public favicon
|
||||||
|
/public/android-chrome-192x192.png
|
||||||
|
/public/android-chrome-512x512.png
|
||||||
|
/public/apple-touch-icon.png
|
||||||
|
/public/browserconfig.xml
|
||||||
|
/public/browserconfig.xml
|
||||||
|
/public/favicon-16x16.png
|
||||||
|
/public/favicon-32x32.png
|
||||||
|
/public/favicon.ico
|
||||||
|
/public/mstile-150x150.png
|
||||||
|
/public/safari-pinned-tab.svg
|
||||||
|
/public/site.webmanifest
|
||||||
|
|
|
||||||
24
.gitlab-ci.yml
Normal file
24
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
include:
|
||||||
|
- project: 'ldc-web/shared-ci'
|
||||||
|
ref: 'main'
|
||||||
|
file: 'lint/lint.yml'
|
||||||
|
- project: 'ldc-web/shared-ci'
|
||||||
|
ref: 'main'
|
||||||
|
file: 'security/security.yml'
|
||||||
|
- project: 'ldc-web/shared-ci'
|
||||||
|
ref: 'main'
|
||||||
|
file: 'build/docker-multistage.yml'
|
||||||
|
- project: 'ldc-web/shared-ci'
|
||||||
|
ref: 'main'
|
||||||
|
file: 'test/test.yml'
|
||||||
|
- project: 'ldc-web/shared-ci'
|
||||||
|
ref: 'main'
|
||||||
|
file: 'deploy/deploy.yml'
|
||||||
|
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- lint
|
||||||
|
- security
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
- deploy
|
||||||
45
.stylelintrc.json
Normal file
45
.stylelintrc.json
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"stylelint-config-standard-scss",
|
||||||
|
"stylelint-config-sass-guidelines",
|
||||||
|
"stylelint-config-idiomatic-order"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"stylelint-scss"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"**/*.css",
|
||||||
|
"**/*.scss"
|
||||||
|
],
|
||||||
|
"ignoreFiles": [
|
||||||
|
"**/vendor/*.css",
|
||||||
|
"**/vendor/**/*.css",
|
||||||
|
"**/vendor/*.scss",
|
||||||
|
"**/vendor/**/*.scss",
|
||||||
|
"**/vendor/*.sass",
|
||||||
|
"**/vendor/**/*.sass",
|
||||||
|
"**/vendor/*.less",
|
||||||
|
"**/vendor/**/*.less"
|
||||||
|
],
|
||||||
|
"customSyntax": "postcss-scss",
|
||||||
|
"rules": {
|
||||||
|
"declaration-property-value-no-unknown": true,
|
||||||
|
"selector-max-id": null,
|
||||||
|
"color-no-invalid-hex": true,
|
||||||
|
"order/properties-alphabetical-order": null,
|
||||||
|
"max-nesting-depth": 5,
|
||||||
|
"selector-max-compound-selectors": 5,
|
||||||
|
"declaration-colon-newline-after": null,
|
||||||
|
"value-list-comma-newline-after": null,
|
||||||
|
"scss/double-slash-comment-empty-line-before": [
|
||||||
|
"always",
|
||||||
|
{
|
||||||
|
"ignore": [
|
||||||
|
"between-comments",
|
||||||
|
"stylelint-commands",
|
||||||
|
"inside-block"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
10
.travis.yml
10
.travis.yml
|
|
@ -1,10 +0,0 @@
|
||||||
language: php
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 5.3.3
|
|
||||||
- 5.3
|
|
||||||
- 5.4
|
|
||||||
|
|
||||||
before_script: composer install
|
|
||||||
|
|
||||||
script: phpunit -c app
|
|
||||||
22
.vscode/settings.json
vendored
Normal file
22
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.activeBackground": "#9898da",
|
||||||
|
"activityBar.background": "#9898da",
|
||||||
|
"activityBar.foreground": "#15202b",
|
||||||
|
"activityBar.inactiveForeground": "#15202b99",
|
||||||
|
"activityBarBadge.background": "#f7e8e8",
|
||||||
|
"activityBarBadge.foreground": "#15202b",
|
||||||
|
"commandCenter.border": "#e7e7e799",
|
||||||
|
"sash.hoverBorder": "#9898da",
|
||||||
|
"statusBar.background": "#7373cc",
|
||||||
|
"statusBar.foreground": "#e7e7e7",
|
||||||
|
"statusBarItem.hoverBackground": "#9898da",
|
||||||
|
"statusBarItem.remoteBackground": "#7373cc",
|
||||||
|
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||||
|
"titleBar.activeBackground": "#7373cc",
|
||||||
|
"titleBar.activeForeground": "#e7e7e7",
|
||||||
|
"titleBar.inactiveBackground": "#7373cc99",
|
||||||
|
"titleBar.inactiveForeground": "#e7e7e799"
|
||||||
|
},
|
||||||
|
"peacock.remoteColor": "#7373cc"
|
||||||
|
}
|
||||||
45
Dockerfile
Normal file
45
Dockerfile
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
FROM composer:2.8 AS vendor
|
||||||
|
|
||||||
|
ARG GITLAB_USER
|
||||||
|
ARG GITLAB_PASSWORD
|
||||||
|
|
||||||
|
COPY database/ database/
|
||||||
|
|
||||||
|
COPY composer.json composer.json
|
||||||
|
COPY composer.lock composer.lock
|
||||||
|
|
||||||
|
RUN composer config gitlab-token.lab.s-web.fr ${GITLAB_USER} ${GITLAB_PASSWORD}
|
||||||
|
RUN composer install \
|
||||||
|
--ignore-platform-reqs \
|
||||||
|
--no-interaction \
|
||||||
|
--no-plugins \
|
||||||
|
--no-scripts \
|
||||||
|
--no-dev \
|
||||||
|
--prefer-dist
|
||||||
|
|
||||||
|
FROM node:20.18 AS frontend
|
||||||
|
|
||||||
|
ARG GITLAB_PASSWORD
|
||||||
|
|
||||||
|
RUN mkdir -p /app/public/build
|
||||||
|
|
||||||
|
COPY package*.json tsconfig.json vite.config.ts .eslintrc.json .stylelintrc.json /app/
|
||||||
|
COPY resources/ /app/resources/
|
||||||
|
WORKDIR /app
|
||||||
|
RUN npm config set @ldc-web:registry https://lab.s-web.fr/api/v4/packages/npm/
|
||||||
|
RUN npm config set -- '//lab.s-web.fr/api/v4/packages/npm/:_authToken' "${GITLAB_PASSWORD}"
|
||||||
|
RUN npm ci && npm run prod
|
||||||
|
|
||||||
|
ARG PHP_8_5_TAG=latest
|
||||||
|
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
|
||||||
|
|
||||||
|
ARG USER=www-data
|
||||||
|
|
||||||
|
COPY --chown=${USER}:${USER} . /app/srcs
|
||||||
|
COPY --chown=${USER}:${USER} ./resources/favicon /app/srcs/public
|
||||||
|
COPY --from=vendor --chown=${USER}:${USER} /app/vendor/ /app/srcs/vendor/
|
||||||
|
COPY --from=frontend --chown=${USER}:${USER} /app/public/build/ /app/srcs/public/build/
|
||||||
|
|
||||||
|
USER root
|
||||||
|
RUN chmod -R 755 /app/srcs/storage
|
||||||
|
USER ${USER}
|
||||||
19
LICENSE
19
LICENSE
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2004-2013 Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
181
README.md
Executable file → Normal file
181
README.md
Executable file → Normal file
|
|
@ -1,176 +1,7 @@
|
||||||
Symfony Standard Edition
|
# Agis
|
||||||
========================
|
|
||||||
|
|
||||||
Welcome to the Symfony Standard Edition - a fully-functional Symfony2
|
## CRON
|
||||||
application that you can use as the skeleton for your new applications.
|
Put every min in PROD :
|
||||||
|
```
|
||||||
This document contains information on how to download, install, and start
|
php artisan schedule:run
|
||||||
using Symfony. For a more detailed explanation, see the [Installation][1]
|
```
|
||||||
chapter of the Symfony Documentation.
|
|
||||||
|
|
||||||
1) Installing the Standard Edition
|
|
||||||
----------------------------------
|
|
||||||
|
|
||||||
When it comes to installing the Symfony Standard Edition, you have the
|
|
||||||
following options.
|
|
||||||
|
|
||||||
### Use Composer (*recommended*)
|
|
||||||
|
|
||||||
As Symfony uses [Composer][2] to manage its dependencies, the recommended way
|
|
||||||
to create a new project is to use it.
|
|
||||||
|
|
||||||
If you don't have Composer yet, download it following the instructions on
|
|
||||||
http://getcomposer.org/ or just run the following command:
|
|
||||||
|
|
||||||
curl -s https://getcomposer.org/installer | php
|
|
||||||
|
|
||||||
Then, use the `create-project` command to generate a new Symfony application:
|
|
||||||
|
|
||||||
php composer.phar create-project symfony/framework-standard-edition path/to/install 2.1.x-dev
|
|
||||||
|
|
||||||
For an exact version, replace 2.1.x-dev with the latest Symfony version (e.g. 2.1.1).
|
|
||||||
|
|
||||||
Composer will install Symfony and all its dependencies under the
|
|
||||||
`path/to/install` directory.
|
|
||||||
|
|
||||||
### Download an Archive File
|
|
||||||
|
|
||||||
To quickly test Symfony, you can also download an [archive][3] of the Standard
|
|
||||||
Edition and unpack it somewhere under your web server root directory.
|
|
||||||
|
|
||||||
If you downloaded an archive "without vendors", you also need to install all
|
|
||||||
the necessary dependencies. Download composer (see above) and run the
|
|
||||||
following command:
|
|
||||||
|
|
||||||
php composer.phar install
|
|
||||||
|
|
||||||
2) Checking your System Configuration
|
|
||||||
-------------------------------------
|
|
||||||
|
|
||||||
Before starting coding, make sure that your local system is properly
|
|
||||||
configured for Symfony.
|
|
||||||
|
|
||||||
Execute the `check.php` script from the command line:
|
|
||||||
|
|
||||||
php app/check.php
|
|
||||||
|
|
||||||
Access the `config.php` script from a browser:
|
|
||||||
|
|
||||||
http://localhost/path/to/symfony/app/web/config.php
|
|
||||||
|
|
||||||
If you get any warnings or recommendations, fix them before moving on.
|
|
||||||
|
|
||||||
3) Browsing the Demo Application
|
|
||||||
--------------------------------
|
|
||||||
|
|
||||||
Congratulations! You're now ready to use Symfony.
|
|
||||||
|
|
||||||
From the `config.php` page, click the "Bypass configuration and go to the
|
|
||||||
Welcome page" link to load up your first Symfony page.
|
|
||||||
|
|
||||||
You can also use a web-based configurator by clicking on the "Configure your
|
|
||||||
Symfony Application online" link of the `config.php` page.
|
|
||||||
|
|
||||||
To see a real-live Symfony page in action, access the following page:
|
|
||||||
|
|
||||||
web/app_dev.php/demo/hello/Fabien
|
|
||||||
|
|
||||||
4) Getting started with Symfony
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
This distribution is meant to be the starting point for your Symfony
|
|
||||||
applications, but it also contains some sample code that you can learn from
|
|
||||||
and play with.
|
|
||||||
|
|
||||||
A great way to start learning Symfony is via the [Quick Tour][4], which will
|
|
||||||
take you through all the basic features of Symfony2.
|
|
||||||
|
|
||||||
Once you're feeling good, you can move onto reading the official
|
|
||||||
[Symfony2 book][5].
|
|
||||||
|
|
||||||
A default bundle, `AcmeDemoBundle`, shows you Symfony2 in action. After
|
|
||||||
playing with it, you can remove it by following these steps:
|
|
||||||
|
|
||||||
* delete the `src/Acme` directory;
|
|
||||||
|
|
||||||
* remove the routing entries referencing AcmeBundle in
|
|
||||||
`app/config/routing_dev.yml`;
|
|
||||||
|
|
||||||
* remove the AcmeBundle from the registered bundles in `app/AppKernel.php`;
|
|
||||||
|
|
||||||
* remove the `web/bundles/acmedemo` directory;
|
|
||||||
|
|
||||||
* remove the `security.providers`, `security.firewalls.login` and
|
|
||||||
`security.firewalls.secured_area` entries in the `security.yml` file or
|
|
||||||
tweak the security configuration to fit your needs.
|
|
||||||
|
|
||||||
What's inside?
|
|
||||||
---------------
|
|
||||||
|
|
||||||
The Symfony Standard Edition is configured with the following defaults:
|
|
||||||
|
|
||||||
* Twig is the only configured template engine;
|
|
||||||
|
|
||||||
* Doctrine ORM/DBAL is configured;
|
|
||||||
|
|
||||||
* Swiftmailer is configured;
|
|
||||||
|
|
||||||
* Annotations for everything are enabled.
|
|
||||||
|
|
||||||
It comes pre-configured with the following bundles:
|
|
||||||
|
|
||||||
* **FrameworkBundle** - The core Symfony framework bundle
|
|
||||||
|
|
||||||
* [**SensioFrameworkExtraBundle**][6] - Adds several enhancements, including
|
|
||||||
template and routing annotation capability
|
|
||||||
|
|
||||||
* [**DoctrineBundle**][7] - Adds support for the Doctrine ORM
|
|
||||||
|
|
||||||
* [**TwigBundle**][8] - Adds support for the Twig templating engine
|
|
||||||
|
|
||||||
* [**SecurityBundle**][9] - Adds security by integrating Symfony's security
|
|
||||||
component
|
|
||||||
|
|
||||||
* [**SwiftmailerBundle**][10] - Adds support for Swiftmailer, a library for
|
|
||||||
sending emails
|
|
||||||
|
|
||||||
* [**MonologBundle**][11] - Adds support for Monolog, a logging library
|
|
||||||
|
|
||||||
* [**AsseticBundle**][12] - Adds support for Assetic, an asset processing
|
|
||||||
library
|
|
||||||
|
|
||||||
* [**JMSSecurityExtraBundle**][13] - Allows security to be added via
|
|
||||||
annotations
|
|
||||||
|
|
||||||
* [**JMSDiExtraBundle**][14] - Adds more powerful dependency injection
|
|
||||||
features
|
|
||||||
|
|
||||||
* **WebProfilerBundle** (in dev/test env) - Adds profiling functionality and
|
|
||||||
the web debug toolbar
|
|
||||||
|
|
||||||
* **SensioDistributionBundle** (in dev/test env) - Adds functionality for
|
|
||||||
configuring and working with Symfony distributions
|
|
||||||
|
|
||||||
* [**SensioGeneratorBundle**][15] (in dev/test env) - Adds code generation
|
|
||||||
capabilities
|
|
||||||
|
|
||||||
* **AcmeDemoBundle** (in dev/test env) - A demo bundle with some example
|
|
||||||
code
|
|
||||||
|
|
||||||
Enjoy!
|
|
||||||
|
|
||||||
[1]: http://symfony.com/doc/2.1/book/installation.html
|
|
||||||
[2]: http://getcomposer.org/
|
|
||||||
[3]: http://symfony.com/download
|
|
||||||
[4]: http://symfony.com/doc/2.1/quick_tour/the_big_picture.html
|
|
||||||
[5]: http://symfony.com/doc/2.1/index.html
|
|
||||||
[6]: http://symfony.com/doc/2.1/bundles/SensioFrameworkExtraBundle/index.html
|
|
||||||
[7]: http://symfony.com/doc/2.1/book/doctrine.html
|
|
||||||
[8]: http://symfony.com/doc/2.1/book/templating.html
|
|
||||||
[9]: http://symfony.com/doc/2.1/book/security.html
|
|
||||||
[10]: http://symfony.com/doc/2.1/cookbook/email.html
|
|
||||||
[11]: http://symfony.com/doc/2.1/cookbook/logging/monolog.html
|
|
||||||
[12]: http://symfony.com/doc/2.1/cookbook/assetic/asset_management.html
|
|
||||||
[13]: http://jmsyst.com/bundles/JMSSecurityExtraBundle/master
|
|
||||||
[14]: http://jmsyst.com/bundles/JMSDiExtraBundle/master
|
|
||||||
[15]: http://symfony.com/doc/2.1/bundles/SensioGeneratorBundle/index.html
|
|
||||||
262
UPGRADE.md
262
UPGRADE.md
|
|
@ -1,262 +0,0 @@
|
||||||
Symfony Standard Edition Upgrade
|
|
||||||
================================
|
|
||||||
|
|
||||||
From Symfony 2.0 to Symfony 2.1
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
### Project Dependencies
|
|
||||||
|
|
||||||
As of Symfony 2.1, project dependencies are managed by
|
|
||||||
[Composer](http://getcomposer.org/):
|
|
||||||
|
|
||||||
* The `bin/vendors` script can be removed as `composer.phar` does all the work
|
|
||||||
now (it is recommended to install it globally on your machine).
|
|
||||||
|
|
||||||
* The `deps` file need to be replaced with the `composer.json` one.
|
|
||||||
|
|
||||||
* The `composer.lock` is the equivalent of the generated `deps.lock` file and
|
|
||||||
it is automatically generated by Composer.
|
|
||||||
|
|
||||||
Download the default
|
|
||||||
[`composer.json`](https://raw.github.com/symfony/symfony-standard/2.1/composer.json)
|
|
||||||
and
|
|
||||||
[`composer.lock`](https://raw.github.com/symfony/symfony-standard/2.1/composer.lock)
|
|
||||||
files for Symfony 2.1 and put them into the main directory of your project. If
|
|
||||||
you have customized your `deps` file, move the added dependencies to the
|
|
||||||
`composer.json` file (many bundles and PHP libraries are already available as
|
|
||||||
Composer packages -- search for them on [Packagist](http://packagist.org/)).
|
|
||||||
|
|
||||||
Remove your current `vendor` directory.
|
|
||||||
|
|
||||||
Finally, run Composer:
|
|
||||||
|
|
||||||
$ composer.phar install
|
|
||||||
|
|
||||||
Note: You must complete the upgrade steps below so composer can successfully generate the autoload files.
|
|
||||||
|
|
||||||
### `app/autoload.php`
|
|
||||||
|
|
||||||
The default `autoload.php` reads as follows (it has been simplified a lot as
|
|
||||||
autoloading for libraries and bundles declared in your `composer.json` file is
|
|
||||||
automatically managed by the Composer autoloader):
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
|
||||||
|
|
||||||
$loader = include __DIR__.'/../vendor/autoload.php';
|
|
||||||
|
|
||||||
// intl
|
|
||||||
if (!function_exists('intl_get_error_code')) {
|
|
||||||
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
|
|
||||||
|
|
||||||
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
|
|
||||||
}
|
|
||||||
|
|
||||||
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
|
|
||||||
|
|
||||||
return $loader;
|
|
||||||
|
|
||||||
### `app/config/config.yml`
|
|
||||||
|
|
||||||
The `framework.charset` setting must be removed. If you are not using `UTF-8`
|
|
||||||
for your application, override the `getCharset()` method in your `AppKernel`
|
|
||||||
class instead:
|
|
||||||
|
|
||||||
class AppKernel extends Kernel
|
|
||||||
{
|
|
||||||
public function getCharset()
|
|
||||||
{
|
|
||||||
return 'ISO-8859-1';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
You might want to add the new `strict_requirements` parameter to
|
|
||||||
`framework.router` (it avoids fatal errors in the production environment when
|
|
||||||
a link cannot be generated):
|
|
||||||
|
|
||||||
framework:
|
|
||||||
router:
|
|
||||||
strict_requirements: "%kernel.debug%"
|
|
||||||
|
|
||||||
The `default_locale` parameter is now a setting of the main `framework`
|
|
||||||
configuration (it was under the `framework.session` in 2.0):
|
|
||||||
|
|
||||||
framework:
|
|
||||||
default_locale: "%locale%"
|
|
||||||
|
|
||||||
The `auto_start` setting under `framework.session` must be removed as it is
|
|
||||||
not used anymore (the session is now always started on-demand). If
|
|
||||||
`auto_start` was the only setting under the `framework.session` entry, don't
|
|
||||||
remove it entirely, but set its value to `~` (`~` means `null` in YAML)
|
|
||||||
instead:
|
|
||||||
|
|
||||||
framework:
|
|
||||||
session: ~
|
|
||||||
|
|
||||||
The `trust_proxy_headers` setting was added in the default configuration file
|
|
||||||
(as it should be set to `true` when you install your application behind a
|
|
||||||
reverse proxy):
|
|
||||||
|
|
||||||
framework:
|
|
||||||
trust_proxy_headers: false
|
|
||||||
|
|
||||||
An empty `bundles` entry was added to the `assetic` configuration:
|
|
||||||
|
|
||||||
assetic:
|
|
||||||
bundles: []
|
|
||||||
|
|
||||||
The default `swiftmailer` configuration now has the `spool` setting configured
|
|
||||||
to the `memory` type to defer email sending after the response is sent to the
|
|
||||||
user (recommended for better end-user performance):
|
|
||||||
|
|
||||||
swiftmailer:
|
|
||||||
spool: { type: memory }
|
|
||||||
|
|
||||||
The `jms_security_extra` configuration was moved to the `security.yml`
|
|
||||||
configuration file.
|
|
||||||
|
|
||||||
### `app/config/config_dev.yml`
|
|
||||||
|
|
||||||
An example of how to send all emails to a unique address was added:
|
|
||||||
|
|
||||||
#swiftmailer:
|
|
||||||
# delivery_address: me@example.com
|
|
||||||
|
|
||||||
### `app/config/config_test.yml`
|
|
||||||
|
|
||||||
The `storage_id` setting must be changed to `session.storage.mock_file`:
|
|
||||||
|
|
||||||
framework:
|
|
||||||
session:
|
|
||||||
storage_id: session.storage.mock_file
|
|
||||||
|
|
||||||
### `app/config/parameters.ini`
|
|
||||||
|
|
||||||
The file has been converted to a YAML file which reads as follows:
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
database_driver: pdo_mysql
|
|
||||||
database_host: localhost
|
|
||||||
database_port: ~
|
|
||||||
database_name: symfony
|
|
||||||
database_user: root
|
|
||||||
database_password: ~
|
|
||||||
|
|
||||||
mailer_transport: smtp
|
|
||||||
mailer_host: localhost
|
|
||||||
mailer_user: ~
|
|
||||||
mailer_password: ~
|
|
||||||
|
|
||||||
locale: en
|
|
||||||
secret: ThisTokenIsNotSoSecretChangeIt
|
|
||||||
|
|
||||||
Note that if you convert your parameters file to YAML, you must also change
|
|
||||||
its reference in `app/config/config.yml`.
|
|
||||||
|
|
||||||
### `app/config/routing_dev.yml`
|
|
||||||
|
|
||||||
The `_assetic` entry was removed:
|
|
||||||
|
|
||||||
#_assetic:
|
|
||||||
# resource: .
|
|
||||||
# type: assetic
|
|
||||||
|
|
||||||
### `app/config/security.yml`
|
|
||||||
|
|
||||||
Under `security.access_control`, the default rule for internal routes was changed:
|
|
||||||
|
|
||||||
security:
|
|
||||||
access_control:
|
|
||||||
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
|
|
||||||
|
|
||||||
Under `security.providers`, the `in_memory` example was updated to the following:
|
|
||||||
|
|
||||||
security:
|
|
||||||
providers:
|
|
||||||
in_memory:
|
|
||||||
memory:
|
|
||||||
users:
|
|
||||||
user: { password: userpass, roles: [ 'ROLE_USER' ] }
|
|
||||||
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
|
|
||||||
|
|
||||||
### `app/AppKernel.php`
|
|
||||||
|
|
||||||
The following bundles have been added to the list of default registered bundles:
|
|
||||||
|
|
||||||
new JMS\AopBundle\JMSAopBundle(),
|
|
||||||
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
|
|
||||||
|
|
||||||
You must also rename the DoctrineBundle from:
|
|
||||||
|
|
||||||
new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
|
|
||||||
|
|
||||||
to:
|
|
||||||
|
|
||||||
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
|
|
||||||
|
|
||||||
### `web/app.php`
|
|
||||||
|
|
||||||
The default `web/app.php` file now reads as follows:
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\ClassLoader\ApcClassLoader;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
|
|
||||||
|
|
||||||
// Use APC for autoloading to improve performance
|
|
||||||
// Change 'sf2' by the prefix you want in order to prevent key conflict with another application
|
|
||||||
/*
|
|
||||||
$loader = new ApcClassLoader('sf2', $loader);
|
|
||||||
$loader->register(true);
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once __DIR__.'/../app/AppKernel.php';
|
|
||||||
//require_once __DIR__.'/../app/AppCache.php';
|
|
||||||
|
|
||||||
$kernel = new AppKernel('prod', false);
|
|
||||||
$kernel->loadClassCache();
|
|
||||||
//$kernel = new AppCache($kernel);
|
|
||||||
$request = Request::createFromGlobals();
|
|
||||||
$response = $kernel->handle($request);
|
|
||||||
$response->send();
|
|
||||||
$kernel->terminate($request, $response);
|
|
||||||
|
|
||||||
### `web/app_dev.php`
|
|
||||||
|
|
||||||
The default `web/app_dev.php` file now reads as follows:
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
|
||||||
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
|
|
||||||
//umask(0000);
|
|
||||||
|
|
||||||
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
|
||||||
// Feel free to remove this, extend it, or make something more sophisticated.
|
|
||||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
|
||||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
|
||||||
|| !in_array(@$_SERVER['REMOTE_ADDR'], array(
|
|
||||||
'127.0.0.1',
|
|
||||||
'::1',
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
header('HTTP/1.0 403 Forbidden');
|
|
||||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
|
|
||||||
require_once __DIR__.'/../app/AppKernel.php';
|
|
||||||
|
|
||||||
$kernel = new AppKernel('dev', true);
|
|
||||||
$kernel->loadClassCache();
|
|
||||||
$request = Request::createFromGlobals();
|
|
||||||
$response = $kernel->handle($request);
|
|
||||||
$response->send();
|
|
||||||
$kernel->terminate($request, $response);
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
deny from all
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__.'/AppKernel.php';
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
|
|
||||||
|
|
||||||
class AppCache extends HttpCache
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
||||||
|
|
||||||
class AppKernel extends Kernel
|
|
||||||
{
|
|
||||||
public function registerBundles()
|
|
||||||
{
|
|
||||||
$bundles = array(
|
|
||||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
|
||||||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
|
||||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
|
||||||
new Symfony\Bundle\MonologBundle\MonologBundle(),
|
|
||||||
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
|
|
||||||
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
|
||||||
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
|
|
||||||
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
|
|
||||||
new JMS\AopBundle\JMSAopBundle(),
|
|
||||||
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
|
|
||||||
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
|
|
||||||
new FOS\UserBundle\FOSUserBundle(),
|
|
||||||
new Agis\FO\AgisBundle\AgisFOAgisBundle(),
|
|
||||||
new Agis\BO\AgisBundle\AgisBOAgisBundle(),
|
|
||||||
new Agis\BO\UserBundle\AgisBoUserBundle(),
|
|
||||||
new Agis\Commun\CommunBundle\AgisCommunCommunBundle(),
|
|
||||||
new Arson\elFinderBundle\ArsonElFinderBundle()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (in_array($this->getEnvironment(), array('dev', 'test', 'local'))) {
|
|
||||||
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
|
||||||
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
|
|
||||||
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $bundles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
|
||||||
{
|
|
||||||
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
35
app/Console/Commands/TestMail.php
Normal file
35
app/Console/Commands/TestMail.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class TestMail extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'uwil:mail:test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Send test email to equipe.web@ldc.fr';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
Mail::raw(sprintf('UWIL mail-test from %s %s', \config('app.name'), \config('app.url')), function ($msg) {
|
||||||
|
$msg->to('equipe.web@ldc.fr')->subject('Test Email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Console/Commands/UpdateNewsStatus.php
Normal file
33
app/Console/Commands/UpdateNewsStatus.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\NewsStatusUpdate;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class UpdateNewsStatus extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'uwil:updatestatus:news';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Update news status according to the publish and unpublish dates';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
\dispatch(new NewsStatusUpdate());
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Console/Commands/UpdateSeasonalSectionsStatus.php
Normal file
33
app/Console/Commands/UpdateSeasonalSectionsStatus.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\SeasonalSectionStatusUpdate;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class UpdateSeasonalSectionsStatus extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'uwil:updatestatus:seasonalsections';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Update seasonal sections status according to the publish and unpublish dates';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
\dispatch(new SeasonalSectionStatusUpdate());
|
||||||
|
}
|
||||||
|
}
|
||||||
200
app/Console/Commands/UserCreate.php
Normal file
200
app/Console/Commands/UserCreate.php
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Enums\Users\RoleEnum;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class UserCreate extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'uwil:user:create';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a backend admin user';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The first name of the new user.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $first_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The last name of the new user.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $last_name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The email of the new user.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The role of the new user.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $role;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$this->first_name = null;
|
||||||
|
$this->addFirstName();
|
||||||
|
|
||||||
|
$this->last_name = null;
|
||||||
|
$this->addLastName();
|
||||||
|
|
||||||
|
$this->email = null;
|
||||||
|
$this->addEmail();
|
||||||
|
|
||||||
|
$this->role = null;
|
||||||
|
$this->addRole();
|
||||||
|
|
||||||
|
$user = new User([
|
||||||
|
'first_name' => $this->first_name,
|
||||||
|
'last_name' => $this->last_name,
|
||||||
|
'email' => $this->email,
|
||||||
|
'role' => $this->role,
|
||||||
|
'published' => true,
|
||||||
|
'published_at' => Carbon::now(),
|
||||||
|
]);
|
||||||
|
$user->saveOrFail();
|
||||||
|
|
||||||
|
$this->info('User created 👌');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a first name to the user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function addFirstName(): void
|
||||||
|
{
|
||||||
|
while (is_null($this->first_name)) {
|
||||||
|
try {
|
||||||
|
$tmp = $this->ask('Type the wanted user first name', 'Admin');
|
||||||
|
$validator = Validator::make(['first_name' => $tmp], [
|
||||||
|
'first_name' => 'required|min:3|max:255'
|
||||||
|
]);
|
||||||
|
$validator->validate();
|
||||||
|
$this->first_name = $tmp;
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$this->error(sprintf(
|
||||||
|
'Please provide a valid first name %s',
|
||||||
|
\implode(',', collect($e->errors())->flatten()->all())
|
||||||
|
));
|
||||||
|
continue;
|
||||||
|
} //end try
|
||||||
|
}; //end while
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a last name to the user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function addLastName(): void
|
||||||
|
{
|
||||||
|
while (is_null($this->last_name)) {
|
||||||
|
try {
|
||||||
|
$tmp = $this->ask('Type the wanted user last name', 'Saïtama');
|
||||||
|
$validator = Validator::make(['last_name' => $tmp], [
|
||||||
|
'last_name' => 'required|min:3|max:255'
|
||||||
|
]);
|
||||||
|
$validator->validate();
|
||||||
|
$this->last_name = $tmp;
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$this->error(sprintf(
|
||||||
|
'Please provide a valid last_name %s',
|
||||||
|
\implode(',', collect($e->errors())->flatten()->all())
|
||||||
|
));
|
||||||
|
continue;
|
||||||
|
} //end try
|
||||||
|
}; //end while
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an email to the user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function addEmail(): void
|
||||||
|
{
|
||||||
|
while (is_null($this->email)) {
|
||||||
|
try {
|
||||||
|
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
|
||||||
|
$validator = Validator::make(['email' => $tmp], [
|
||||||
|
'email' => 'required|unique:users,email|email:rfc,dns'
|
||||||
|
]);
|
||||||
|
$validator->validate();
|
||||||
|
$this->email = $tmp;
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$this->error(sprintf(
|
||||||
|
'Please provide a valid email %s',
|
||||||
|
\implode(',', collect($e->errors())->flatten()->all())
|
||||||
|
));
|
||||||
|
continue;
|
||||||
|
} //end try
|
||||||
|
}; //end while
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a role to the user.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function addRole(): void
|
||||||
|
{
|
||||||
|
while (is_null($this->role)) {
|
||||||
|
try {
|
||||||
|
$tmp = $this->choice(
|
||||||
|
'Select his role',
|
||||||
|
[RoleEnum::conceptor->label(), RoleEnum::admin->label(), RoleEnum::visitor->label()],
|
||||||
|
RoleEnum::visitor->label(),
|
||||||
|
);
|
||||||
|
if ($tmp === RoleEnum::conceptor->label()) {
|
||||||
|
$tmp = RoleEnum::conceptor;
|
||||||
|
} elseif ($tmp === RoleEnum::admin->label()) {
|
||||||
|
$tmp = RoleEnum::admin;
|
||||||
|
} elseif ($tmp === RoleEnum::visitor->label()) {
|
||||||
|
$tmp = RoleEnum::visitor;
|
||||||
|
}
|
||||||
|
$validator = Validator::make(['role' => $tmp], [
|
||||||
|
'role' => 'required'
|
||||||
|
]);
|
||||||
|
$validator->validate();
|
||||||
|
$this->role = $tmp;
|
||||||
|
} catch (ValidationException $e) {
|
||||||
|
$this->error(sprintf(
|
||||||
|
'Please choose from the selection %s',
|
||||||
|
\implode(',', collect($e->errors())->flatten()->all())
|
||||||
|
));
|
||||||
|
continue;
|
||||||
|
} //end try
|
||||||
|
}; //end while
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Console/Kernel.php
Normal file
35
app/Console/Kernel.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console;
|
||||||
|
|
||||||
|
use App\Jobs\NewsStatusUpdate;
|
||||||
|
use App\Jobs\SeasonalSectionStatusUpdate;
|
||||||
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
||||||
|
class Kernel extends ConsoleKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the application's command schedule.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function schedule(Schedule $schedule)
|
||||||
|
{
|
||||||
|
$schedule->job(NewsStatusUpdate::class)->everyMinute();
|
||||||
|
$schedule->job(SeasonalSectionStatusUpdate::class)->everyMinute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the commands for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function commands()
|
||||||
|
{
|
||||||
|
$this->load(__DIR__ . '/Commands');
|
||||||
|
|
||||||
|
require base_path('routes/console.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Enums/ActivityLogs/ActivityLogsEventEnum.php
Normal file
47
app/Enums/ActivityLogs/ActivityLogsEventEnum.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\ActivityLogs;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum ActivityLogsEventEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case created = 1;
|
||||||
|
case updated = 2;
|
||||||
|
case duplicated = 3;
|
||||||
|
case deleted = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::created->name => 'Création',
|
||||||
|
self::updated->name => 'Mise à jour',
|
||||||
|
self::duplicated->name => 'Duplication',
|
||||||
|
self::deleted->name => 'Suppression',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom added classes definition
|
||||||
|
*/
|
||||||
|
private const BOOTSTRAPCLASS = [
|
||||||
|
self::created->name => 'success',
|
||||||
|
self::updated->name => 'warning',
|
||||||
|
self::duplicated->name => 'secondary',
|
||||||
|
self::deleted->name => 'danger',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Class
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function bootstrapClass(): string
|
||||||
|
{
|
||||||
|
return self::BOOTSTRAPCLASS[$this->name];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Enums/Contact/CivilityEnum.php
Normal file
23
app/Enums/Contact/CivilityEnum.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Contact;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum CivilityEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case man = 1;
|
||||||
|
case woman = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::man->name => 'Monsieur',
|
||||||
|
self::woman->name => 'Madame',
|
||||||
|
];
|
||||||
|
}
|
||||||
27
app/Enums/Contact/ObjectEnum.php
Normal file
27
app/Enums/Contact/ObjectEnum.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Contact;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum ObjectEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case customerService = 1;
|
||||||
|
case ideasSuggestions = 2;
|
||||||
|
case informationRequest = 3;
|
||||||
|
case other = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::customerService->name => 'Service consommateurs',
|
||||||
|
self::ideasSuggestions->name => 'Idées & suggestions',
|
||||||
|
self::informationRequest->name => 'Demande d’informations',
|
||||||
|
self::other->name => 'Divers',
|
||||||
|
];
|
||||||
|
}
|
||||||
625
app/Enums/Country.php
Normal file
625
app/Enums/Country.php
Normal file
|
|
@ -0,0 +1,625 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum Country: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case afghanistan = 1;
|
||||||
|
case alandIslands = 2;
|
||||||
|
case albania = 3;
|
||||||
|
case algeria = 4;
|
||||||
|
case americanSamoa = 5;
|
||||||
|
case andorra = 6;
|
||||||
|
case angola = 7;
|
||||||
|
case anguilla = 8;
|
||||||
|
case antarctica = 9;
|
||||||
|
case antiguaAndBarbuda = 10;
|
||||||
|
case argentina = 11;
|
||||||
|
case armenia = 12;
|
||||||
|
case aruba = 13;
|
||||||
|
case australia = 14;
|
||||||
|
case austria = 15;
|
||||||
|
case azerbaijan = 16;
|
||||||
|
case bahrain = 17;
|
||||||
|
case bahamas = 18;
|
||||||
|
case bangladesh = 19;
|
||||||
|
case barbados = 20;
|
||||||
|
case belarus = 21;
|
||||||
|
case belgium = 22;
|
||||||
|
case belize = 23;
|
||||||
|
case benin = 24;
|
||||||
|
case bermuda = 25;
|
||||||
|
case bhutan = 26;
|
||||||
|
case boliviaPlurinationalStateOf = 27;
|
||||||
|
case bonaireSintEustatiusAndSaba = 28;
|
||||||
|
case bosniaAndHerzegovina = 29;
|
||||||
|
case botswana = 30;
|
||||||
|
case bouvetIsland = 31;
|
||||||
|
case brazil = 32;
|
||||||
|
case britishIndianOceanTerritory = 33;
|
||||||
|
case bruneiDarussalam = 34;
|
||||||
|
case bulgaria = 35;
|
||||||
|
case burkinaFaso = 36;
|
||||||
|
case burundi = 37;
|
||||||
|
case cambodia = 38;
|
||||||
|
case cameroon = 39;
|
||||||
|
case canada = 40;
|
||||||
|
case capeVerde = 41;
|
||||||
|
case caymanIslands = 42;
|
||||||
|
case centralAfricanRepublic = 43;
|
||||||
|
case chad = 44;
|
||||||
|
case chile = 45;
|
||||||
|
case china = 46;
|
||||||
|
case christmasIsland = 47;
|
||||||
|
case cocosKeelingIslands = 48;
|
||||||
|
case colombia = 49;
|
||||||
|
case comoros = 50;
|
||||||
|
case congo = 51;
|
||||||
|
case congoTheDemocraticRepublicOfThe = 52;
|
||||||
|
case cookIslands = 53;
|
||||||
|
case costaRica = 54;
|
||||||
|
case coteDivoire = 55;
|
||||||
|
case croatia = 56;
|
||||||
|
case cuba = 57;
|
||||||
|
case curacao = 58;
|
||||||
|
case cyprus = 59;
|
||||||
|
case czechRepublic = 60;
|
||||||
|
case denmark = 61;
|
||||||
|
case djibouti = 62;
|
||||||
|
case dominica = 63;
|
||||||
|
case dominicanRepublic = 64;
|
||||||
|
case ecuador = 65;
|
||||||
|
case egypt = 66;
|
||||||
|
case elSalvador = 67;
|
||||||
|
case equatorialGuinea = 68;
|
||||||
|
case eritrea = 69;
|
||||||
|
case estonia = 70;
|
||||||
|
case ethiopia = 71;
|
||||||
|
case falklandIslandsMalvinas = 72;
|
||||||
|
case faroeIslands = 73;
|
||||||
|
case fiji = 74;
|
||||||
|
case finland = 75;
|
||||||
|
case france = 76;
|
||||||
|
case frenchGuiana = 77;
|
||||||
|
case frenchPolynesia = 78;
|
||||||
|
case frenchSouthernTerritories = 79;
|
||||||
|
case gabon = 80;
|
||||||
|
case gambia = 81;
|
||||||
|
case georgia = 82;
|
||||||
|
case germany = 83;
|
||||||
|
case ghana = 84;
|
||||||
|
case gibraltar = 85;
|
||||||
|
case greece = 86;
|
||||||
|
case greenland = 87;
|
||||||
|
case grenada = 88;
|
||||||
|
case guadeloupe = 89;
|
||||||
|
case guam = 90;
|
||||||
|
case guatemala = 91;
|
||||||
|
case guernsey = 92;
|
||||||
|
case guinea = 93;
|
||||||
|
case guineaBissau = 94;
|
||||||
|
case guyana = 95;
|
||||||
|
case haiti = 96;
|
||||||
|
case heardIslandAndMcdonaldIslands = 97;
|
||||||
|
case holySeeVaticanCityState = 98;
|
||||||
|
case honduras = 99;
|
||||||
|
case hongKong = 100;
|
||||||
|
case hungary = 101;
|
||||||
|
case iceland = 102;
|
||||||
|
case india = 103;
|
||||||
|
case indonesia = 104;
|
||||||
|
case iranIslamicRepublicOf = 105;
|
||||||
|
case iraq = 106;
|
||||||
|
case ireland = 107;
|
||||||
|
case isleOfMan = 108;
|
||||||
|
case israel = 109;
|
||||||
|
case italy = 110;
|
||||||
|
case jamaica = 111;
|
||||||
|
case japan = 112;
|
||||||
|
case jersey = 113;
|
||||||
|
case jordan = 114;
|
||||||
|
case kazakhstan = 115;
|
||||||
|
case kenya = 116;
|
||||||
|
case kiribati = 117;
|
||||||
|
case koreaDemocraticPeoplesRepublicOf = 118;
|
||||||
|
case koreaRepublicOf = 119;
|
||||||
|
case kuwait = 120;
|
||||||
|
case kyrgyzstan = 121;
|
||||||
|
case laoPeoplesDemocraticRepublic = 122;
|
||||||
|
case latvia = 123;
|
||||||
|
case lebanon = 124;
|
||||||
|
case lesotho = 125;
|
||||||
|
case liberia = 126;
|
||||||
|
case libya = 127;
|
||||||
|
case liechtenstein = 128;
|
||||||
|
case lithuania = 129;
|
||||||
|
case luxembourg = 130;
|
||||||
|
case macao = 131;
|
||||||
|
case macedoniaTheFormerYugoslavRepublicOf = 132;
|
||||||
|
case madagascar = 133;
|
||||||
|
case malawi = 134;
|
||||||
|
case malaysia = 135;
|
||||||
|
case maldives = 136;
|
||||||
|
case mali = 137;
|
||||||
|
case malta = 138;
|
||||||
|
case marshallIslands = 139;
|
||||||
|
case martinique = 140;
|
||||||
|
case mauritania = 141;
|
||||||
|
case mauritius = 142;
|
||||||
|
case mayotte = 143;
|
||||||
|
case mexico = 144;
|
||||||
|
case micronesiaFederatedStatesOf = 145;
|
||||||
|
case moldovaRepublicOf = 146;
|
||||||
|
case monaco = 147;
|
||||||
|
case mongolia = 148;
|
||||||
|
case montenegro = 149;
|
||||||
|
case montserrat = 150;
|
||||||
|
case morocco = 151;
|
||||||
|
case mozambique = 152;
|
||||||
|
case myanmar = 153;
|
||||||
|
case namibia = 154;
|
||||||
|
case nauru = 155;
|
||||||
|
case nepal = 156;
|
||||||
|
case netherlands = 157;
|
||||||
|
case newCaledonia = 158;
|
||||||
|
case newZealand = 159;
|
||||||
|
case nicaragua = 160;
|
||||||
|
case niger = 161;
|
||||||
|
case nigeria = 162;
|
||||||
|
case niue = 163;
|
||||||
|
case norfolkIsland = 164;
|
||||||
|
case northernMarianaIslands = 165;
|
||||||
|
case norway = 166;
|
||||||
|
case oman = 167;
|
||||||
|
case pakistan = 168;
|
||||||
|
case palau = 169;
|
||||||
|
case palestineStateOf = 170;
|
||||||
|
case panama = 171;
|
||||||
|
case papuaNewGuinea = 172;
|
||||||
|
case paraguay = 173;
|
||||||
|
case peru = 174;
|
||||||
|
case philippines = 175;
|
||||||
|
case pitcairn = 176;
|
||||||
|
case poland = 177;
|
||||||
|
case portugal = 178;
|
||||||
|
case puertoRico = 179;
|
||||||
|
case qatar = 180;
|
||||||
|
case reunion = 181;
|
||||||
|
case romania = 182;
|
||||||
|
case russianFederation = 183;
|
||||||
|
case rwanda = 184;
|
||||||
|
case saintBarthelemy = 185;
|
||||||
|
case saintHelenaAscensionAndTristanDaCunha = 186;
|
||||||
|
case saintKittsAndNevis = 187;
|
||||||
|
case saintLucia = 188;
|
||||||
|
case saintMartinFrenchPart = 189;
|
||||||
|
case saintPierreAndMiquelon = 190;
|
||||||
|
case saintVincentAndTheGrenadines = 191;
|
||||||
|
case samoa = 192;
|
||||||
|
case sanMarino = 193;
|
||||||
|
case saoTomeAndPrincipe = 194;
|
||||||
|
case saudiArabia = 195;
|
||||||
|
case senegal = 196;
|
||||||
|
case serbia = 197;
|
||||||
|
case seychelles = 198;
|
||||||
|
case sierraLeone = 199;
|
||||||
|
case singapore = 200;
|
||||||
|
case sintMaartenDutchPart = 201;
|
||||||
|
case slovakia = 202;
|
||||||
|
case slovenia = 203;
|
||||||
|
case solomonIslands = 204;
|
||||||
|
case somalia = 205;
|
||||||
|
case southAfrica = 206;
|
||||||
|
case southGeorgiaAndTheSouthSandwichIslands = 207;
|
||||||
|
case southSudan = 208;
|
||||||
|
case spain = 209;
|
||||||
|
case sriLanka = 210;
|
||||||
|
case sudan = 211;
|
||||||
|
case suriname = 212;
|
||||||
|
case svalbardAndJanMayen = 213;
|
||||||
|
case swaziland = 214;
|
||||||
|
case sweden = 215;
|
||||||
|
case switzerland = 216;
|
||||||
|
case syrianArabRepublic = 217;
|
||||||
|
case taiwanProvinceOfChina = 218;
|
||||||
|
case tajikistan = 219;
|
||||||
|
case tanzaniaUnitedRepublicOf = 220;
|
||||||
|
case thailand = 221;
|
||||||
|
case timorLeste = 222;
|
||||||
|
case togo = 223;
|
||||||
|
case tokelau = 224;
|
||||||
|
case tonga = 225;
|
||||||
|
case trinidadAndTobago = 226;
|
||||||
|
case tunisia = 227;
|
||||||
|
case turkey = 228;
|
||||||
|
case turkmenistan = 229;
|
||||||
|
case turksAndCaicosIslands = 230;
|
||||||
|
case tuvalu = 231;
|
||||||
|
case uganda = 232;
|
||||||
|
case ukraine = 233;
|
||||||
|
case unitedArabEmirates = 234;
|
||||||
|
case unitedKingdom = 235;
|
||||||
|
case unitedStates = 236;
|
||||||
|
case unitedStatesMinorOutlyingIslands = 237;
|
||||||
|
case uruguay = 238;
|
||||||
|
case uzbekistan = 239;
|
||||||
|
case vanuatu = 240;
|
||||||
|
case venezuelaBolivarianRepublicOf = 241;
|
||||||
|
case vietNam = 242;
|
||||||
|
case virginIslandsBritish = 243;
|
||||||
|
case virginIslandsUs = 244;
|
||||||
|
case wallisAndFutuna = 245;
|
||||||
|
case westernSahara = 246;
|
||||||
|
case yemen = 247;
|
||||||
|
case zambia = 248;
|
||||||
|
case zimbabwe = 249;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::afghanistan->name => 'Afghanistan',
|
||||||
|
self::alandIslands->name => 'Åland Islands',
|
||||||
|
self::albania->name => 'Albania',
|
||||||
|
self::algeria->name => 'Algeria',
|
||||||
|
self::americanSamoa->name => 'American Samoa',
|
||||||
|
self::andorra->name => 'Andorra',
|
||||||
|
self::angola->name => 'Angola',
|
||||||
|
self::anguilla->name => 'Anguilla',
|
||||||
|
self::antarctica->name => 'Antarctica',
|
||||||
|
self::antiguaAndBarbuda->name => 'Antigua and Barbuda',
|
||||||
|
self::argentina->name => 'Argentina',
|
||||||
|
self::armenia->name => 'Armenia',
|
||||||
|
self::aruba->name => 'Aruba',
|
||||||
|
self::australia->name => 'Australia',
|
||||||
|
self::austria->name => 'Austria',
|
||||||
|
self::azerbaijan->name => 'Azerbaijan',
|
||||||
|
self::bahrain->name => 'Bahrain',
|
||||||
|
self::bahamas->name => 'Bahamas',
|
||||||
|
self::bangladesh->name => 'Bangladesh',
|
||||||
|
self::barbados->name => 'Barbados',
|
||||||
|
self::belarus->name => 'Belarus',
|
||||||
|
self::belgium->name => 'Belgium',
|
||||||
|
self::belize->name => 'Belize',
|
||||||
|
self::benin->name => 'Benin',
|
||||||
|
self::bermuda->name => 'Bermuda',
|
||||||
|
self::bhutan->name => 'Bhutan',
|
||||||
|
self::boliviaPlurinationalStateOf->name => 'Bolivia, Plurinational State of',
|
||||||
|
self::bonaireSintEustatiusAndSaba->name => 'Bonaire, Sint Eustatius and Saba',
|
||||||
|
self::bosniaAndHerzegovina->name => 'Bosnia and Herzegovina',
|
||||||
|
self::botswana->name => 'Botswana',
|
||||||
|
self::bouvetIsland->name => 'Bouvet Island',
|
||||||
|
self::brazil->name => 'Brazil',
|
||||||
|
self::britishIndianOceanTerritory->name => 'British Indian Ocean Territory',
|
||||||
|
self::bruneiDarussalam->name => 'Brunei Darussalam',
|
||||||
|
self::bulgaria->name => 'Bulgaria',
|
||||||
|
self::burkinaFaso->name => 'Burkina Faso',
|
||||||
|
self::burundi->name => 'Burundi',
|
||||||
|
self::cambodia->name => 'Cambodia',
|
||||||
|
self::cameroon->name => 'Cameroon',
|
||||||
|
self::canada->name => 'Canada',
|
||||||
|
self::capeVerde->name => 'Cape Verde',
|
||||||
|
self::caymanIslands->name => 'Cayman Islands',
|
||||||
|
self::centralAfricanRepublic->name => 'Central African Republic',
|
||||||
|
self::chad->name => 'Chad',
|
||||||
|
self::chile->name => 'Chile',
|
||||||
|
self::china->name => 'China',
|
||||||
|
self::christmasIsland->name => 'Christmas Island',
|
||||||
|
self::cocosKeelingIslands->name => 'Cocos (Keeling) Islands',
|
||||||
|
self::colombia->name => 'Colombia',
|
||||||
|
self::comoros->name => 'Comoros',
|
||||||
|
self::congo->name => 'Congo',
|
||||||
|
self::congoTheDemocraticRepublicOfThe->name => 'Congo, the Democratic Republic of the',
|
||||||
|
self::cookIslands->name => 'Cook Islands',
|
||||||
|
self::costaRica->name => 'Costa Rica',
|
||||||
|
self::coteDivoire->name => 'Côte d\'Ivoire',
|
||||||
|
self::croatia->name => 'Croatia',
|
||||||
|
self::cuba->name => 'Cuba',
|
||||||
|
self::curacao->name => 'Curaçao',
|
||||||
|
self::cyprus->name => 'Cyprus',
|
||||||
|
self::czechRepublic->name => 'Czech Republic',
|
||||||
|
self::denmark->name => 'Denmark',
|
||||||
|
self::djibouti->name => 'Djibouti',
|
||||||
|
self::dominica->name => 'Dominica',
|
||||||
|
self::dominicanRepublic->name => 'Dominican Republic',
|
||||||
|
self::ecuador->name => 'Ecuador',
|
||||||
|
self::egypt->name => 'Egypt',
|
||||||
|
self::elSalvador->name => 'El Salvador',
|
||||||
|
self::equatorialGuinea->name => 'Equatorial Guinea',
|
||||||
|
self::eritrea->name => 'Eritrea',
|
||||||
|
self::estonia->name => 'Estonia',
|
||||||
|
self::ethiopia->name => 'Ethiopia',
|
||||||
|
self::falklandIslandsMalvinas->name => 'Falkland Islands (Malvinas)',
|
||||||
|
self::faroeIslands->name => 'Faroe Islands',
|
||||||
|
self::fiji->name => 'Fiji',
|
||||||
|
self::finland->name => 'Finland',
|
||||||
|
self::france->name => 'France',
|
||||||
|
self::frenchGuiana->name => 'French Guiana',
|
||||||
|
self::frenchPolynesia->name => 'French Polynesia',
|
||||||
|
self::frenchSouthernTerritories->name => 'French Southern Territories',
|
||||||
|
self::gabon->name => 'Gabon',
|
||||||
|
self::gambia->name => 'Gambia',
|
||||||
|
self::georgia->name => 'Georgia',
|
||||||
|
self::germany->name => 'Germany',
|
||||||
|
self::ghana->name => 'Ghana',
|
||||||
|
self::gibraltar->name => 'Gibraltar',
|
||||||
|
self::greece->name => 'Greece',
|
||||||
|
self::greenland->name => 'Greenland',
|
||||||
|
self::grenada->name => 'Grenada',
|
||||||
|
self::guadeloupe->name => 'Guadeloupe',
|
||||||
|
self::guam->name => 'Guam',
|
||||||
|
self::guatemala->name => 'Guatemala',
|
||||||
|
self::guernsey->name => 'Guernsey',
|
||||||
|
self::guinea->name => 'Guinea',
|
||||||
|
self::guineaBissau->name => 'GuineaBissau',
|
||||||
|
self::guyana->name => 'Guyana',
|
||||||
|
self::haiti->name => 'Haiti',
|
||||||
|
self::heardIslandAndMcdonaldIslands->name => 'Heard Island and McDonald Islands',
|
||||||
|
self::holySeeVaticanCityState->name => 'Holy See (Vatican City State)',
|
||||||
|
self::honduras->name => 'Honduras',
|
||||||
|
self::hongKong->name => 'Hong Kong',
|
||||||
|
self::hungary->name => 'Hungary',
|
||||||
|
self::iceland->name => 'Iceland',
|
||||||
|
self::india->name => 'India',
|
||||||
|
self::indonesia->name => 'Indonesia',
|
||||||
|
self::iranIslamicRepublicOf->name => 'Iran, Islamic Republic of',
|
||||||
|
self::iraq->name => 'Iraq',
|
||||||
|
self::ireland->name => 'Ireland',
|
||||||
|
self::isleOfMan->name => 'Isle of Man',
|
||||||
|
self::israel->name => 'Israel',
|
||||||
|
self::italy->name => 'Italy',
|
||||||
|
self::jamaica->name => 'Jamaica',
|
||||||
|
self::japan->name => 'Japan',
|
||||||
|
self::jersey->name => 'Jersey',
|
||||||
|
self::jordan->name => 'Jordan',
|
||||||
|
self::kazakhstan->name => 'Kazakhstan',
|
||||||
|
self::kenya->name => 'Kenya',
|
||||||
|
self::kiribati->name => 'Kiribati',
|
||||||
|
self::koreaDemocraticPeoplesRepublicOf->name => 'Korea, Democratic People\'s Republic of',
|
||||||
|
self::koreaRepublicOf->name => 'Korea, Republic of',
|
||||||
|
self::kuwait->name => 'Kuwait',
|
||||||
|
self::kyrgyzstan->name => 'Kyrgyzstan',
|
||||||
|
self::laoPeoplesDemocraticRepublic->name => 'Lao People\'s Democratic Republic',
|
||||||
|
self::latvia->name => 'Latvia',
|
||||||
|
self::lebanon->name => 'Lebanon',
|
||||||
|
self::lesotho->name => 'Lesotho',
|
||||||
|
self::liberia->name => 'Liberia',
|
||||||
|
self::libya->name => 'Libya',
|
||||||
|
self::liechtenstein->name => 'Liechtenstein',
|
||||||
|
self::lithuania->name => 'Lithuania',
|
||||||
|
self::luxembourg->name => 'Luxembourg',
|
||||||
|
self::macao->name => 'Macao',
|
||||||
|
self::macedoniaTheFormerYugoslavRepublicOf->name => 'Macedonia, the Former Yugoslav Republic of',
|
||||||
|
self::madagascar->name => 'Madagascar',
|
||||||
|
self::malawi->name => 'Malawi',
|
||||||
|
self::malaysia->name => 'Malaysia',
|
||||||
|
self::maldives->name => 'Maldives',
|
||||||
|
self::mali->name => 'Mali',
|
||||||
|
self::malta->name => 'Malta',
|
||||||
|
self::marshallIslands->name => 'Marshall Islands',
|
||||||
|
self::martinique->name => 'Martinique',
|
||||||
|
self::mauritania->name => 'Mauritania',
|
||||||
|
self::mauritius->name => 'Mauritius',
|
||||||
|
self::mayotte->name => 'Mayotte',
|
||||||
|
self::mexico->name => 'Mexico',
|
||||||
|
self::micronesiaFederatedStatesOf->name => 'Micronesia, Federated States of',
|
||||||
|
self::moldovaRepublicOf->name => 'Moldova, Republic of',
|
||||||
|
self::monaco->name => 'Monaco',
|
||||||
|
self::mongolia->name => 'Mongolia',
|
||||||
|
self::montenegro->name => 'Montenegro',
|
||||||
|
self::montserrat->name => 'Montserrat',
|
||||||
|
self::morocco->name => 'Morocco',
|
||||||
|
self::mozambique->name => 'Mozambique',
|
||||||
|
self::myanmar->name => 'Myanmar',
|
||||||
|
self::namibia->name => 'Namibia',
|
||||||
|
self::nauru->name => 'Nauru',
|
||||||
|
self::nepal->name => 'Nepal',
|
||||||
|
self::netherlands->name => 'Netherlands',
|
||||||
|
self::newCaledonia->name => 'New Caledonia',
|
||||||
|
self::newZealand->name => 'New Zealand',
|
||||||
|
self::nicaragua->name => 'Nicaragua',
|
||||||
|
self::niger->name => 'Niger',
|
||||||
|
self::nigeria->name => 'Nigeria',
|
||||||
|
self::niue->name => 'Niue',
|
||||||
|
self::norfolkIsland->name => 'Norfolk Island',
|
||||||
|
self::northernMarianaIslands->name => 'Northern Mariana Islands',
|
||||||
|
self::norway->name => 'Norway',
|
||||||
|
self::oman->name => 'Oman',
|
||||||
|
self::pakistan->name => 'Pakistan',
|
||||||
|
self::palau->name => 'Palau',
|
||||||
|
self::palestineStateOf->name => 'Palestine, State of',
|
||||||
|
self::panama->name => 'Panama',
|
||||||
|
self::papuaNewGuinea->name => 'Papua New Guinea',
|
||||||
|
self::paraguay->name => 'Paraguay',
|
||||||
|
self::peru->name => 'Peru',
|
||||||
|
self::philippines->name => 'Philippines',
|
||||||
|
self::pitcairn->name => 'Pitcairn',
|
||||||
|
self::poland->name => 'Poland',
|
||||||
|
self::portugal->name => 'Portugal',
|
||||||
|
self::puertoRico->name => 'Puerto Rico',
|
||||||
|
self::qatar->name => 'Qatar',
|
||||||
|
self::reunion->name => 'Réunion',
|
||||||
|
self::romania->name => 'Romania',
|
||||||
|
self::russianFederation->name => 'Russian Federation',
|
||||||
|
self::rwanda->name => 'Rwanda',
|
||||||
|
self::saintBarthelemy->name => 'Saint Barthélemy',
|
||||||
|
self::saintHelenaAscensionAndTristanDaCunha->name => 'Saint Helena, Ascension and Tristan da Cunha',
|
||||||
|
self::saintKittsAndNevis->name => 'Saint Kitts and Nevis',
|
||||||
|
self::saintLucia->name => 'Saint Lucia',
|
||||||
|
self::saintMartinFrenchPart->name => 'Saint Martin (French part)',
|
||||||
|
self::saintPierreAndMiquelon->name => 'Saint Pierre and Miquelon',
|
||||||
|
self::saintVincentAndTheGrenadines->name => 'Saint Vincent and the Grenadines',
|
||||||
|
self::samoa->name => 'Samoa',
|
||||||
|
self::sanMarino->name => 'San Marino',
|
||||||
|
self::saoTomeAndPrincipe->name => 'Sao Tome and Principe',
|
||||||
|
self::saudiArabia->name => 'Saudi Arabia',
|
||||||
|
self::senegal->name => 'Senegal',
|
||||||
|
self::serbia->name => 'Serbia',
|
||||||
|
self::seychelles->name => 'Seychelles',
|
||||||
|
self::sierraLeone->name => 'Sierra Leone',
|
||||||
|
self::singapore->name => 'Singapore',
|
||||||
|
self::sintMaartenDutchPart->name => 'Sint Maarten (Dutch part)',
|
||||||
|
self::slovakia->name => 'Slovakia',
|
||||||
|
self::slovenia->name => 'Slovenia',
|
||||||
|
self::solomonIslands->name => 'Solomon Islands',
|
||||||
|
self::somalia->name => 'Somalia',
|
||||||
|
self::southAfrica->name => 'South Africa',
|
||||||
|
self::southGeorgiaAndTheSouthSandwichIslands->name => 'South Georgia and the South Sandwich Islands',
|
||||||
|
self::southSudan->name => 'South Sudan',
|
||||||
|
self::spain->name => 'Spain',
|
||||||
|
self::sriLanka->name => 'Sri Lanka',
|
||||||
|
self::sudan->name => 'Sudan',
|
||||||
|
self::suriname->name => 'Suriname',
|
||||||
|
self::svalbardAndJanMayen->name => 'Svalbard and Jan Mayen',
|
||||||
|
self::swaziland->name => 'Swaziland',
|
||||||
|
self::sweden->name => 'Sweden',
|
||||||
|
self::switzerland->name => 'Switzerland',
|
||||||
|
self::syrianArabRepublic->name => 'Syrian Arab Republic',
|
||||||
|
self::taiwanProvinceOfChina->name => 'Taiwan, Province of China',
|
||||||
|
self::tajikistan->name => 'Tajikistan',
|
||||||
|
self::tanzaniaUnitedRepublicOf->name => 'Tanzania, United Republic of',
|
||||||
|
self::thailand->name => 'Thailand',
|
||||||
|
self::timorLeste->name => 'TimorLeste',
|
||||||
|
self::togo->name => 'Togo',
|
||||||
|
self::tokelau->name => 'Tokelau',
|
||||||
|
self::tonga->name => 'Tonga',
|
||||||
|
self::trinidadAndTobago->name => 'Trinidad and Tobago',
|
||||||
|
self::tunisia->name => 'Tunisia',
|
||||||
|
self::turkey->name => 'Turkey',
|
||||||
|
self::turkmenistan->name => 'Turkmenistan',
|
||||||
|
self::turksAndCaicosIslands->name => 'Turks and Caicos Islands',
|
||||||
|
self::tuvalu->name => 'Tuvalu',
|
||||||
|
self::uganda->name => 'Uganda',
|
||||||
|
self::ukraine->name => 'Ukraine',
|
||||||
|
self::unitedArabEmirates->name => 'United Arab Emirates',
|
||||||
|
self::unitedKingdom->name => 'United Kingdom',
|
||||||
|
self::unitedStates->name => 'United States',
|
||||||
|
self::unitedStatesMinorOutlyingIslands->name => 'United States Minor Outlying Islands',
|
||||||
|
self::uruguay->name => 'Uruguay',
|
||||||
|
self::uzbekistan->name => 'Uzbekistan',
|
||||||
|
self::vanuatu->name => 'Vanuatu',
|
||||||
|
self::venezuelaBolivarianRepublicOf->name => 'Venezuela, Bolivarian Republic of',
|
||||||
|
self::vietNam->name => 'Viet Nam',
|
||||||
|
self::virginIslandsBritish->name => 'Virgin Islands, British',
|
||||||
|
self::virginIslandsUs->name => 'Virgin Islands, U.S.',
|
||||||
|
self::wallisAndFutuna->name => 'Wallis and Futuna',
|
||||||
|
self::westernSahara->name => 'Western Sahara',
|
||||||
|
self::yemen->name => 'Yemen',
|
||||||
|
self::zambia->name => 'Zambia',
|
||||||
|
self::zimbabwe->name => 'Zimbabwe',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Valid Shipping Countries
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function validShippingCountries(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::france,
|
||||||
|
/**
|
||||||
|
* // * DROM COM .
|
||||||
|
// self::guadeloupe,
|
||||||
|
// self::martinique,
|
||||||
|
// self::frenchGuiana,
|
||||||
|
// self::reunion,
|
||||||
|
// self::saintPierreAndMiquelon,
|
||||||
|
// self::mayotte,
|
||||||
|
// self::saintBarthelemy,
|
||||||
|
// self::saintMartinFrenchPart,
|
||||||
|
// self::wallisAndFutuna,
|
||||||
|
// self::frenchPolynesia,
|
||||||
|
// self::newCaledonia
|
||||||
|
*/
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Valid Shipping Countries
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function validBillingCountries(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
self::france,
|
||||||
|
// * DROM COM.
|
||||||
|
self::guadeloupe,
|
||||||
|
self::martinique,
|
||||||
|
self::frenchGuiana,
|
||||||
|
self::reunion,
|
||||||
|
self::saintPierreAndMiquelon,
|
||||||
|
self::mayotte,
|
||||||
|
self::saintBarthelemy,
|
||||||
|
self::saintMartinFrenchPart,
|
||||||
|
self::wallisAndFutuna,
|
||||||
|
self::frenchPolynesia,
|
||||||
|
self::newCaledonia
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Alpha 2 ISO code of valid shipping countries
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getValidShippingCountriesIsoAplha2Codes(): array
|
||||||
|
{
|
||||||
|
return ['FR'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Alpha 2 ISO code of valid billing countries
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getValidBillingCountriesIsoAplha2Codes(): array
|
||||||
|
{
|
||||||
|
return \array_values(self::ISOCODES);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom added ISOCODES definition
|
||||||
|
*/
|
||||||
|
private const ISOCODES = [
|
||||||
|
self::france->name => 'FR',
|
||||||
|
self::guadeloupe->name => 'GP',
|
||||||
|
self::martinique->name => 'MQ',
|
||||||
|
self::frenchGuiana->name => 'GF',
|
||||||
|
self::reunion->name => 'RE',
|
||||||
|
self::saintPierreAndMiquelon->name => 'PM',
|
||||||
|
self::mayotte->name => 'YT',
|
||||||
|
self::saintBarthelemy->name => 'BL',
|
||||||
|
self::saintMartinFrenchPart->name => 'MF',
|
||||||
|
self::wallisAndFutuna->name => 'WF',
|
||||||
|
self::frenchPolynesia->name => 'PF',
|
||||||
|
self::newCaledonia->name => 'NC',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get ISOCODE
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function iso(): string
|
||||||
|
{
|
||||||
|
return self::ISOCODES[$this->name];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get enum ISOCODES
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function toIsoCodes(): array
|
||||||
|
{
|
||||||
|
return self::ISOCODES;
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Enums/DesiredLocation.php
Normal file
27
app/Enums/DesiredLocation.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum DesiredLocation: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case avignon = 1;
|
||||||
|
case herbignac = 2;
|
||||||
|
case tarare = 3;
|
||||||
|
case none = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::avignon->name => 'Avignon',
|
||||||
|
self::herbignac->name => 'Herbignac',
|
||||||
|
self::tarare->name => 'Tarare',
|
||||||
|
self::none->name => 'Indifférent',
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/Enums/InputType.php
Normal file
30
app/Enums/InputType.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum InputType: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case boolean = 1;
|
||||||
|
case dropdownArray = 2;
|
||||||
|
case email = 3;
|
||||||
|
case image = 4;
|
||||||
|
case imageArray = 5;
|
||||||
|
case labelArray = 6;
|
||||||
|
case miniblocArray = 7;
|
||||||
|
case number = 8;
|
||||||
|
case selectEnum = 9;
|
||||||
|
case password = 10;
|
||||||
|
case string = 11;
|
||||||
|
case text = 12;
|
||||||
|
case url = 13;
|
||||||
|
/** Vimeo only */
|
||||||
|
case videoVimeo = 14;
|
||||||
|
/** Youtube only */
|
||||||
|
case videoYoutube = 15;
|
||||||
|
/** Youtube or Vimeo. */
|
||||||
|
case video = 16;
|
||||||
|
}
|
||||||
29
app/Enums/News/CategoryEnum.php
Normal file
29
app/Enums/News/CategoryEnum.php
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\News;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum CategoryEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case enterprise = 1;
|
||||||
|
case convictions = 2;
|
||||||
|
case recipes = 3;
|
||||||
|
case jobs = 4;
|
||||||
|
case communication = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::enterprise->name => 'La vie d\'Entreprise',
|
||||||
|
self::convictions->name => 'Nos convictions',
|
||||||
|
self::recipes->name => 'Nos recettes',
|
||||||
|
self::jobs->name => 'Nos métiers',
|
||||||
|
self::communication->name => 'Communication',
|
||||||
|
];
|
||||||
|
}
|
||||||
16
app/Enums/Pagination/ItemsPerPaginationEnum.php
Normal file
16
app/Enums/Pagination/ItemsPerPaginationEnum.php
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Pagination;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum ItemsPerPaginationEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case five = 5;
|
||||||
|
case twelve = 12;
|
||||||
|
case twentyfive = 25;
|
||||||
|
case fifty = 50;
|
||||||
|
case onehundred = 100;
|
||||||
|
}
|
||||||
72
app/Enums/Products/CookingModeEnum.php
Normal file
72
app/Enums/Products/CookingModeEnum.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Products;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum CookingModeEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case microwave = 1;
|
||||||
|
case furnace = 2;
|
||||||
|
case waterbath = 3;
|
||||||
|
case pan = 4;
|
||||||
|
case fresh = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::microwave->name => 'Micro-ondes',
|
||||||
|
self::furnace->name => 'Four traditionnel',
|
||||||
|
self::waterbath->name => 'Bain-marie',
|
||||||
|
self::pan->name => 'Poêle',
|
||||||
|
self::fresh->name => 'Se consomme frais',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pictures paths.
|
||||||
|
*/
|
||||||
|
private const PICTURES = [
|
||||||
|
self::microwave->name => 'resources/assets/images/pictos/micro-wave.png',
|
||||||
|
self::furnace->name => 'resources/assets/images/pictos/furnace.png',
|
||||||
|
self::waterbath->name => 'resources/assets/images/pictos/water-bath.png',
|
||||||
|
self::pan->name => 'resources/assets/images/pictos/pan.png',
|
||||||
|
self::fresh->name => 'resources/assets/images/pictos/fresh.png',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get picture path
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function picture(): string
|
||||||
|
{
|
||||||
|
return self::PICTURES[$this->name];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alt attributes for pictures.
|
||||||
|
*/
|
||||||
|
private const ALTS = [
|
||||||
|
self::microwave->name => 'Pictogramme d\'un micro-ondes',
|
||||||
|
self::furnace->name => 'Pictogramme d\'un four traditionnel',
|
||||||
|
self::waterbath->name => 'Pictogramme d\'un bain-marie',
|
||||||
|
self::pan->name => 'Pictogramme d\'une poêle',
|
||||||
|
self::fresh->name => 'Pictogramme d\'une goutte d\'eau',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get picture alt attribute
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function alt(): string
|
||||||
|
{
|
||||||
|
return self::ALTS[$this->name];
|
||||||
|
}
|
||||||
|
}
|
||||||
44
app/Enums/SeasonalSections/BackgroundEnum.php
Normal file
44
app/Enums/SeasonalSections/BackgroundEnum.php
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\SeasonalSections;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum BackgroundEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case candlemas = 1;
|
||||||
|
case chinesenewyear = 2;
|
||||||
|
case endofyear = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::candlemas->name => 'Chandeleur',
|
||||||
|
self::chinesenewyear->name => 'Nouvel an chinois',
|
||||||
|
self::endofyear->name => 'Fin d\'année',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom added classes definition
|
||||||
|
*/
|
||||||
|
private const BOOTSTRAPCLASS = [
|
||||||
|
self::candlemas->name => 'seasonal-sections-candlemas',
|
||||||
|
self::chinesenewyear->name => 'seasonal-sections-chinesenewyear',
|
||||||
|
self::endofyear->name => 'seasonal-sections-endofyear',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Class
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function bootstrapClass(): string
|
||||||
|
{
|
||||||
|
return self::BOOTSTRAPCLASS[$this->name];
|
||||||
|
}
|
||||||
|
}
|
||||||
39
app/Enums/StaticPageType.php
Normal file
39
app/Enums/StaticPageType.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum StaticPageType: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case contact = 1;
|
||||||
|
case legals = 2;
|
||||||
|
case confidentiality = 3;
|
||||||
|
case home = 4;
|
||||||
|
case conviction = 5;
|
||||||
|
case explorer = 6;
|
||||||
|
case joinus = 7;
|
||||||
|
case ranges = 8;
|
||||||
|
case aboutus = 9;
|
||||||
|
case news = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::contact->name => 'Contact',
|
||||||
|
self::legals->name => 'Mentions légales et CGU',
|
||||||
|
self::confidentiality->name => 'Confidentialité',
|
||||||
|
self::home->name => 'Accueil',
|
||||||
|
self::conviction->name => 'Nos Convictions',
|
||||||
|
self::explorer->name => 'Explorateur & Gastronome',
|
||||||
|
self::joinus->name => 'Rejoignez-nous',
|
||||||
|
self::ranges->name => 'Nos Gammes de Produits',
|
||||||
|
self::aboutus->name => 'Nous Connaître',
|
||||||
|
self::news->name => 'Actualités',
|
||||||
|
];
|
||||||
|
}
|
||||||
23
app/Enums/Theme/BootstrapThemeEnum.php
Normal file
23
app/Enums/Theme/BootstrapThemeEnum.php
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Theme;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum BootstrapThemeEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case light = 1;
|
||||||
|
case dark = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::light->name => 'Light',
|
||||||
|
self::dark->name => 'Dark',
|
||||||
|
];
|
||||||
|
}
|
||||||
25
app/Enums/Users/RoleEnum.php
Normal file
25
app/Enums/Users/RoleEnum.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums\Users;
|
||||||
|
|
||||||
|
use App\Traits\Enums\BaseEnum;
|
||||||
|
|
||||||
|
enum RoleEnum: int
|
||||||
|
{
|
||||||
|
use BaseEnum;
|
||||||
|
|
||||||
|
case conceptor = 1;
|
||||||
|
case admin = 2;
|
||||||
|
case visitor = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optionnal labels definition.
|
||||||
|
*
|
||||||
|
* @phpstan-ignore-next-line
|
||||||
|
*/
|
||||||
|
private const LABELS = [
|
||||||
|
self::conceptor->name => 'Concepteur',
|
||||||
|
self::admin->name => 'Administrateur',
|
||||||
|
self::visitor->name => 'Visiteur',
|
||||||
|
];
|
||||||
|
}
|
||||||
48
app/Exceptions/Handler.php
Normal file
48
app/Exceptions/Handler.php
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exceptions;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class Handler extends ExceptionHandler
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A list of exception types with their corresponding custom log levels.
|
||||||
|
*
|
||||||
|
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||||
|
*/
|
||||||
|
protected $levels = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the exception types that are not reported.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string<\Throwable>>
|
||||||
|
*/
|
||||||
|
protected $dontReport = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of the inputs that are never flashed to the session on validation exceptions.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $dontFlash = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the exception handling callbacks for the application.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->reportable(function (Throwable $e) {
|
||||||
|
if (app()->bound('sentry')) {
|
||||||
|
app('sentry')->captureException($e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
71
app/Http/Controllers/Bo/ActivityLogsController.php
Normal file
71
app/Http/Controllers/Bo/ActivityLogsController.php
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\ActivityLog;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ActivityLogsController extends Controller
|
||||||
|
{
|
||||||
|
use ChangesModelOrder;
|
||||||
|
use UpdateModelPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('isConceptor');
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||||
|
$query = ActivityLog::query()->with('user');
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$query,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'model_class',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
trans('validation.custom.target'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($query);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$activitylogModels = $this->paginate($query);
|
||||||
|
|
||||||
|
return view('bo.pages.activity_logs.index', compact('activitylogModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\ActivityLog $activity_log
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('isConceptor');
|
||||||
|
$targetModelClass = $activity_log->model_class;
|
||||||
|
$targetModel = $activity_log->model_class::where(
|
||||||
|
(new $targetModelClass())->getRouteKeyName(),
|
||||||
|
$activity_log->model_id
|
||||||
|
)->first();
|
||||||
|
|
||||||
|
return view('bo.pages.activity_logs.show', [
|
||||||
|
'activitylogModel' => $activity_log,
|
||||||
|
'targetModel' => $targetModel,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
72
app/Http/Controllers/Bo/Auth/LoginController.php
Normal file
72
app/Http/Controllers/Bo/Auth/LoginController.php
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
use AuthenticatesUsers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('guest:backend')->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the guard to be used during authentication.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
||||||
|
*/
|
||||||
|
protected function guard(): StatefulGuard
|
||||||
|
{
|
||||||
|
return Auth::guard('backend');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application's login form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function showLoginForm(): View
|
||||||
|
{
|
||||||
|
return view('bo.auth.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function redirectTo(): string
|
||||||
|
{
|
||||||
|
return response()->redirectToIntended()->getTargetUrl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to log the user into the application.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function attemptLogin(Request $request)
|
||||||
|
{
|
||||||
|
$credentials = $this->credentials($request);
|
||||||
|
// * Attempt login only using published users.
|
||||||
|
$credentials['published'] = true;
|
||||||
|
return $this->guard()->attempt(
|
||||||
|
$credentials,
|
||||||
|
$request->boolean('remember')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Http/Controllers/Bo/Auth/ResetPasswordController.php
Normal file
33
app/Http/Controllers/Bo/Auth/ResetPasswordController.php
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo\Auth;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Contracts\Auth\StatefulGuard;
|
||||||
|
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
use ResetsPasswords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the guard to be used during authentication.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
||||||
|
*/
|
||||||
|
protected function guard(): StatefulGuard
|
||||||
|
{
|
||||||
|
return Auth::guard('backend');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where to redirect users after login.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function redirectTo(): string
|
||||||
|
{
|
||||||
|
return \route('bo.login');
|
||||||
|
}
|
||||||
|
}
|
||||||
166
app/Http/Controllers/Bo/CommitmentController.php
Normal file
166
app/Http/Controllers/Bo/CommitmentController.php
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Commitments\StoreCommitmentRequest;
|
||||||
|
use App\Http\Requests\Bo\Commitments\UpdateCommitmentRequest;
|
||||||
|
use App\Models\Commitment;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class CommitmentController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
use ChangesModelOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(Commitment::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $commitmentModels */
|
||||||
|
$commitmentModels = Commitment::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$commitmentModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title'))
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($commitmentModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$commitmentModels = $this->paginate($commitmentModels);
|
||||||
|
|
||||||
|
return view('bo.pages.commitments.index', compact('commitmentModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Commitment $commitment
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.commitments.create', ['commitmentModel' => $commitment]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Commitments\StoreCommitmentRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreCommitmentRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$commitment = new Commitment();
|
||||||
|
|
||||||
|
if ($commitment->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.commitments.edit', $commitment)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Commitment $commitment
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.commitments.edit', ['commitmentModel' => $commitment]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Commitments\UpdateCommitmentRequest $request
|
||||||
|
* @param \App\Models\Commitment $commitment
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateCommitmentRequest $request, Commitment $commitment): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $commitment) {
|
||||||
|
if ($commitment->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.commitments.edit', $commitment)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.commitments.edit', $commitment)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Commitment $commitment
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Commitment $commitment): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$commitment->products()->detach();
|
||||||
|
|
||||||
|
if ($commitment->explorerpage()->count() === 0) {
|
||||||
|
if ($commitment->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.commitments.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.commitment'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Commitment $commitment
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(Commitment $commitment): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($commitment->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Http/Controllers/Bo/ConvictionpageController.php
Normal file
54
app/Http/Controllers/Bo/ConvictionpageController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest;
|
||||||
|
use App\Models\Convictionpage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ConvictionpageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Convictionpage::class);
|
||||||
|
|
||||||
|
/** @var \App\Models\Convictionpage $convictionpageModel */
|
||||||
|
$convictionpageModel = Convictionpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
return view('bo.pages.convictionpages.edit', compact('convictionpageModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Convictionpages\UpdateConvictionpageRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateConvictionpageRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Convictionpage::class);
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
/** @var \App\Models\Convictionpage $convictionpageModel */
|
||||||
|
$convictionpageModel = Convictionpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
if (($convictionpageModel->fill($request->validated()))->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.convictionpages.edit')
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.convictionpages.edit')
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.convictionpage'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Controllers/Bo/DashboardController.php
Normal file
19
app/Http/Controllers/Bo/DashboardController.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Dashboard Page
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
return view('bo.pages.dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
61
app/Http/Controllers/Bo/ExplorerpageController.php
Normal file
61
app/Http/Controllers/Bo/ExplorerpageController.php
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Explorerpage\UpdateExplorerpageRequest;
|
||||||
|
use App\Models\Commitment;
|
||||||
|
use App\Models\Explorerpage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ExplorerpageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Explorerpage::class);
|
||||||
|
|
||||||
|
/** @var \App\Models\Explorerpage $explorerpageModel */
|
||||||
|
$explorerpageModel = Explorerpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\Commitment> */
|
||||||
|
$commitmentModels = Commitment::all();
|
||||||
|
|
||||||
|
return view('bo.pages.explorerpages.edit', compact('explorerpageModel', 'commitmentModels'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Explorerpage\UpdateExplorerpageRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateExplorerpageRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Explorerpage::class);
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
/** @var \App\Models\Explorerpage $explorerpageModel */
|
||||||
|
$explorerpageModel = Explorerpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
$explorerpageModel->fill($request->safe()->except('commitments'));
|
||||||
|
$explorerpageModel->commitments()->sync(\collect($request->validated('commitments'))->pluck('id'));
|
||||||
|
|
||||||
|
if ($explorerpageModel->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.explorerpages.edit')
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.explorerpage'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.explorerpages.edit')
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.explorerpage'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Http/Controllers/Bo/HomepageController.php
Normal file
54
app/Http/Controllers/Bo/HomepageController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Homepage\UpdateHomepageRequest;
|
||||||
|
use App\Models\Homepage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class HomepageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Homepage::class);
|
||||||
|
|
||||||
|
/** @var \App\Models\Homepage $homepageModel */
|
||||||
|
$homepageModel = Homepage::query()->firstOrFail();
|
||||||
|
|
||||||
|
return view('bo.pages.homepages.edit', compact('homepageModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Homepage\UpdateHomepageRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateHomepageRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Homepage::class);
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
/** @var \App\Models\Homepage $homepageModel */
|
||||||
|
$homepageModel = Homepage::query()->firstOrFail();
|
||||||
|
|
||||||
|
if ($homepageModel->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.homepages.edit')
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.homepage'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.homepages.edit')
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.homepage'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
54
app/Http/Controllers/Bo/JoinuspageController.php
Normal file
54
app/Http/Controllers/Bo/JoinuspageController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Joinuspage\UpdateJoinuspageRequest;
|
||||||
|
use App\Models\Joinuspage;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class JoinuspageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Joinuspage::class);
|
||||||
|
|
||||||
|
/** @var \App\Models\Joinuspage $joinuspageModel */
|
||||||
|
$joinuspageModel = Joinuspage::query()->firstOrFail();
|
||||||
|
|
||||||
|
return view('bo.pages.joinuspages.edit', compact('joinuspageModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Joinuspage\UpdateJoinuspageRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateJoinuspageRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$this->authorize('update', \App\Models\Joinuspage::class);
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
/** @var \App\Models\Joinuspage $joinuspageModel */
|
||||||
|
$joinuspageModel = Joinuspage::query()->firstOrFail();
|
||||||
|
|
||||||
|
if ($joinuspageModel->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.joinuspages.edit')
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.joinuspage'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.joinuspages.edit')
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.joinuspage'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
168
app/Http/Controllers/Bo/NewsController.php
Normal file
168
app/Http/Controllers/Bo/NewsController.php
Normal file
|
|
@ -0,0 +1,168 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\News\StoreNewsRequest;
|
||||||
|
use App\Http\Requests\Bo\News\UpdateNewsRequest;
|
||||||
|
use App\Models\News;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class NewsController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
use ChangesModelOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(News::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $newsModels */
|
||||||
|
$newsModels = News::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$newsModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
'subtitle',
|
||||||
|
'content',
|
||||||
|
'category',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title')),
|
||||||
|
trans('validation.custom.subtitle'),
|
||||||
|
trans('validation.attributes.content'),
|
||||||
|
trans('validation.custom.category'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($newsModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$newsModels = $this->paginate($newsModels);
|
||||||
|
|
||||||
|
return view('bo.pages.news.index', compact('newsModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\News $news
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(News $news): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.news.create', ['newsModel' => $news]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\News\StoreNewsRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreNewsRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$news = new News();
|
||||||
|
|
||||||
|
if ($news->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.news.edit', $news)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\News $news
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(News $news): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.news.edit', ['newsModel' => $news]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\News\UpdateNewsRequest $request
|
||||||
|
* @param \App\Models\News $news
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateNewsRequest $request, News $news): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $news) {
|
||||||
|
if ($news->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.news.edit', $news)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.news.edit', $news)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\News $news
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(News $news): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($news->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.news.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.news'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\News $news
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(News $news): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($news->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
191
app/Http/Controllers/Bo/ProductController.php
Normal file
191
app/Http/Controllers/Bo/ProductController.php
Normal file
|
|
@ -0,0 +1,191 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Products\StoreProductRequest;
|
||||||
|
use App\Http\Requests\Bo\Products\UpdateProductRequest;
|
||||||
|
use App\Models\Commitment;
|
||||||
|
use App\Models\Product;
|
||||||
|
use App\Models\Range;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class ProductController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
use ChangesModelOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(Product::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $productModels */
|
||||||
|
$productModels = Product::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$productModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
'subtitle',
|
||||||
|
'description',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title')),
|
||||||
|
trans('validation.custom.subtitle'),
|
||||||
|
trans('validation.custom.description'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($productModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$productModels = $this->paginate($productModels);
|
||||||
|
|
||||||
|
return view('bo.pages.products.index', compact('productModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Product $product
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(Product $product): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$rangeModels = Range::all();
|
||||||
|
$commitmentModels = Commitment::all();
|
||||||
|
return view('bo.pages.products.create', [
|
||||||
|
'productModel' => $product,
|
||||||
|
'rangeModels' => $rangeModels,
|
||||||
|
'commitmentModels' => $commitmentModels,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Products\StoreProductRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreProductRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$product = new Product();
|
||||||
|
// Method safe() don't return formatted nutritionnal values, but we need this method to exclude commitments.
|
||||||
|
$product->fill($request->safe()->except(['commitments', 'nutritionnal_values']));
|
||||||
|
// We don't take $request->validated('nutritionnal_values') because it returned undesired datas.
|
||||||
|
$product->nutritionnal_values = $request->validated()['nutritionnal_values'];
|
||||||
|
|
||||||
|
if ($product->saveOrFail()) {
|
||||||
|
$product->commitments()->attach(collect($request->validated('commitments'))->pluck('id'));
|
||||||
|
return redirect()->route('bo.products.edit', $product)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Product $product
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(Product $product): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$rangeModels = Range::all();
|
||||||
|
$commitmentModels = Commitment::all();
|
||||||
|
return view('bo.pages.products.edit', [
|
||||||
|
'productModel' => $product,
|
||||||
|
'rangeModels' => $rangeModels,
|
||||||
|
'commitmentModels' => $commitmentModels,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Products\UpdateProductRequest $request
|
||||||
|
* @param \App\Models\Product $product
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateProductRequest $request, Product $product): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $product) {
|
||||||
|
$product->fill($request->safe()->except('commitments'));
|
||||||
|
$product->commitments()->sync(collect($request->validated('commitments'))->pluck('id'));
|
||||||
|
$product->nutritionnal_values = $request->validated()['nutritionnal_values'];
|
||||||
|
if ($product->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.products.edit', $product)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.products.edit', $product)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Product $product
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Product $product): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($product) {
|
||||||
|
$product->commitments()->detach();
|
||||||
|
if ($product->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.products.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Product $product
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(Product $product): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($product->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
177
app/Http/Controllers/Bo/RangeController.php
Normal file
177
app/Http/Controllers/Bo/RangeController.php
Normal file
|
|
@ -0,0 +1,177 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Ranges\StoreRangeRequest;
|
||||||
|
use App\Http\Requests\Bo\Ranges\UpdateRangeRequest;
|
||||||
|
use App\Models\Range;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class RangeController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
use ChangesModelOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(Range::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $rangeModels */
|
||||||
|
$rangeModels = Range::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$rangeModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
'subtitle',
|
||||||
|
'tagline',
|
||||||
|
'description',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title')),
|
||||||
|
trans('validation.custom.subtitle'),
|
||||||
|
trans('validation.custom.tagline'),
|
||||||
|
trans('validation.custom.description'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($rangeModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$rangeModels = $this->paginate($rangeModels);
|
||||||
|
|
||||||
|
return view('bo.pages.ranges.index', compact('rangeModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Range $range
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(Range $range): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.ranges.create', ['rangeModel' => $range]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Ranges\StoreRangeRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreRangeRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$range = new Range();
|
||||||
|
|
||||||
|
if ($range->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.ranges.edit', $range)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Range $range
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(Range $range): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.ranges.edit', ['rangeModel' => $range]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Ranges\UpdateRangeRequest $request
|
||||||
|
* @param \App\Models\Range $range
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateRangeRequest $request, Range $range): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $range) {
|
||||||
|
if ($range->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.ranges.edit', $range)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.ranges.edit', $range)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Range $range
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Range $range): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection $products*/
|
||||||
|
$products = $range->products;
|
||||||
|
if (!$products->isEmpty()) {
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted_relation', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range')),
|
||||||
|
'relations' => Str::plural(__('models.classes.product'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
if ($range->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.ranges.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.range'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Range $range
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(Range $range): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($range->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
164
app/Http/Controllers/Bo/SeasonalSectionController.php
Normal file
164
app/Http/Controllers/Bo/SeasonalSectionController.php
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\SeasonalSections\StoreSeasonalSectionRequest;
|
||||||
|
use App\Http\Requests\Bo\SeasonalSections\UpdateSeasonalSectionRequest;
|
||||||
|
use App\Models\SeasonalSection;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class SeasonalSectionController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(SeasonalSection::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $seasonalSectionModels */
|
||||||
|
$seasonalSectionModels = SeasonalSection::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$seasonalSectionModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
'text',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title')),
|
||||||
|
trans('validation.attributes.text'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($seasonalSectionModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$seasonalSectionModels = $this->paginate($seasonalSectionModels);
|
||||||
|
|
||||||
|
return view('bo.pages.seasonal_sections.index', compact('seasonalSectionModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\SeasonalSection $seasonalSection
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.seasonal_sections.create', ['seasonalSectionModel' => $seasonalSection]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\SeasonalSections\StoreSeasonalSectionRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreSeasonalSectionRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$seasonalSection = new SeasonalSection();
|
||||||
|
|
||||||
|
if ($seasonalSection->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\SeasonalSection $seasonalSection
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.seasonal_sections.edit', ['seasonalSectionModel' => $seasonalSection]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\SeasonalSections\UpdateSeasonalSectionRequest $request
|
||||||
|
* @param \App\Models\SeasonalSection $seasonalSection
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(
|
||||||
|
UpdateSeasonalSectionRequest $request,
|
||||||
|
SeasonalSection $seasonalSection
|
||||||
|
): \Illuminate\Http\RedirectResponse {
|
||||||
|
return DB::transaction(function () use ($request, $seasonalSection) {
|
||||||
|
if ($seasonalSection->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.seasonalsections.edit', $seasonalSection)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\SeasonalSection $seasonalSection
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(SeasonalSection $seasonalSection): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($seasonalSection->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.seasonalsections.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(trans_choice('models.classes.seasonal_section', 1))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\SeasonalSection $seasonalSection
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(SeasonalSection $seasonalSection): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($seasonalSection->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
162
app/Http/Controllers/Bo/StampController.php
Normal file
162
app/Http/Controllers/Bo/StampController.php
Normal file
|
|
@ -0,0 +1,162 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Stamps\StoreStampRequest;
|
||||||
|
use App\Http\Requests\Bo\Stamps\UpdateStampRequest;
|
||||||
|
use App\Models\Stamp;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class StampController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(Stamp::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $stampModels */
|
||||||
|
$stampModels = Stamp::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$stampModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'picture_alt',
|
||||||
|
'picture_title',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.custom.attribute_alt')),
|
||||||
|
trans('validation.custom.attribute_title'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($stampModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$stampModels = $this->paginate($stampModels);
|
||||||
|
|
||||||
|
return view('bo.pages.stamps.index', compact('stampModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Stamp $stamp
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(Stamp $stamp): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.stamps.create', ['stampModel' => $stamp]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Stamps\StoreStampRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreStampRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$stamp = new Stamp();
|
||||||
|
|
||||||
|
if ($stamp->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.stamps.edit', $stamp)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Stamp $stamp
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(Stamp $stamp): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.stamps.edit', ['stampModel' => $stamp]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Stamps\UpdateStampRequest $request
|
||||||
|
* @param \App\Models\Stamp $stamp
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateStampRequest $request, Stamp $stamp): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $stamp) {
|
||||||
|
if ($stamp->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.stamps.edit', $stamp)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.stamps.edit', $stamp)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Stamp $stamp
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Stamp $stamp): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($stamp->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.stamps.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.stamp'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Stamp $stamp
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(Stamp $stamp): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($stamp->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
89
app/Http/Controllers/Bo/StaticPageController.php
Normal file
89
app/Http/Controllers/Bo/StaticPageController.php
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\StaticPages\UpdateStaticPageRequest;
|
||||||
|
use App\Models\StaticPage;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class StaticPageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(StaticPage::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||||
|
$query = StaticPage::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$query,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'title',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.attributes.title'))
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($query);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$staticPageModelList = $this->paginate($query);
|
||||||
|
|
||||||
|
return view('bo.pages.static_pages.index', compact('staticPageModelList', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\StaticPage $static_page
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(StaticPage $static_page): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.static_pages.edit', ['staticPageModel' => $static_page]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\StaticPages\UpdateStaticPageRequest $request
|
||||||
|
* @param \App\Models\StaticPage $static_page
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateStaticPageRequest $request, StaticPage $static_page): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $static_page) {
|
||||||
|
if ($static_page->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.static_pages.edit', $static_page)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.static_pages.edit', $static_page)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(\trans_choice('models.classes.static_page', 1))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
167
app/Http/Controllers/Bo/TestimonialController.php
Normal file
167
app/Http/Controllers/Bo/TestimonialController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest;
|
||||||
|
use App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest;
|
||||||
|
use App\Models\Testimonial;
|
||||||
|
use App\Traits\Controllers\ChangesModelOrder;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class TestimonialController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
use ChangesModelOrder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(Testimonial::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $testimonialModels */
|
||||||
|
$testimonialModels = Testimonial::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$testimonialModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'description',
|
||||||
|
'job'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
Str::ucfirst(trans('validation.custom.description')),
|
||||||
|
Str::ucfirst(trans('validation.custom.job'))
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($testimonialModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$testimonialModels = $this->paginate($testimonialModels);
|
||||||
|
|
||||||
|
return view('bo.pages.testimonials.index', compact('testimonialModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Testimonial $testimonial
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.testimonials.create', ['testimonialModel' => $testimonial]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Testimonials\StoreTestimonialRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreTestimonialRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$testimonial = new Testimonial();
|
||||||
|
|
||||||
|
if ($testimonial->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Testimonial $testimonial
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.testimonials.edit', ['testimonialModel' => $testimonial]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Testimonials\UpdateTestimonialRequest $request
|
||||||
|
* @param \App\Models\Testimonial $testimonial
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(
|
||||||
|
UpdateTestimonialRequest $request,
|
||||||
|
Testimonial $testimonial
|
||||||
|
): \Illuminate\Http\RedirectResponse {
|
||||||
|
return DB::transaction(function () use ($request, $testimonial) {
|
||||||
|
if ($testimonial->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.testimonials.edit', $testimonial)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Testimonial $testimonial
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(Testimonial $testimonial): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($testimonial->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.testimonials.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.testimonial'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Testimonial $testimonial
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(Testimonial $testimonial): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($testimonial->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
166
app/Http/Controllers/Bo/UsersController.php
Normal file
166
app/Http/Controllers/Bo/UsersController.php
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Bo\Users\StoreUserRequest;
|
||||||
|
use App\Http\Requests\Bo\Users\UpdateUserRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Traits\Controllers\UpdateModelPublished;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class UsersController extends Controller
|
||||||
|
{
|
||||||
|
use UpdateModelPublished;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the controller instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->authorizeResource(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder $userModels */
|
||||||
|
$userModels = User::query();
|
||||||
|
|
||||||
|
/** @var string $search Search field */
|
||||||
|
$search = $request->search;
|
||||||
|
if ($search) {
|
||||||
|
$this->searchQuery(
|
||||||
|
$userModels,
|
||||||
|
$search,
|
||||||
|
null,
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'email',
|
||||||
|
'role',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$searchFields = \implode(', ', [
|
||||||
|
trans('validation.attributes.first_name'),
|
||||||
|
trans('validation.attributes.last_name'),
|
||||||
|
trans('validation.attributes.email'),
|
||||||
|
trans('validation.attributes.role'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** Sort columns with a query */
|
||||||
|
$this->sortQuery($userModels);
|
||||||
|
|
||||||
|
/** Custom pagination */
|
||||||
|
$userModels = $this->paginate($userModels);
|
||||||
|
|
||||||
|
return view('bo.pages.users.index', compact('userModels', 'search', 'searchFields'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function create(User $user): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.users.create', ['userModel' => $user]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Users\StoreUserRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function store(StoreUserRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request) {
|
||||||
|
$user = new User();
|
||||||
|
|
||||||
|
if ($user->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.users.edit', $user)
|
||||||
|
->with('success', __('crud.messages.has_been_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_created', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function edit(User $user): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return view('bo.pages.users.edit', ['userModel' => $user]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Users\UpdateUserRequest $request
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function update(UpdateUserRequest $request, User $user): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($request, $user) {
|
||||||
|
if ($user->fill($request->validated())->saveOrFail()) {
|
||||||
|
return redirect()->route('bo.users.edit', $user)
|
||||||
|
->with('success', __('crud.messages.has_been_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->route('bo.users.edit', $user)
|
||||||
|
->with('error', __('crud.messages.cannot_be_updated', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy(User $user): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($user->deleteOrFail()) {
|
||||||
|
return redirect()->route('bo.users.index')
|
||||||
|
->with('success', __('crud.messages.has_been_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
return redirect()->back()
|
||||||
|
->with('error', __('crud.messages.cannot_be_deleted', [
|
||||||
|
'model' => Str::ucfirst(__('models.classes.user'))
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duplicate the specified resource.
|
||||||
|
*
|
||||||
|
* @param \App\Models\User $user
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function duplicate(User $user): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
return $this->create($user->replicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
238
app/Http/Controllers/Controller.php
Normal file
238
app/Http/Controllers/Controller.php
Normal file
|
|
@ -0,0 +1,238 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Enums\Pagination\ItemsPerPaginationEnum;
|
||||||
|
use App\Enums\Theme\BootstrapThemeEnum;
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests;
|
||||||
|
use ValidatesRequests;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build Search query on specified fields
|
||||||
|
* splitting search into words or using whole sentence
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query The eloquent query builder.
|
||||||
|
* @param string $search The query string.
|
||||||
|
* @param callable|null $searchQuery The query string.
|
||||||
|
* @param string ...$fields Either a simple array or a string
|
||||||
|
* in case of a string the two fields
|
||||||
|
* would be concatenate to make the search.
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
protected function searchQuery(
|
||||||
|
Builder $query,
|
||||||
|
string $search,
|
||||||
|
callable|null $searchQuery = null,
|
||||||
|
string ...$fields
|
||||||
|
): \Illuminate\Database\Eloquent\Builder {
|
||||||
|
if (count($fields)) {
|
||||||
|
// Search using words.
|
||||||
|
$words = explode(' ', $search);
|
||||||
|
$query->where(function ($query) use ($searchQuery, $words, $search, $fields) {
|
||||||
|
foreach ($words as $word) {
|
||||||
|
if (!strlen($word)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->searchOnFields($query, $word, $fields);
|
||||||
|
} //end foreach
|
||||||
|
// Search whole using whole sentence.
|
||||||
|
$this->searchOnFields($query, $search, $fields);
|
||||||
|
if ($searchQuery) {
|
||||||
|
$searchQuery($query);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} //end if
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build query search on all fields
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $search
|
||||||
|
* @param array $fields
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
private function searchOnFields(
|
||||||
|
Builder $query,
|
||||||
|
string $search,
|
||||||
|
array $fields
|
||||||
|
): \Illuminate\Database\Eloquent\Builder {
|
||||||
|
$table = $query->getModel()->getTable();
|
||||||
|
foreach ($fields as $field) {
|
||||||
|
$field = str_replace('?', '\?', $field);
|
||||||
|
if (is_array($field)) {
|
||||||
|
$query->orWhereRaw(
|
||||||
|
sprintf("UPPER(CONCAT(%s)) LIKE UPPER(?)", collect($field)->map(function ($q) use ($table) {
|
||||||
|
return "`$table`.`$q`";
|
||||||
|
})->implode(', \' \', ')),
|
||||||
|
['%' . htmlspecialchars($search) . '%']
|
||||||
|
);
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
// Get models woth enum's label.
|
||||||
|
if (is_array($this->getSearchValue($query, $search, $field))) {
|
||||||
|
foreach ($this->getSearchValue($query, $search, $field) as $array) {
|
||||||
|
$query->orWhereRaw(
|
||||||
|
"UPPER(`$table`.`$field`) LIKE UPPER(?)",
|
||||||
|
['%' . htmlspecialchars($array->value) . '%']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
// Get models with relation's name/label.
|
||||||
|
if (Str::endsWith($field, '_id')) {
|
||||||
|
$query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) {
|
||||||
|
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
|
||||||
|
$queryRelation->where('name', 'like', '%' . $search . '%');
|
||||||
|
} elseif (Schema::hasColumn(Str::remove('_id', $field) . 's', 'label')) {
|
||||||
|
$queryRelation->where('label', 'like', '%' . $search . '%');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
$query->orWhereRaw(
|
||||||
|
"UPPER(`$table`.`$field`) LIKE UPPER(?)",
|
||||||
|
['%' . htmlspecialchars($this->getSearchValue($query, $search, $field)) . '%']
|
||||||
|
);
|
||||||
|
} //end foreach
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the search value (on string or Enum).
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param string $search
|
||||||
|
* @param string $field
|
||||||
|
* @return string|array
|
||||||
|
*/
|
||||||
|
protected function getSearchValue(Builder $query, string $search, string $field): string|array
|
||||||
|
{
|
||||||
|
$cast = $query->getModel()->getCasts()[$field] ?? null;
|
||||||
|
if (
|
||||||
|
count($query->getModel()->getCasts()) and // Check if the model has casts.
|
||||||
|
$cast and // Check if there is cast about specific field.
|
||||||
|
enum_exists($cast) // Check if the cast is an enum.
|
||||||
|
) {
|
||||||
|
/** @var \App\Traits\Enums $cast */
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
|
$cases = collect($cast::toArray());
|
||||||
|
$enum = $cases->filter(function ($item) use ($search) {
|
||||||
|
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
|
||||||
|
});
|
||||||
|
return $enum->toArray();
|
||||||
|
} else {
|
||||||
|
return $search;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sort columns with a query.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param array $ignore
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
protected function sortQuery(Builder $query, array $ignore = []): \Illuminate\Database\Eloquent\Builder
|
||||||
|
{
|
||||||
|
$rName = request()->route()->getName();
|
||||||
|
$table = $query->getModel()->getTable();
|
||||||
|
if (request()->input('sort_col')) {
|
||||||
|
Session::put("$rName.sort_col", request()->input('sort_col'));
|
||||||
|
Session::put("$rName.sorted", true);
|
||||||
|
}
|
||||||
|
if (request()->input('sort_way')) {
|
||||||
|
Session::put("$rName.sort_way", request()->input('sort_way'));
|
||||||
|
Session::put("$rName.sorted", true);
|
||||||
|
}
|
||||||
|
if (request()->rst) {
|
||||||
|
Session::remove("$rName.sorted");
|
||||||
|
Session::remove("$rName.sort_col");
|
||||||
|
Session::remove("$rName.sort_way");
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
request()->input('sort_col') and
|
||||||
|
request()->input('sort_way') and
|
||||||
|
Schema::hasColumn($table, request()->input('sort_col'))
|
||||||
|
) {
|
||||||
|
if (!in_array(request()->input('sort_col'), $ignore)) {
|
||||||
|
$query = $query->orderBy(
|
||||||
|
\sprintf("$table.%s", request()->input('sort_col')),
|
||||||
|
request()->input('sort_way')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} elseif (Schema::hasColumn($table, 'order')) {
|
||||||
|
$query = $query->orderBy('order', 'ASC');
|
||||||
|
Session::put("$rName.sort_col", 'order');
|
||||||
|
Session::put("$rName.sort_way", 'asc');
|
||||||
|
} elseif (Schema::hasColumn($table, 'updated_at')) {
|
||||||
|
$query = $query->orderBy('updated_at', 'DESC');
|
||||||
|
Session::put("$rName.sort_col", 'updated_at');
|
||||||
|
Session::put("$rName.sort_way", 'desc');
|
||||||
|
} elseif (Schema::hasColumn($table, 'created_at')) {
|
||||||
|
$query = $query->orderBy('created_at', 'DESC');
|
||||||
|
Session::put("$rName.sort_col", 'created_at');
|
||||||
|
Session::put("$rName.sort_way", 'desc');
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customize pagination with cache or config (default).
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||||
|
* @param \App\Enums\Pagination\ItemsPerPaginationEnum|null $pagination
|
||||||
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
protected function paginate(
|
||||||
|
Builder $query,
|
||||||
|
ItemsPerPaginationEnum|null $pagination = null
|
||||||
|
): \Illuminate\Contracts\Pagination\LengthAwarePaginator {
|
||||||
|
$currentRoutePath = Str::slug(request()->route()->getName());
|
||||||
|
$cacheKey = "pagination.{$currentRoutePath}";
|
||||||
|
$pagination = $pagination ?? ItemsPerPaginationEnum::twelve;
|
||||||
|
$pagination = ToolboxHelper::getValidatedEnum(
|
||||||
|
Cache::get($cacheKey, $pagination->value()),
|
||||||
|
'pagination',
|
||||||
|
'\App\Enums\Pagination\ItemsPerPaginationEnum',
|
||||||
|
);
|
||||||
|
if (Cache::get($cacheKey) !== $pagination) {
|
||||||
|
Cache::put($cacheKey, $pagination);
|
||||||
|
}
|
||||||
|
$query = $query->paginate($pagination);
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the bootstrap theme or light (default).
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
protected function setTheme(Request $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$theme = ToolboxHelper::getValidatedEnum(
|
||||||
|
$request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
|
||||||
|
'theme',
|
||||||
|
'\App\Http\Controllers\BootstrapThemeEnum',
|
||||||
|
);
|
||||||
|
if (Cache::get("theme") !== $theme) {
|
||||||
|
Cache::put("theme", $theme);
|
||||||
|
}
|
||||||
|
return redirect()->back()->with('success', __('crud.messages.theme_updated'));
|
||||||
|
}
|
||||||
|
}
|
||||||
69
app/Http/Controllers/Fo/NewsController.php
Normal file
69
app/Http/Controllers/Fo/NewsController.php
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Fo;
|
||||||
|
|
||||||
|
use App\Enums\StaticPageType;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Lib\Helpers\CollectionHelper;
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use App\Models\News;
|
||||||
|
use App\Models\StaticPage;
|
||||||
|
use Illuminate\Contracts\Database\Query\Builder;
|
||||||
|
|
||||||
|
class NewsController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::news)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\News $newsModels */
|
||||||
|
$newsModels = News::query()->where('published', true)->orderBy('publish_at', 'desc')->paginate(12);
|
||||||
|
|
||||||
|
return view('fo.pages.news.index', \compact('staticPageModel', 'newsModels'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a news articles
|
||||||
|
*
|
||||||
|
* @param string $slug
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function show(string $slug): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\News $newsModel */
|
||||||
|
$newsModel = News::query()
|
||||||
|
->where('published', true)
|
||||||
|
->where('slug', $slug)
|
||||||
|
->firstOrFail();
|
||||||
|
return view('fo.pages.news.show', \compact('newsModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filtered news.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function newsFiltered(): \Illuminate\Http\JsonResponse
|
||||||
|
{
|
||||||
|
$categoryId = ToolboxHelper::getValidatedEnum(
|
||||||
|
0,
|
||||||
|
'category',
|
||||||
|
'\App\Enums\News\CategoryEnum',
|
||||||
|
);
|
||||||
|
$newsModels = News::query()
|
||||||
|
->where('published', true)
|
||||||
|
->when($categoryId != 0, function (Builder $query) use ($categoryId) {
|
||||||
|
$query->where('category', $categoryId);
|
||||||
|
})
|
||||||
|
->orderBy('publish_at', 'desc')
|
||||||
|
->get();
|
||||||
|
$newsModels = CollectionHelper::paginateManually($newsModels, 12, request()->page ?? 1);
|
||||||
|
return response()->json($newsModels);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/Http/Controllers/Fo/ProductController.php
Normal file
45
app/Http/Controllers/Fo/ProductController.php
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Fo;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Lib\Helpers\CollectionHelper;
|
||||||
|
use App\Models\Product;
|
||||||
|
|
||||||
|
class ProductController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display the product page.
|
||||||
|
*
|
||||||
|
* @param string $slug
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function show(string $slug): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$productModel = Product::query()->where('slug', $slug)->firstOrFail();
|
||||||
|
|
||||||
|
$otherProductModels = $productModel->range->products()
|
||||||
|
->where('id', '!=', $productModel->id)
|
||||||
|
->where('published', true)
|
||||||
|
->inRandomOrder()
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('fo.pages.products.show', compact('productModel', 'otherProductModels'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filtered products.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function productsFiltered(): \Illuminate\Http\JsonResponse
|
||||||
|
{
|
||||||
|
$productModels = Product::query()
|
||||||
|
->where('published', true)
|
||||||
|
->where('range_id', request()->range_id)
|
||||||
|
->orderBy('order', 'asc')
|
||||||
|
->get();
|
||||||
|
$productModels = CollectionHelper::paginateManually($productModels, 12, request()->page ?? 1);
|
||||||
|
return response()->json($productModels);
|
||||||
|
}
|
||||||
|
}
|
||||||
65
app/Http/Controllers/Fo/RangeController.php
Normal file
65
app/Http/Controllers/Fo/RangeController.php
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Fo;
|
||||||
|
|
||||||
|
use App\Enums\StaticPageType;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Lib\Helpers\CollectionHelper;
|
||||||
|
use App\Models\Product;
|
||||||
|
use App\Models\Range;
|
||||||
|
use App\Models\StaticPage;
|
||||||
|
|
||||||
|
class RangeController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function index(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::ranges)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\Range $rangeModels */
|
||||||
|
$rangeModels = Range::query()->where('published', true)->orderBy('order')->paginate(12);
|
||||||
|
|
||||||
|
return view('fo.pages.ranges.index', compact('rangeModels', 'staticPageModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a specific resource.
|
||||||
|
*
|
||||||
|
* @param string $slug
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function show(string $slug): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\Range $rangeModel */
|
||||||
|
$rangeModel = Range::query()->where('published', true)->where('slug', $slug)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\Product $productModels */
|
||||||
|
$productModels = Product::query()
|
||||||
|
->where('range_id', $rangeModel->id)
|
||||||
|
->where('published', true)
|
||||||
|
->orderBy('order')
|
||||||
|
->paginate(12);
|
||||||
|
|
||||||
|
return view('fo.pages.ranges.show', compact('rangeModel', 'productModels'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get filtered ranges.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function rangesFiltered(): \Illuminate\Http\JsonResponse
|
||||||
|
{
|
||||||
|
$productModels = Range::query()
|
||||||
|
->where('published', true)
|
||||||
|
->orderBy('order', 'asc')
|
||||||
|
->get();
|
||||||
|
$productModels = CollectionHelper::paginateManually($productModels, 12, request()->page ?? 1);
|
||||||
|
return response()->json($productModels);
|
||||||
|
}
|
||||||
|
}
|
||||||
207
app/Http/Controllers/Fo/StaticPageController.php
Normal file
207
app/Http/Controllers/Fo/StaticPageController.php
Normal file
|
|
@ -0,0 +1,207 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Fo;
|
||||||
|
|
||||||
|
use App\Enums\Contact\ObjectEnum;
|
||||||
|
use App\Enums\StaticPageType;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Requests\Fo\ContactRequest;
|
||||||
|
use App\Http\Requests\Fo\JoinusRequest;
|
||||||
|
use App\Mail\SendContactMail;
|
||||||
|
use App\Mail\SendJoinusMail;
|
||||||
|
use App\Models\Convictionpage;
|
||||||
|
use App\Models\Explorerpage;
|
||||||
|
use App\Models\Homepage;
|
||||||
|
use App\Models\Joinuspage;
|
||||||
|
use App\Models\News;
|
||||||
|
use App\Models\Range;
|
||||||
|
use App\Models\SeasonalSection;
|
||||||
|
use App\Models\StaticPage;
|
||||||
|
use App\Models\Testimonial;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
class StaticPageController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* About us show
|
||||||
|
*
|
||||||
|
* @param \App\Models\StaticPage $aboutUsPage
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function aboutUs(StaticPage $aboutUsPage): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$aboutUsPage = StaticPage::query()->where('type', StaticPageType::aboutus)
|
||||||
|
->get();
|
||||||
|
return view('fo.pages.about-us', ['staticPageModel' => $aboutUsPage[0]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legal show
|
||||||
|
*
|
||||||
|
* @param \App\Models\StaticPage $legalPage
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function legals(StaticPage $legalPage): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$legalPage = StaticPage::query()->where('type', StaticPageType::legals)->get();
|
||||||
|
return view('fo.pages.legals', ['staticPageModel' => $legalPage[0]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Policies show
|
||||||
|
*
|
||||||
|
* @param \App\Models\StaticPage $policiesPage
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function policies(StaticPage $policiesPage): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
$policiesPage = StaticPage::query()->where('type', StaticPageType::confidentiality)->get();
|
||||||
|
return view('fo.pages.legals', ['staticPageModel' => $policiesPage[0]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function homepage(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\Homepage $homepageModel */
|
||||||
|
$homepageModel = Homepage::query()->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::home)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\SeasonalSection $seasonalSectionsModel */
|
||||||
|
$seasonalSectionsModel = SeasonalSection::query()->where('published', true)->first();
|
||||||
|
|
||||||
|
/** @var \App\Models\News $newsModels */
|
||||||
|
$newsModels = News::query()->where('published', true)->latest('publish_at')->limit(2)->get();
|
||||||
|
|
||||||
|
/** @var \App\Models\Range $rangeModels */
|
||||||
|
$rangeModels = Range::query()->where('published', true)->orderBy('order')->get();
|
||||||
|
|
||||||
|
return view('fo.pages.home', compact(
|
||||||
|
'homepageModel',
|
||||||
|
'staticPageModel',
|
||||||
|
'seasonalSectionsModel',
|
||||||
|
'newsModels',
|
||||||
|
'rangeModels',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function contact(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\StaticPage $contactModel */
|
||||||
|
$contactModel = StaticPage::query()->where('type', StaticPageType::contact)->firstOrFail();
|
||||||
|
|
||||||
|
return view('fo.pages.contact', compact('contactModel'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle contactForm Request
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Fo\ContactRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function contactForm(ContactRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
if ($request->object === strval(ObjectEnum::customerService->value())) {
|
||||||
|
$receivers = \config('mail.contactform.customerService');
|
||||||
|
} else {
|
||||||
|
$receivers = \config('mail.contactform.receiver');
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($receivers as $email) {
|
||||||
|
Mail::to($email)->send(new SendContactMail((object)$request->validated()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('fo.contact.show')
|
||||||
|
->with(
|
||||||
|
'success',
|
||||||
|
'Bonjour, votre message a bien été transmis. nous vous en remercions. Cordialement, l’équipe Agis.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the explorer and gastronome page.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function explorer(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\Explorerpage $explorerpageModel */
|
||||||
|
$explorerpageModel = Explorerpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::explorer)->firstOrFail();
|
||||||
|
|
||||||
|
return view('fo.pages.explorer-and-gastronome', compact(
|
||||||
|
'explorerpageModel',
|
||||||
|
'staticPageModel',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the convictions page.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function convictions(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\Convictionpage $convictionpageModel */
|
||||||
|
$convictionpageModel = Convictionpage::query()->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::conviction)->firstOrFail();
|
||||||
|
|
||||||
|
return view('fo.pages.convictions', compact(
|
||||||
|
'convictionpageModel',
|
||||||
|
'staticPageModel',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the explorer and gastonome page.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\View
|
||||||
|
*/
|
||||||
|
public function joinus(): \Illuminate\Contracts\View\View
|
||||||
|
{
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::joinus)->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\Joinuspage $joinuspageModel */
|
||||||
|
$joinuspageModel = Joinuspage::query()->firstOrFail();
|
||||||
|
|
||||||
|
/** @var \App\Models\Testimonial $testimonialModels */
|
||||||
|
$testimonialModels = Testimonial::query()->get();
|
||||||
|
|
||||||
|
return view('fo.pages.join-us', compact('staticPageModel', 'joinuspageModel', 'testimonialModels'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle joinusForm Request
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Fo\JoinusRequest $request
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function joinusForm(JoinusRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
$receivers = \config('mail.contactform.receiver');
|
||||||
|
foreach ($receivers as $email) {
|
||||||
|
Mail::to($email)->send(new SendJoinusMail((object)$request->validated()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('fo.joinus.show')
|
||||||
|
->with(
|
||||||
|
'success',
|
||||||
|
'Bonjour, votre candidature a bien été transmise. nous vous en remercions. Cordialement, l’équipe Agis.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
app/Http/Kernel.php
Normal file
76
app/Http/Kernel.php
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The application's global HTTP middleware stack.
|
||||||
|
*
|
||||||
|
* These middleware are run during every request to your application.
|
||||||
|
*
|
||||||
|
* @var array<int, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middleware = [
|
||||||
|
\App\Http\Middleware\TrustHosts::class,
|
||||||
|
\App\Http\Middleware\TrustProxies::class,
|
||||||
|
\Illuminate\Http\Middleware\HandleCors::class,
|
||||||
|
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||||
|
\App\Http\Middleware\TrimStrings::class,
|
||||||
|
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware groups.
|
||||||
|
*
|
||||||
|
* @var array<string, array<int, class-string|string>>
|
||||||
|
*/
|
||||||
|
protected $middlewareGroups = [
|
||||||
|
'web' => [
|
||||||
|
'htmlsanitize',
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||||
|
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
\App\Http\Middleware\SecureHeaders::class
|
||||||
|
],
|
||||||
|
|
||||||
|
'saml' => [
|
||||||
|
\App\Http\Middleware\EncryptCookies::class,
|
||||||
|
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||||
|
\Illuminate\Session\Middleware\StartSession::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
'api' => [
|
||||||
|
\Illuminate\Routing\Middleware\ThrottleRequests::class . ':api',
|
||||||
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application's route middleware.
|
||||||
|
*
|
||||||
|
* These middleware may be assigned to groups or used individually.
|
||||||
|
*
|
||||||
|
* @var array<string, class-string|string>
|
||||||
|
*/
|
||||||
|
protected $middlewareAliases = [
|
||||||
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
|
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||||
|
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||||
|
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||||
|
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||||
|
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||||
|
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||||
|
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||||
|
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||||
|
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
|
||||||
|
'local-development' => \App\Http\Middleware\LocalDevelopment::class,
|
||||||
|
];
|
||||||
|
}
|
||||||
39
app/Http/Middleware/Authenticate.php
Normal file
39
app/Http/Middleware/Authenticate.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
|
||||||
|
class Authenticate extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the path the user should be redirected to when they are not authenticated.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
protected function redirectTo(Request $request): ?string
|
||||||
|
{
|
||||||
|
$logins = [
|
||||||
|
'backend' => route('bo.login')
|
||||||
|
];
|
||||||
|
if (!$request->expectsJson()) {
|
||||||
|
// * Notify must login
|
||||||
|
Session::flash('warning', trans('Veuillez vous connecter pour continuer'));
|
||||||
|
|
||||||
|
foreach ($request->route()->gatherMiddleware() as $middleware) {
|
||||||
|
if (\is_string($middleware) and strpos($middleware, 'auth:') !== false) {
|
||||||
|
$route = $logins[str_replace('auth:', '', $middleware)] ?? null;
|
||||||
|
if ($route) {
|
||||||
|
return $route;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return route('login');
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Http/Middleware/EncryptCookies.php
Normal file
15
app/Http/Middleware/EncryptCookies.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||||
|
|
||||||
|
class EncryptCookies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the cookies that should not be encrypted.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [];
|
||||||
|
}
|
||||||
61
app/Http/Middleware/HtmlSanitizer.php
Normal file
61
app/Http/Middleware/HtmlSanitizer.php
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class HtmlSanitizer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @param string|array ...$params
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, \Closure $next, string|array ...$params): Response
|
||||||
|
{
|
||||||
|
$inputs = $request->all();
|
||||||
|
/** @var callable|null */
|
||||||
|
$cleanInput = null;
|
||||||
|
$cleanInput = function (
|
||||||
|
null|string|array &$input,
|
||||||
|
string $name,
|
||||||
|
?string $rootName = null
|
||||||
|
) use (
|
||||||
|
$params,
|
||||||
|
&$cleanInput
|
||||||
|
): void {
|
||||||
|
// * Nested element array
|
||||||
|
if (is_array($input)) {
|
||||||
|
array_walk_recursive($input, $cleanInput, $name);
|
||||||
|
}
|
||||||
|
if (!is_string($input)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (in_array($name, $params) or in_array($rootName ?? $name, $params)) {
|
||||||
|
// ? Is a json input ?
|
||||||
|
if ($isJson = \json_decode($input, true) and is_array($isJson)) {
|
||||||
|
// ! Decode each json field recursive.
|
||||||
|
\array_walk_recursive($isJson, function (string|array &$item) {
|
||||||
|
if (\is_string($item)) {
|
||||||
|
$item = clean($item);
|
||||||
|
$item = ToolboxHelper::stripCkEditorSchemesOnMediaInputs($item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$input = clean($input);
|
||||||
|
$input = ToolboxHelper::stripCkEditorSchemesOnMediaInputs($input);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$input = strip_tags($input);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
\array_walk($inputs, $cleanInput);
|
||||||
|
$request->merge($inputs);
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
app/Http/Middleware/LocalDevelopment.php
Normal file
25
app/Http/Middleware/LocalDevelopment.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class LocalDevelopment
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure $next
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
if (app()->environment() != 'local') {
|
||||||
|
return abort(403, 'You are not authorized to access this');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
15
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||||
|
|
||||||
|
class PreventRequestsDuringMaintenance extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be reachable while maintenance mode is enabled.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [];
|
||||||
|
}
|
||||||
43
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
43
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class RedirectIfAuthenticated
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
* @param string|null ...$guards
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
* @throws \RuntimeException If guard is unhandled.
|
||||||
|
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, \Closure $next, ...$guards): Response
|
||||||
|
{
|
||||||
|
// phpcs:enable phpcs:disable
|
||||||
|
$guards = empty($guards) ? [null] : $guards;
|
||||||
|
|
||||||
|
foreach ($guards as $guard) {
|
||||||
|
if (auth($guard)->check()) {
|
||||||
|
switch ($guard) {
|
||||||
|
case 'frontend':
|
||||||
|
return \redirect()->route('fo.homepage');
|
||||||
|
case 'backend':
|
||||||
|
if (!$request->routeIs('bo.*')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return \redirect()->route('bo.dashboard');
|
||||||
|
default:
|
||||||
|
throw new \RuntimeException("Unhandled guard `{$guard}` .");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
133
app/Http/Middleware/SecureHeaders.php
Normal file
133
app/Http/Middleware/SecureHeaders.php
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\Support\Facades\View;
|
||||||
|
use Illuminate\Support\Facades\Vite;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
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/
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $unwantedHeaderList = [
|
||||||
|
'X-Powered-By',
|
||||||
|
'Server',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
|
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
// * For Vite DEV
|
||||||
|
$host = \parse_url(\config('app.url'), \PHP_URL_HOST);
|
||||||
|
View::share('nonce', $nonce = Vite::useCspNonce());
|
||||||
|
// * For VueJS dev tool to execute
|
||||||
|
$jsDev = config('app.debug') ? "'unsafe-eval' 'unsafe-inline'" : "'nonce-{$nonce}' 'strict-dynamic'";
|
||||||
|
$scheme = config('app.env') === 'local' ? 'http' : 'https';
|
||||||
|
$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');
|
||||||
|
$response->headers->set('X-Content-Type-Options', 'nosniff');
|
||||||
|
$response->headers->set('X-XSS-Protection', '1; mode=block');
|
||||||
|
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
|
||||||
|
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;');
|
||||||
|
$cspPolicies = [
|
||||||
|
"default-src 'none';",
|
||||||
|
"manifest-src 'self';",
|
||||||
|
// * CKEDITOR Specific https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html
|
||||||
|
"connect-src 'self' " . implode(' ', [
|
||||||
|
// * VITE DEV
|
||||||
|
config('app.debug') ? "wss://{$host}:4443" : '',
|
||||||
|
config('app.debug') ? "https://{$host}:4443" : '',
|
||||||
|
'https://yl.s-web.fr',
|
||||||
|
]) . ';',
|
||||||
|
"img-src 'self' data: blob: " . implode(' ', [
|
||||||
|
'https://yl.s-web.fr',
|
||||||
|
// * VITE DEV
|
||||||
|
config('app.debug') ? "https://{$host}:4443" : ''
|
||||||
|
]) . ';',
|
||||||
|
'frame-src ' . implode(' ', [
|
||||||
|
'https://www.google.com/recaptcha/',
|
||||||
|
'https://recaptcha.google.com/recaptcha/',
|
||||||
|
'https://www.google.com/maps/',
|
||||||
|
'https://www.youtube.com',
|
||||||
|
'https://player.vimeo.com',
|
||||||
|
]) . ';',
|
||||||
|
"font-src 'self' data: " . \implode(' ', [
|
||||||
|
// * VITE DEV
|
||||||
|
config('app.debug') ? "https://{$host}:4443" : '',
|
||||||
|
'https://fonts.gstatic.com;'
|
||||||
|
]) . ';',
|
||||||
|
// ! Using CKEditor will must have unsafe-inline style
|
||||||
|
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||||
|
"style-src 'self' 'unsafe-inline' " . \implode(' ', [
|
||||||
|
'https://cdnjs.cloudflare.com',
|
||||||
|
// * File Manager
|
||||||
|
'https://fonts.googleapis.com',
|
||||||
|
'https://cdn.jsdelivr.net',
|
||||||
|
'https://use.fontawesome.com',
|
||||||
|
'https://fonts.googleapis.com',
|
||||||
|
// * VITE DEV
|
||||||
|
config('app.debug') ? "https://{$host}:4443" : '',
|
||||||
|
]) . ';',
|
||||||
|
// ! If you dont use ckeditor use this
|
||||||
|
// "style-src 'self' 'nonce-$nonce';",
|
||||||
|
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||||
|
"script-src 'self' {$jsDev} " . \implode(' ', [
|
||||||
|
'https: blob:',
|
||||||
|
'https://www.googletagmanager.com',
|
||||||
|
'https://cdnjs.cloudflare.com',
|
||||||
|
"$scheme://www.google-analytics.com",
|
||||||
|
'https://www.google.com/recaptcha/',
|
||||||
|
'https://www.gstatic.com/recaptcha/',
|
||||||
|
'https://yl.s-web.fr',
|
||||||
|
// * VITE DEV
|
||||||
|
config('app.debug') ? "https://{$host}:4443" : '',
|
||||||
|
]) . ';'
|
||||||
|
];
|
||||||
|
|
||||||
|
$response->headers->set(
|
||||||
|
'Content-Security-Policy',
|
||||||
|
implode(' ', $cspPolicies) . $reportUri
|
||||||
|
);
|
||||||
|
$response->headers->set('Feature-Policy', \implode(',', [
|
||||||
|
'fullscreen',
|
||||||
|
'accelerometer',
|
||||||
|
'encrypted-media',
|
||||||
|
'gyroscope',
|
||||||
|
'picture-in-picture'
|
||||||
|
]) . ';');
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove unwanted headers
|
||||||
|
*
|
||||||
|
* @param array $headerList
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function removeUnwantedHeaders(array $headerList): void
|
||||||
|
{
|
||||||
|
foreach ($headerList as $header) {
|
||||||
|
header_remove($header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||||
|
|
||||||
|
class TrimStrings extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the attributes that should not be trimmed.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'current_password',
|
||||||
|
'password',
|
||||||
|
'password_confirmation',
|
||||||
|
];
|
||||||
|
}
|
||||||
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||||
|
|
||||||
|
class TrustHosts extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the host patterns that should be trusted.
|
||||||
|
*
|
||||||
|
* @return array<int, string|null>
|
||||||
|
*/
|
||||||
|
public function hosts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->allSubdomainsOfApplicationUrl(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TrustProxies extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trusted proxies for this application.
|
||||||
|
*
|
||||||
|
* @var array<int, string>|string|null
|
||||||
|
*/
|
||||||
|
protected $proxies;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The headers that should be used to detect proxies.
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
|
}
|
||||||
15
app/Http/Middleware/ValidateSignature.php
Normal file
15
app/Http/Middleware/ValidateSignature.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||||
|
|
||||||
|
class ValidateSignature extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The names of the query string parameters that should be ignored.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [];
|
||||||
|
}
|
||||||
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||||
|
|
||||||
|
class VerifyCsrfToken extends Middleware
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The URIs that should be excluded from CSRF verification.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
protected $except = [
|
||||||
|
'/csp-report'
|
||||||
|
];
|
||||||
|
}
|
||||||
68
app/Http/Requests/Bo/Commitments/StoreCommitmentRequest.php
Normal file
68
app/Http/Requests/Bo/Commitments/StoreCommitmentRequest.php
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Commitments;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreCommitmentRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'title' => 'required|string|min:3|max:255',
|
||||||
|
'picture_alt' => 'required|string|min:3|max:255',
|
||||||
|
'picture_title' => 'required|string|min:3|max:255',
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 185, 185, 185, 185, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt', ['field' => __('validation.custom.picture')]),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title', ['field' => __('validation.custom.picture')]),
|
||||||
|
'published' => trans('validation.attributes.published'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Commitments;
|
||||||
|
|
||||||
|
class UpdateCommitmentRequest extends StoreCommitmentRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Convictionpages;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateConvictionpageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'key_feed' => 'required|numeric|max:2147483647',
|
||||||
|
'key_earth_1' => 'required|numeric|max:2147483647',
|
||||||
|
'key_earth_2' => 'required|numeric|max:2147483647',
|
||||||
|
'key_together_1' => 'required|numeric|max:2147483647',
|
||||||
|
'key_together_2' => 'required|numeric|max:2147483647',
|
||||||
|
'key_together_3' => 'required|numeric|max:2147483647',
|
||||||
|
'key_together_4' => 'required|numeric|max:2147483647',
|
||||||
|
'key_territory' => 'required|numeric|max:2147483647',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'key_feed' => trans('validation.custom.key_feed'),
|
||||||
|
'key_earth_1' => trans('validation.custom.key_earth_1'),
|
||||||
|
'key_earth_2' => trans('validation.custom.key_earth_2'),
|
||||||
|
'key_together_1' => trans('validation.custom.key_together_1'),
|
||||||
|
'key_together_2' => trans('validation.custom.key_together_2'),
|
||||||
|
'key_together_3' => trans('validation.custom.key_together_3'),
|
||||||
|
'key_together_4' => trans('validation.custom.key_together_4'),
|
||||||
|
'key_territory' => trans('validation.custom.key_territory'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Explorerpage;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateExplorerpageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->mergePicture('picture_1');
|
||||||
|
$this->mergePicture('picture_2');
|
||||||
|
$this->mergePicture('picture_3');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'picture_1_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_1_title' => 'required|string|between:3,255',
|
||||||
|
'picture_2_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_2_title' => 'required|string|between:3,255',
|
||||||
|
'picture_3_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_3_title' => 'required|string|between:3,255',
|
||||||
|
'commitments' => 'required|array',
|
||||||
|
'commitments.*.id' => 'required|exists:commitments,id',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture_1', 265, 364, 265, 364, false),
|
||||||
|
$this->pictureRules('picture_2', 265, 364, 265, 364, false),
|
||||||
|
$this->pictureRules('picture_3', 265, 364, 265, 364, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'picture_1_alt' => trans('validation.custom.picture_alt', [
|
||||||
|
'field' => __('validation.custom.picture_1')
|
||||||
|
]),
|
||||||
|
'picture_1_title' => trans('validation.custom.picture_title', [
|
||||||
|
'field' => __('validation.custom.picture_1')
|
||||||
|
]),
|
||||||
|
'picture_2_alt' => trans('validation.custom.picture_alt', [
|
||||||
|
'field' => __('validation.custom.picture_2')
|
||||||
|
]),
|
||||||
|
'picture_2_title' => trans('validation.custom.picture_title', [
|
||||||
|
'field' => __('validation.custom.picture_2')
|
||||||
|
]),
|
||||||
|
'picture_3_alt' => trans('validation.custom.picture_alt', [
|
||||||
|
'field' => __('validation.custom.picture_3')
|
||||||
|
]),
|
||||||
|
'picture_3_title' => trans('validation.custom.picture_title', [
|
||||||
|
'field' => __('validation.custom.picture_3')
|
||||||
|
]),
|
||||||
|
'commitments' => trans('validation.custom.commitments'),
|
||||||
|
'commitments.*.id' => trans('validation.custom.commitments'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
91
app/Http/Requests/Bo/Homepage/UpdateHomepageRequest.php
Normal file
91
app/Http/Requests/Bo/Homepage/UpdateHomepageRequest.php
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Homepage;
|
||||||
|
|
||||||
|
use App\Rules\IsValidVimeoId;
|
||||||
|
use App\Rules\IsValidYoutubeId;
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateHomepageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'display_video' => $this->boolean('display_video')
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'title_part1' => 'required|string|between:3,255',
|
||||||
|
'title_part2' => 'required|string|between:3,255',
|
||||||
|
'title_part3' => 'required|string|between:3,255',
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'presentation_title' => 'required|string|between:3,255',
|
||||||
|
'presentation_content' => 'required|string',
|
||||||
|
'display_video' => 'present|boolean',
|
||||||
|
'video_id' => [
|
||||||
|
'nullable', 'required_if:display_video,true',
|
||||||
|
function (string $attribute, mixed $value, \Closure $fail) {
|
||||||
|
if (!IsValidYoutubeId::validates($value) and !IsValidVimeoId::validates($value)) {
|
||||||
|
(new IsValidYoutubeId())->validate($attribute, $value, $fail);
|
||||||
|
(new IsValidVimeoId())->validate($attribute, $value, $fail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 640, 390, 640, 390, true, requiredIf: 'display_video,false'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'video_id' => trans('validation.custom.video_id'),
|
||||||
|
'title_part1' => trans('validation.custom.title_part1'),
|
||||||
|
'title_part2' => trans('validation.custom.title_part2'),
|
||||||
|
'title_part3' => trans('validation.custom.title_part3'),
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt', [
|
||||||
|
'field' => __('validation.custom.picture')
|
||||||
|
]),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title', [
|
||||||
|
'field' => __('validation.custom.picture')
|
||||||
|
]),
|
||||||
|
'presentation_title' => trans('validation.custom.presentation_title'),
|
||||||
|
'presentation_content' => trans('validation.custom.presentation_content'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/Http/Requests/Bo/Joinuspage/UpdateJoinuspageRequest.php
Normal file
52
app/Http/Requests/Bo/Joinuspage/UpdateJoinuspageRequest.php
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Joinuspage;
|
||||||
|
|
||||||
|
use App\Rules\IsValidVimeoId;
|
||||||
|
use App\Rules\IsValidYoutubeId;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateJoinuspageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'video_id' => [
|
||||||
|
'required', 'string',
|
||||||
|
function (string $attribute, mixed $value, \Closure $fail) {
|
||||||
|
if (!IsValidYoutubeId::validates($value) and !IsValidVimeoId::validates($value)) {
|
||||||
|
(new IsValidYoutubeId())->validate($attribute, $value, $fail);
|
||||||
|
(new IsValidVimeoId())->validate($attribute, $value, $fail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'video_id' => trans('validation.custom.video_id'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
91
app/Http/Requests/Bo/News/StoreNewsRequest.php
Normal file
91
app/Http/Requests/Bo/News/StoreNewsRequest.php
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\News;
|
||||||
|
|
||||||
|
use App\Enums\News\CategoryEnum;
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class StoreNewsRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
$this->mergePicture('picture_thumbnail');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'seo_title' => 'required|between:45,70',
|
||||||
|
'seo_description' => 'required|between:50,160',
|
||||||
|
'title' => 'required|string|between:3,100',
|
||||||
|
'category' => ['required', new Enum(CategoryEnum::class)],
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_title' => 'required|string|between:3,255',
|
||||||
|
'subtitle' => 'required|string|between:3,255',
|
||||||
|
'content' => 'required|string|min:15',
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
'publish_at' => 'required|date',
|
||||||
|
'unpublish_at' => 'nullable|date|after:publish_at',
|
||||||
|
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 1002, 565, 1002, 565, false),
|
||||||
|
$this->pictureRules('picture_thumbnail', 265, 354, 265, 354, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'seo_title' => trans('validation.custom.seo_title'),
|
||||||
|
'seo_description' => trans('validation.custom.seo_description'),
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'category' => trans('validation.custom.category'),
|
||||||
|
'subtitle' => trans('validation.custom.subtitle'),
|
||||||
|
'content' => trans('validation.attributes.content'),
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title'),
|
||||||
|
'picture_thumbnail_alt' => trans('validation.custom.picture_thumbnail_alt'),
|
||||||
|
'picture_thumbnail_title' => trans('validation.custom.picture_thumbnail_title'),
|
||||||
|
'published' => trans('validation.custom.activated'),
|
||||||
|
'publish_at' => trans('validation.custom.publish_at'),
|
||||||
|
'unpublish_at' => trans('validation.custom.unpublish_at'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/Http/Requests/Bo/News/UpdateNewsRequest.php
Normal file
7
app/Http/Requests/Bo/News/UpdateNewsRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\News;
|
||||||
|
|
||||||
|
class UpdateNewsRequest extends StoreNewsRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
163
app/Http/Requests/Bo/Products/StoreProductRequest.php
Normal file
163
app/Http/Requests/Bo/Products/StoreProductRequest.php
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Products;
|
||||||
|
|
||||||
|
use App\Enums\Products\CookingModeEnum;
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class StoreProductRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture_thumbnail');
|
||||||
|
$this->mergePicture('picture_ambiance');
|
||||||
|
$this->mergePicture('picture_packshot');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'seo_title' => 'required|between:45,70',
|
||||||
|
'seo_description' => 'required|between:50,160',
|
||||||
|
'title' => 'required|string|between:3,100',
|
||||||
|
'subtitle' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_title' => 'required|string|between:3,255',
|
||||||
|
'picture_ambiance_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_ambiance_title' => 'required|string|between:3,255',
|
||||||
|
'picture_packshot_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_packshot_title' => 'required|string|between:3,255',
|
||||||
|
'description' => 'required|string|min:15',
|
||||||
|
'cooking_mode' => ['required', new Enum(CookingModeEnum::class)],
|
||||||
|
'cooking_advice' => 'required|string|min:15',
|
||||||
|
'ingredients' => 'required|string|min:15',
|
||||||
|
'nutritionnal_values' => 'required|array',
|
||||||
|
'nutritionnal_values.*' => 'required|numeric|min:0',
|
||||||
|
'range_id' => 'required|exists:ranges,id',
|
||||||
|
'commitments' => 'nullable|array',
|
||||||
|
'commitments.*.id' => 'required|exists:commitments,id',
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture_thumbnail', 332, 252, 332, 252, false),
|
||||||
|
$this->pictureRules('picture_ambiance', 1115, 790, 1115, 790, false),
|
||||||
|
$this->pictureRules('picture_packshot', 560, 480, 560, 480, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override validated() function from FormRequest.
|
||||||
|
*
|
||||||
|
* @param array|integer|string|null $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @return array|null
|
||||||
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed
|
||||||
|
*/
|
||||||
|
public function validated($key = null, mixed $default = null): array|null
|
||||||
|
{
|
||||||
|
if ($key === 'commitments') {
|
||||||
|
return parent::validated($key, $default);
|
||||||
|
}
|
||||||
|
// phpcs:enable
|
||||||
|
$nutritionnal_values = json_encode([
|
||||||
|
"energyKj" => [
|
||||||
|
"label" => "ÉNERGIE (kJ)",
|
||||||
|
"value" => $this->nutritionnal_values['energy_kj'],
|
||||||
|
],
|
||||||
|
"energyKcal" => [
|
||||||
|
"label" => "ÉNERGIE (kcal)",
|
||||||
|
"value" => $this->nutritionnal_values['energy_kcal'],
|
||||||
|
],
|
||||||
|
"fat" => [
|
||||||
|
"label" => "MATIÈRES GRASSES (g)",
|
||||||
|
"value" => $this->nutritionnal_values['fat'],
|
||||||
|
],
|
||||||
|
"saturated-fat" => [
|
||||||
|
"label" => "ACIDES GRAS SATURÉS (g)",
|
||||||
|
"value" => $this->nutritionnal_values['saturated_fat'],
|
||||||
|
],
|
||||||
|
"carbohydrate" => [
|
||||||
|
"label" => "GLUCIDES (g)",
|
||||||
|
"value" => $this->nutritionnal_values['carbohydrate'],
|
||||||
|
],
|
||||||
|
"sugar" => [
|
||||||
|
"label" => "SUCRES (g)",
|
||||||
|
"value" => $this->nutritionnal_values['sugar'],
|
||||||
|
],
|
||||||
|
"proteins" => [
|
||||||
|
"label" => "PROTÉINES (g)",
|
||||||
|
"value" => $this->nutritionnal_values['proteins'],
|
||||||
|
],
|
||||||
|
"salt" => [
|
||||||
|
"label" => "SEL (g)",
|
||||||
|
"value" => $this->nutritionnal_values['salt'],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
return array_merge(
|
||||||
|
parent::validated($key, $default),
|
||||||
|
[
|
||||||
|
'nutritionnal_values' => $nutritionnal_values
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'seo_title' => trans('validation.custom.seo_title'),
|
||||||
|
'seo_description' => trans('validation.custom.seo_description'),
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'subtitle' => trans('validation.custom.subtitle'),
|
||||||
|
'description' => trans('validation.custom.description'),
|
||||||
|
'picture_thumbnail_alt' => trans('validation.custom.picture_thumbnail_alt'),
|
||||||
|
'picture_thumbnail_title' => trans('validation.custom.picture_thumbnail_title'),
|
||||||
|
'picture_ambiance_alt' => trans('validation.custom.picture_ambiance_alt'),
|
||||||
|
'picture_ambiance_title' => trans('validation.custom.picture_ambiance_title'),
|
||||||
|
'picture_packshot_alt' => trans('validation.custom.picture_packshot_alt'),
|
||||||
|
'picture_packshot_title' => trans('validation.custom.picture_packshot_title'),
|
||||||
|
'cooking_mode' => trans('validation.custom.cooking_mode'),
|
||||||
|
'cooking_advice' => trans('validation.custom.cooking_advice'),
|
||||||
|
'ingredients' => trans('validation.custom.ingredients'),
|
||||||
|
'nutritionnal_values' => trans('validation.custom.nutritionnal_values'),
|
||||||
|
'range_id' => trans('models.classes.range'),
|
||||||
|
'commitments' => trans('Engagements associés au produit'),
|
||||||
|
'commitments.*.id' => trans('Élément parmis les engagements associés au produit'),
|
||||||
|
'published' => trans('validation.custom.activated'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/Http/Requests/Bo/Products/UpdateProductRequest.php
Normal file
7
app/Http/Requests/Bo/Products/UpdateProductRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Products;
|
||||||
|
|
||||||
|
class UpdateProductRequest extends StoreProductRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
90
app/Http/Requests/Bo/Ranges/StoreRangeRequest.php
Normal file
90
app/Http/Requests/Bo/Ranges/StoreRangeRequest.php
Normal file
|
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Ranges;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreRangeRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
$this->mergePicture('picture_productsheet');
|
||||||
|
$this->mergePicture('picture_thumbnail');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'seo_title' => 'required|between:45,70',
|
||||||
|
'seo_description' => 'required|between:50,160',
|
||||||
|
'title' => 'required|string|between:3,100',
|
||||||
|
'subtitle' => 'required|string|between:3,255',
|
||||||
|
'tagline' => 'required|string|between:3,255',
|
||||||
|
'description' => 'required|string|min:15',
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'picture_productsheet_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_productsheet_title' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_thumbnail_title' => 'required|string|between:3,255',
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 466, 440, 466, 440, false),
|
||||||
|
$this->pictureRules('picture_productsheet', 680, 300, 680, 300, false),
|
||||||
|
$this->pictureRules('picture_thumbnail', 246, 337, 246, 337, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'seo_title' => trans('validation.custom.seo_title'),
|
||||||
|
'seo_description' => trans('validation.custom.seo_description'),
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'subtitle' => trans('validation.custom.subtitle'),
|
||||||
|
'tagline' => trans('validation.custom.tagline'),
|
||||||
|
'description' => trans('validation.custom.description'),
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title'),
|
||||||
|
'picture_productsheet_alt' => trans('validation.custom.picture_productsheet_alt'),
|
||||||
|
'picture_productsheet_title' => trans('validation.custom.picture_productsheet_title'),
|
||||||
|
'picture_thumbnail_alt' => trans('validation.custom.picture_thumbnail_alt'),
|
||||||
|
'picture_thumbnail_title' => trans('validation.custom.picture_thumbnail_title'),
|
||||||
|
'published' => trans('validation.custom.activated'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php
Normal file
7
app/Http/Requests/Bo/Ranges/UpdateRangeRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Ranges;
|
||||||
|
|
||||||
|
class UpdateRangeRequest extends StoreRangeRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\SeasonalSections;
|
||||||
|
|
||||||
|
use App\Enums\SeasonalSections\BackgroundEnum;
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class StoreSeasonalSectionRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'title' => 'required|string|between:3,100',
|
||||||
|
'text' => 'required|string|min:15',
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'background' => ['required', new Enum(BackgroundEnum::class)],
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
'publish_at' => 'nullable|date',
|
||||||
|
'unpublish_at' => 'nullable|date|after:publish_at',
|
||||||
|
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 362, 542, 362, 542, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'text' => trans('validation.attributes.content'),
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title'),
|
||||||
|
'background' => trans('validation.custom.background'),
|
||||||
|
'published' => trans('validation.custom.activated'),
|
||||||
|
'publish_at' => trans('validation.custom.publish_at'),
|
||||||
|
'unpublish_at' => trans('validation.custom.unpublish_at'),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\SeasonalSections;
|
||||||
|
|
||||||
|
class UpdateSeasonalSectionRequest extends StoreSeasonalSectionRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
66
app/Http/Requests/Bo/Stamps/StoreStampRequest.php
Normal file
66
app/Http/Requests/Bo/Stamps/StoreStampRequest.php
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Stamps;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreStampRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->published ? true : false
|
||||||
|
]);
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 120, 120, 120, 120, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt'),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title'),
|
||||||
|
'published' => trans('validation.custom.activated'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
7
app/Http/Requests/Bo/Stamps/UpdateStampRequest.php
Normal file
7
app/Http/Requests/Bo/Stamps/UpdateStampRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Stamps;
|
||||||
|
|
||||||
|
class UpdateStampRequest extends StoreStampRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
74
app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php
Normal file
74
app/Http/Requests/Bo/StaticPages/UpdateStaticPageRequest.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\StaticPages;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class UpdateStaticPageRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
/** @var \App\Models\StaticPage $staticPageModel */
|
||||||
|
$staticPageModel = $this->route('static_page');
|
||||||
|
if (
|
||||||
|
\in_array($staticPageModel->type, [
|
||||||
|
\App\Enums\StaticPageType::confidentiality,
|
||||||
|
\App\Enums\StaticPageType::legals
|
||||||
|
])
|
||||||
|
) {
|
||||||
|
$this->merge([
|
||||||
|
'content' => (string)Str::of($this->post('content'))
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->merge([
|
||||||
|
'content' => ''
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'seo_title' => 'required|min:45|max:70',
|
||||||
|
'seo_description' => 'required|min:50|max:160',
|
||||||
|
'title' => 'required|min:3|max:255',
|
||||||
|
'content' => 'present',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'seo_title' => trans('validation.custom.seo_title'),
|
||||||
|
'seo_description' => trans('validation.custom.seo_description'),
|
||||||
|
'title' => trans('validation.attributes.title'),
|
||||||
|
'content' => trans('validation.attributes.content'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Testimonials;
|
||||||
|
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class StoreTestimonialRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth('backend')->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->mergePicture('picture');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [
|
||||||
|
'picture_alt' => 'required|string|between:3,255',
|
||||||
|
'picture_title' => 'required|string|between:3,255',
|
||||||
|
'description' => 'required|string|between:3,255',
|
||||||
|
'job' => 'required|string|between:3,255',
|
||||||
|
'statut' => 'required|string|between:3,255',
|
||||||
|
];
|
||||||
|
return \array_merge(
|
||||||
|
$rules,
|
||||||
|
$this->pictureRules('picture', 292, 417, 292, 417, false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'picture_alt' => trans('validation.custom.picture_alt', ['field' => __('validation.custom.picture')]),
|
||||||
|
'picture_title' => trans('validation.custom.picture_title', ['field' => __('validation.custom.picture')]),
|
||||||
|
'description' => trans('validation.attributes.description'),
|
||||||
|
'job' => trans('validation.custom.job'),
|
||||||
|
'statut' => trans('validation.custom.statut'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Testimonials;
|
||||||
|
|
||||||
|
class UpdateTestimonialRequest extends StoreTestimonialRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
54
app/Http/Requests/Bo/UpdateChangeOrderRequest.php
Normal file
54
app/Http/Requests/Bo/UpdateChangeOrderRequest.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateChangeOrderRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth()->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'direction' => $this->direction === 'up' ? true : false
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'direction' => 'required|boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'direction' => trans('validation.custom.direction'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
66
app/Http/Requests/Bo/Users/StoreUserRequest.php
Normal file
66
app/Http/Requests/Bo/Users/StoreUserRequest.php
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Users;
|
||||||
|
|
||||||
|
use App\Enums\Users\RoleEnum;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class StoreUserRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Gate::check('create', User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->boolean('published')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => 'required|string|min:3|max:255',
|
||||||
|
'last_name' => 'required|string|min:3|max:255',
|
||||||
|
'email' => 'required|email:rfc,strict,dns,spoof,filter|unique:users,email',
|
||||||
|
'role' => ['required', new Enum(RoleEnum::class)],
|
||||||
|
'published' => 'required|boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => trans('validation.attributes.first_name'),
|
||||||
|
'last_name' => trans('validation.attributes.last_name'),
|
||||||
|
'email' => trans('validation.attributes.email'),
|
||||||
|
'role' => trans('validation.attributes.role'),
|
||||||
|
'published' => trans('validation.custom.publication')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Http/Requests/Bo/Users/UpdateUserRequest.php
Normal file
47
app/Http/Requests/Bo/Users/UpdateUserRequest.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Users;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class UpdateUserRequest extends StoreUserRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Gate::check('update', $this->route('user'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->boolean('published'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return array_merge(parent::rules(), [
|
||||||
|
'email' => [
|
||||||
|
'required',
|
||||||
|
'email:rfc,strict,dns,spoof,filter',
|
||||||
|
Rule::unique('users', 'email')->ignore(\optional($this->route('user'))->getRouteKey())
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
208
app/Http/Requests/Fo/ContactRequest.php
Normal file
208
app/Http/Requests/Fo/ContactRequest.php
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Fo;
|
||||||
|
|
||||||
|
use App\Enums\Contact\CivilityEnum;
|
||||||
|
use App\Enums\Contact\ObjectEnum;
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use App\Traits\Requests\HasPicture;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class ContactRequest extends FormRequest
|
||||||
|
{
|
||||||
|
use HasPicture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation()
|
||||||
|
{
|
||||||
|
$this->mergePicture('file');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||||
|
|
||||||
|
$rules = [
|
||||||
|
'civility' => ['sometimes', 'nullable', new Enum(CivilityEnum::class)],
|
||||||
|
'last_name' => 'sometimes|nullable|string|between:3,255',
|
||||||
|
'first_name' => 'sometimes|nullable|string|between:3,255',
|
||||||
|
'society' => 'sometimes|nullable|string|between:3,255',
|
||||||
|
'email' => 'required|email:rfc,strict,dns,spoof,filter|max:255',
|
||||||
|
'phone' => 'sometimes|nullable|numeric|min:0',
|
||||||
|
'address' => 'required|string|between:3,255',
|
||||||
|
'postal_code' => 'required|numeric|min:0',
|
||||||
|
'city' => 'required|string|between:3,255',
|
||||||
|
'object' => ['required', new Enum(ObjectEnum::class)],
|
||||||
|
'message' => 'required|string|between:3,500',
|
||||||
|
];
|
||||||
|
if ($this->object === strval(ObjectEnum::customerService->value())) {
|
||||||
|
$rules = \array_merge($rules, [
|
||||||
|
'product_name' => [
|
||||||
|
'string',
|
||||||
|
'between:3,255',
|
||||||
|
'required',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_name'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'product_date_limit' => [
|
||||||
|
'required',
|
||||||
|
'date',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_date_limit'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'product_barcode' => [
|
||||||
|
'numeric',
|
||||||
|
'min:0',
|
||||||
|
'required',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_barcode'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'product_lot' => [
|
||||||
|
'numeric',
|
||||||
|
'min:0',
|
||||||
|
'required',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_lot'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'product_date_consumption' => [
|
||||||
|
'required',
|
||||||
|
'date',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_date_consumption'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'product_location' => [
|
||||||
|
'string',
|
||||||
|
'between:3,255',
|
||||||
|
'required',
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->get("object") != ObjectEnum::customerService->value()) {
|
||||||
|
$fail(\trans('le Champs :field doit être vide lorsque le champs objet
|
||||||
|
n\'est pas égale à :enumValue.', [
|
||||||
|
'field' => trans('validation.custom.product_location'),
|
||||||
|
'enumValue' => ObjectEnum::customerService->label(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} //end if
|
||||||
|
if (
|
||||||
|
isset(request()->file) and
|
||||||
|
(request()->file->getClientMimeType() === "image/jpeg" ||
|
||||||
|
request()->file->getClientMimeType() === "image/png")
|
||||||
|
) {
|
||||||
|
$rules = \array_merge($rules, $this->pictureRules(
|
||||||
|
'file',
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1920,
|
||||||
|
1080,
|
||||||
|
true,
|
||||||
|
3000,
|
||||||
|
'product_name,product_date_limit,product_barcode,product_lot,product_date_consumption,product_location'
|
||||||
|
));
|
||||||
|
} elseif (isset(request()->file) and (request()->file->getClientMimeType() === "application/pdf")) {
|
||||||
|
$rules = \array_merge($rules, [
|
||||||
|
//phpcs:ignore Generic.Files.LineLength.TooLong
|
||||||
|
'file' => 'sometimes|nullable|mimes:pdf|required_with:product_name,product_date_limit,product_barcode,product_lot,product_date_consumption,product_location'
|
||||||
|
]);
|
||||||
|
} elseif (
|
||||||
|
isset(request()->file) and
|
||||||
|
(request()->file->getClientMimeType() !== "application/pdf") and
|
||||||
|
(request()->file->getClientMimeType() !== "image/jpeg") and
|
||||||
|
(request()->file->getClientMimeType() !== "image/png")
|
||||||
|
) {
|
||||||
|
$rules = \array_merge($rules, [
|
||||||
|
'file' => [
|
||||||
|
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
$fail(\trans('Le format du fichier doit être .jpg, .png ou .pdf'));
|
||||||
|
}
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} //end if
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'civility' => trans('validation.custom.civility'),
|
||||||
|
'first_name' => trans('validation.attributes.first_name'),
|
||||||
|
'last_name' => trans('validation.attributes.last_name'),
|
||||||
|
'society' => trans('validation.custom.society'),
|
||||||
|
'email' => trans('validation.attributes.email'),
|
||||||
|
'phone' => trans('validation.attributes.phone'),
|
||||||
|
'address' => trans('validation.attributes.address'),
|
||||||
|
'postal_code' => trans('validation.attributes.postal_code'),
|
||||||
|
'city' => trans('validation.attributes.city'),
|
||||||
|
'object' => trans('validation.custom.object'),
|
||||||
|
'product_name' => trans('validation.custom.product_name'),
|
||||||
|
'product_date_limit' => trans('validation.custom.product_date_limit'),
|
||||||
|
'product_barcode' => trans('validation.custom.product_barcode'),
|
||||||
|
'product_lot' => trans('validation.custom.product_lot'),
|
||||||
|
'product_date_consumption' => trans('validation.custom.product_date_consumption'),
|
||||||
|
'product_location' => trans('validation.custom.product_location'),
|
||||||
|
'message' => trans('validation.attributes.message'),
|
||||||
|
'file' => trans('validation.custom.file'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Http/Requests/Fo/JoinusRequest.php
Normal file
49
app/Http/Requests/Fo/JoinusRequest.php
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Fo;
|
||||||
|
|
||||||
|
use App\Enums\DesiredLocation;
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Validation\Rules\Enum;
|
||||||
|
|
||||||
|
class JoinusRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'last_name' => 'required|string|between:3,255',
|
||||||
|
'first_name' => 'required|string|between:3,255',
|
||||||
|
'email' => 'required|email:rfc,strict,dns,spoof,filter|max:255',
|
||||||
|
'phone' => 'required|numeric|min:0',
|
||||||
|
'desired_location' => ['required', new Enum(DesiredLocation::class)],
|
||||||
|
'message' => 'required|string|between:3,500',
|
||||||
|
"file" => "sometimes|nullable|mimes:pdf|max:10000"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get custom attributes for validator errors.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'first_name' => trans('validation.attributes.first_name'),
|
||||||
|
'last_name' => trans('validation.attributes.last_name'),
|
||||||
|
'email' => trans('validation.attributes.email'),
|
||||||
|
'phone' => trans('validation.attributes.phone'),
|
||||||
|
'desired_location' => trans('validation.custom.desired_location'),
|
||||||
|
'message' => trans('validation.attributes.message'),
|
||||||
|
'file' => trans('validation.attributes.file'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Jobs/NewsStatusUpdate.php
Normal file
46
app/Jobs/NewsStatusUpdate.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\News;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update published attribute reading its
|
||||||
|
* publish_at and unpublish_at attributes.
|
||||||
|
*/
|
||||||
|
class NewsStatusUpdate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Called when the job will be executed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||||
|
$newsListToPublish = News::query()
|
||||||
|
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||||
|
->whereNotNull('publish_at')
|
||||||
|
->where('published', false)->get();
|
||||||
|
Log::debug(__CLASS__ . " news to publish " . $newsListToPublish->count());
|
||||||
|
foreach ($newsListToPublish as $news) {
|
||||||
|
$news->publish_at = null;
|
||||||
|
$news->published = true;
|
||||||
|
$news->saveOrFail();
|
||||||
|
}
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\News> */
|
||||||
|
$newsListToUnPublish = News::query()
|
||||||
|
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||||
|
->whereNotNull('unpublish_at')
|
||||||
|
->where('published', true)->get();
|
||||||
|
Log::debug(__CLASS__ . " news to unpublish " . $newsListToPublish->count());
|
||||||
|
foreach ($newsListToUnPublish as $news) {
|
||||||
|
$news->publish_at = null;
|
||||||
|
$news->unpublish_at = null;
|
||||||
|
$news->published = false;
|
||||||
|
$news->saveOrFail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Jobs/SeasonalSectionStatusUpdate.php
Normal file
46
app/Jobs/SeasonalSectionStatusUpdate.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\SeasonalSection;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update published attribute reading its
|
||||||
|
* publish_at and unpublish_at attributes.
|
||||||
|
*/
|
||||||
|
class SeasonalSectionStatusUpdate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Called when the job will be executed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\SeasonalSection> */
|
||||||
|
$seasonalsectionsListToPublish = SeasonalSection::query()
|
||||||
|
->where('publish_at', '<=', Carbon::now()->toDateTime())
|
||||||
|
->whereNotNull('publish_at')
|
||||||
|
->where('published', false)->get();
|
||||||
|
Log::debug(__CLASS__ . " seasonalsections to publish " . $seasonalsectionsListToPublish->count());
|
||||||
|
foreach ($seasonalsectionsListToPublish as $seasonalsections) {
|
||||||
|
$seasonalsections->publish_at = null;
|
||||||
|
$seasonalsections->published = true;
|
||||||
|
$seasonalsections->saveOrFail();
|
||||||
|
}
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \App\Models\SeasonalSection> */
|
||||||
|
$seasonalsectionsListToUnPublish = SeasonalSection::query()
|
||||||
|
->where('unpublish_at', '<=', Carbon::now()->toDateTime())
|
||||||
|
->whereNotNull('unpublish_at')
|
||||||
|
->where('published', true)->get();
|
||||||
|
Log::debug(__CLASS__ . " seasonalsections to unpublish " . $seasonalsectionsListToPublish->count());
|
||||||
|
foreach ($seasonalsectionsListToUnPublish as $seasonalsections) {
|
||||||
|
$seasonalsections->publish_at = null;
|
||||||
|
$seasonalsections->unpublish_at = null;
|
||||||
|
$seasonalsections->published = false;
|
||||||
|
$seasonalsections->saveOrFail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/Lib/Helpers/CollectionHelper.php
Normal file
64
app/Lib/Helpers/CollectionHelper.php
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Lib\Helpers;
|
||||||
|
|
||||||
|
use Illuminate\Container\Container;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use Illuminate\Pagination\Paginator;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
class CollectionHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Paginate a collection
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Support\Collection $results
|
||||||
|
* @param integer $pageSize
|
||||||
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator
|
||||||
|
{
|
||||||
|
$page = Paginator::resolveCurrentPage('page');
|
||||||
|
|
||||||
|
return self::paginateManually($results, $pageSize, $page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paginate a collection
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Support\Collection $results
|
||||||
|
* @param integer $pageSize
|
||||||
|
* @param integer $page
|
||||||
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator
|
||||||
|
{
|
||||||
|
$total = $results->count();
|
||||||
|
|
||||||
|
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
|
||||||
|
'path' => Paginator::resolveCurrentPath(),
|
||||||
|
'pageName' => 'page',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new length-aware paginator instance.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Support\Collection $items
|
||||||
|
* @param integer $total
|
||||||
|
* @param integer $perPage
|
||||||
|
* @param integer $currentPage
|
||||||
|
* @param array $options
|
||||||
|
* @return \Illuminate\Pagination\LengthAwarePaginator
|
||||||
|
*/
|
||||||
|
protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
|
||||||
|
{
|
||||||
|
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
|
||||||
|
'items' => $items,
|
||||||
|
'total' => $total,
|
||||||
|
'perPage' => $perPage,
|
||||||
|
'currentPage' => $currentPage,
|
||||||
|
'options' => $options
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
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(strtolower($param)))[0] ?? null;
|
||||||
|
}
|
||||||
|
switch (true) {
|
||||||
|
case $type === 'lambda':
|
||||||
|
case $type === 'object':
|
||||||
|
continue 2;
|
||||||
|
case $type === 'array' and \is_array($param):
|
||||||
|
$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";
|
||||||
|
} else {
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue