Compare commits

..

No commits in common. "migration/php-8.5" and "add-CICD-files" have entirely different histories.

159 changed files with 6894 additions and 8164 deletions

View file

@ -17,7 +17,7 @@ DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
@ -33,19 +33,15 @@ MAIL_FROM_NAME="${APP_NAME}"
MAIL_LIST_CONTACTFORM=
# Matomo
MATOMO_SITE_ID=
ANALYTICS_GOOGLE_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=""
## LDCWEB ADMIN SECURE
LDC_WEB_API_KEY=
# Sentry
SENTRY_LARAVEL_DSN=

4
.gitignore vendored
View file

@ -1,8 +1,7 @@
/node_modules
/public/hot
/public/storage
/public/
!/public/sitemap.xml
/public
/storage/*.key
/vendor
.env
@ -15,4 +14,3 @@ npm-debug.log
yarn-error.log
/.idea
auth.json
.npmrc

View file

@ -1,24 +1,23 @@
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/build.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'test/test.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'deploy/deploy.yml'
- project: "ldc-web/shared-ci"
ref: "main"
file: "lint/lint7.3.yml"
- project: "ldc-web/shared-ci"
ref: "main"
file: "security/security7.3.yml"
- project: "ldc-web/shared-ci"
ref: "main"
file: "build/build7.3.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
- lint
- security
- build
- test
- deploy

15
.vscode/settings.json vendored
View file

@ -1,7 +1,7 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#e2bd2b",
"activityBar.activeBorder": "#15202b",
"activityBar.activeBorder": "#222f5c",
"activityBar.background": "#e2bd2b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
@ -11,22 +11,13 @@
"statusBar.background": "#c19f1a",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#947a14",
"statusBarItem.remoteBackground": "#abf4e5",
"statusBarItem.remoteBackground": "#c19f1a",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#c19f1a",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#c19f1a99",
"titleBar.inactiveForeground": "#15202b99",
"commandCenter.border": "#15202b99",
"activityBarTop.activeBackground": "#e2bd2b",
"activityBarTop.activeBorder": "#15202b",
"activityBarTop.background": "#e2bd2b",
"activityBarTop.foreground": "#15202b",
"activityBarTop.inactiveForeground": "#15202b99",
"commandCenter.foreground": "#15202b",
"statusBar.debuggingBackground": "#c19f1a",
"statusBar.debuggingForeground": "#15202b",
"statusBar.inactiveBackground": "#c19f1a"
"commandCenter.border": "#15202b99"
},
"peacock.remoteColor": "#c19f1a"
}

View file

@ -1,5 +1,4 @@
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}
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/ldcweb-production-7.3:latest
COPY --chown=www-data:www-data . /app/srcs
USER root
RUN chmod -R 755 /app/srcs/storage

View file

@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
class AdminCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create Admin User';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$role = 0;
$name = $this->ask('Name ?');
$email = $this->ask('Email ?');
$password = $this->secret('What is the password?');
$user = new User([
'name' => $name,
'email' => $email,
'role' => $role,
'password' => Hash::make($password)
]);
$user->saveOrFail();
$this->info('Admin created.');
return 0;
}
}

View file

@ -1,49 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class UserCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
#[\Override]
protected $signature = 'user:create';
/**
* The console command description.
*
* @var string
*/
#[\Override]
protected $description = 'Create a backend user';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$name = $this->ask('What is the name?');
$email = $this->ask('What is the email?');
$role = $this->ask('What is the role 1 (SuperAdmin) or 2 (Admin) ?') == '1' ? 1 : 2;
$pwd = $this->secret('What is the password?');
$user = new User();
$user->name = $name;
$user->email = $email;
$user->role = $role;
$user->password = Hash::make($pwd);
$user->saveOrFail();
$this->info('User created.');
return 0;
}
}

View file

@ -12,7 +12,8 @@ class Kernel extends ConsoleKernel
*
* @var array
*/
protected $commands = [];
protected $commands = [
];
/**
* Define the application's command schedule.
@ -22,10 +23,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
// * FIXME: remove this when swithing to latest php version and ldc-web-admin-secure-laravel package
if ($this->app->environment('staging')) {
$schedule->command('ldcweb:admin-secure-sync')->daily();
}
// Write schedules here.
}
/**

View file

@ -31,7 +31,6 @@ class Handler extends ExceptionHandler
*
* @var array
*/
#[\Override]
protected $dontReport = [];
/**
@ -39,7 +38,6 @@ class Handler extends ExceptionHandler
*
* @var array
*/
#[\Override]
protected $dontFlash = [
'current_password',
'password',
@ -52,9 +50,9 @@ class Handler extends ExceptionHandler
*/
public function register()
{
$this->reportable(function (\Throwable $e): void {
$this->reportable(function (\Throwable $e) {
if (app()->bound('sentry')) {
resolve('sentry')->captureException($e);
app('sentry')->captureException($e);
}
});
}

View file

@ -43,11 +43,11 @@ class AdviceController extends Controller
}
if (!$advice->saveOrFail()) {
return to_route('bo.advice.edit', $advice->id)
return redirect()->route('bo.advice.edit', $advice->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.advice.edit', $advice->id)
return redirect()->route('bo.advice.edit', $advice->id)
->with('success', trans('Modifications enregistrées !'));
}
}

View file

@ -37,11 +37,11 @@ class EncartsController extends Controller
}
if (!$encart->saveOrFail()) {
return to_route('bo.encarts.edit', $encart->id)
return redirect()->route('bo.encarts.edit', $encart->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.encarts.edit', $encart->id)
return redirect()->route('bo.encarts.edit', $encart->id)
->with('success', trans('Modifications enregistrées !'));
}
}

View file

@ -25,7 +25,7 @@ class GammesController extends Controller
foreach ($dbGammes as $gamme) {
$gammes->push($gamme);
$gamme->childGammes->sortBy('title')
->map(function (Gamme $childGamme) use (&$gammes): void {
->map(function (Gamme $childGamme) use (&$gammes) {
$gammes->push($childGamme);
});
}
@ -69,9 +69,9 @@ class GammesController extends Controller
}
if (!$gamme->saveOrFail()) {
return to_route('bo.gammes.edit', $gamme->id)->with('error', 'L\'actualité n\'a pas été créee');
return redirect()->route('bo.gammes.edit', $gamme->id)->with('error', 'L\'actualité n\'a pas été créee');
}
return to_route('bo.gammes.edit', $gamme->id)->with('success', 'Gamme créée !');
return redirect()->route('bo.gammes.edit', $gamme->id)->with('success', 'Gamme créée !');
}
/**
@ -111,11 +111,11 @@ class GammesController extends Controller
}
if (!$gamme->saveOrFail()) {
return to_route('bo.gammes.edit', $gamme->id)
return redirect()->route('bo.gammes.edit', $gamme->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.gammes.edit', $gamme->id)
return redirect()->route('bo.gammes.edit', $gamme->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -128,9 +128,9 @@ class GammesController extends Controller
public function destroy(Gamme $gamme)
{
if (!$gamme->delete()) {
return to_route('bo.gammes.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.gammes.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.gammes.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.gammes.index')->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -49,11 +49,11 @@ class MomentsController extends Controller
}
if (!$moment->saveOrFail()) {
return to_route('bo.moments.edit', $moment->id)
return redirect()->route('bo.moments.edit', $moment->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.moments.edit', $moment->id)
return redirect()->route('bo.moments.edit', $moment->id)
->with('success', trans('Modifications enregistrées !'));
}
}

View file

@ -49,10 +49,10 @@ class PictoBrandsController extends Controller
}
if (!$pictobrand->saveOrFail()) {
return to_route('bo.pictobrands.edit', $pictobrand->id)
return redirect()->route('bo.pictobrands.edit', $pictobrand->id)
->with('error', 'Le pictogramme n\'a pas été crée');
}
return to_route('bo.pictobrands.edit', $pictobrand->id)
return redirect()->route('bo.pictobrands.edit', $pictobrand->id)
->with('success', 'Pictogramme créé !');
}
@ -84,11 +84,11 @@ class PictoBrandsController extends Controller
}
if (!$pictobrand->saveOrFail()) {
return to_route('bo.pictobrands.edit', $pictobrand->id)
return redirect()->route('bo.pictobrands.edit', $pictobrand->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.pictobrands.edit', $pictobrand->id)
return redirect()->route('bo.pictobrands.edit', $pictobrand->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -101,9 +101,9 @@ class PictoBrandsController extends Controller
public function destroy(PictoBrand $pictobrand)
{
if (!$pictobrand->delete()) {
return to_route('bo.pictobrands.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.pictobrands.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.pictobrands.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.pictobrands.index')->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -55,9 +55,9 @@ class PictosController extends Controller
$picto->page = Page::marqueBloc2();
if (!$picto->saveOrFail()) {
return to_route('bo.pictos.edit', $picto->id)->with('error', 'Le pictogramme n\'a pas été crée');
return redirect()->route('bo.pictos.edit', $picto->id)->with('error', 'Le pictogramme n\'a pas été crée');
}
return to_route('bo.pictos.edit', $picto->id)->with('success', 'Pictogramme créé !');
return redirect()->route('bo.pictos.edit', $picto->id)->with('success', 'Pictogramme créé !');
}
/**
@ -88,11 +88,11 @@ class PictosController extends Controller
}
if (!$picto->saveOrFail()) {
return to_route('bo.pictos.edit', $picto->id)
return redirect()->route('bo.pictos.edit', $picto->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.pictos.edit', $picto->id)
return redirect()->route('bo.pictos.edit', $picto->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -105,11 +105,11 @@ class PictosController extends Controller
public function destroy(Picto $picto)
{
if (!$picto->delete()) {
return to_route('bo.pictos.content', $picto->page)
return redirect()->route('bo.pictos.content', $picto->page)
->with('error', trans('La suppression a échoué'));
}
return to_route('bo.pictos.content', $picto->page)
return redirect()->route('bo.pictos.content', $picto->page)
->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -55,9 +55,9 @@ class PostsController extends Controller
$response = $post->saveOrFail();
}
if (!$response) {
return to_route('bo.posts.edit', $post->id)->with('error', 'L\'actualité n\'a pas été créee');
return redirect()->route('bo.posts.edit', $post->id)->with('error', 'L\'actualité n\'a pas été créee');
}
return to_route('bo.posts.edit', $post->id)->with('success', 'Actualité créée !');
return redirect()->route('bo.posts.edit', $post->id)->with('success', 'Actualité créée !');
}
/**
@ -95,11 +95,11 @@ class PostsController extends Controller
$response = $post->saveOrFail();
}
if (!$response) {
return to_route('bo.posts.edit', $post->id)
return redirect()->route('bo.posts.edit', $post->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.posts.edit', $post->id)
return redirect()->route('bo.posts.edit', $post->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -112,10 +112,10 @@ class PostsController extends Controller
public function destroy(Post $post)
{
if (!$post->delete()) {
return to_route('bo.posts.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.posts.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.posts.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.posts.index')->with('success', trans('Suppression faite avec succès'));
}
/**

View file

@ -36,93 +36,93 @@ class ProductsController extends Controller
{
$gammes = Gamme::all()->sortBy('title');
// Default structure + produits.
$tabFour = [
$tabFour = array(
'id' => 0,
'name' => 'Four',
'url' => '/assets/images/four.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabFriteuse = [
);
$tabFriteuse = array(
'id' => 1,
'name' => 'Friteuse',
'url' => '/assets/images/friteuse.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabPoele = [
);
$tabPoele = array(
'id' => 2,
'name' => 'Poêle',
'url' => '/assets/images/poele.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabCocotte = [
);
$tabCocotte = array(
'id' => 3,
'name' => 'Cocotte',
'url' => '/assets/images/cocotte.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabPlancha = [
);
$tabPlancha = array(
'id' => 4,
'name' => 'Plancha',
'url' => '/assets/images/plancha.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabBainMarie = [
);
$tabBainMarie = array(
'id' => 5,
'name' => 'Bain Marie',
'url' => '/assets/images/bainmarie.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabBarbecue = [
);
$tabBarbecue = array(
'id' => 6,
'name' => 'Barbecue',
'url' => '/assets/images/barbecue.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabMicroOndes = [
);
$tabMicroOndes = array(
'id' => 7,
'name' => 'Micro Ondes',
'url' => '/assets/images/microondes.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabCasserole = [
);
$tabCasserole = array(
'id' => 8,
'name' => 'Casserole',
'url' => '/assets/images/casserole.png',
'time' => '',
'temp' => '',
'status' => false
];
$tabPlusProduit1 = [
);
$tabPlusProduit1 = array(
'id' => 0,
'name' => '',
'url' => '',
];
$tabPlusProduit2 = [
);
$tabPlusProduit2 = array(
'id' => 1,
'name' => '',
'url' => '',
];
$tabPlusProduit3 = [
);
$tabPlusProduit3 = array(
'id' => 2,
'name' => '',
'url' => '',
];
);
//phpcs:ignore Generic.Files.LineLength.TooLong
$product->pictos = json_encode([$tabFour, $tabFriteuse, $tabPoele, $tabCocotte, $tabPlancha, $tabBainMarie, $tabBarbecue, $tabMicroOndes, $tabCasserole]);
$product->plusproduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]);
@ -153,9 +153,12 @@ class ProductsController extends Controller
$product->plusproduit = json_encode($plusproduit);
if (!$product->saveOrFail()) {
return to_route('bo.products.edit', $product->id)->with('error', 'Le produit n\'a pas été crée');
return redirect()->route(
'bo.products.edit',
$product->id
)->with('error', 'Le produit n\'a pas été crée');
}
return to_route('bo.products.edit', $product->id)->with('success', 'Produit créé !');
return redirect()->route('bo.products.edit', $product->id)->with('success', 'Produit créé !');
}
/**
@ -207,11 +210,11 @@ class ProductsController extends Controller
// Encodage avant save.
$product->plusproduit = json_encode($plusproduit);
if (!$product->saveOrFail()) {
return to_route('bo.products.edit', $product->id)
return redirect()->route('bo.products.edit', $product->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.products.edit', $product->id)
return redirect()->route('bo.products.edit', $product->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -224,9 +227,9 @@ class ProductsController extends Controller
public function destroy(Product $product)
{
if (!$product->delete()) {
return to_route('bo.products.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.products.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.products.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.products.index')->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -33,7 +33,7 @@ class SeoDataController extends Controller
$SeoDatum->fill($request->validated());
$SeoDatum->save();
return to_route('bo.seo_data.edit', $SeoDatum->page)
return redirect()->route('bo.seo_data.edit', $SeoDatum->page)
->with('success', trans('Modifications enregistrées !'));
}
}

View file

@ -45,9 +45,9 @@ class SlidersController extends Controller
$slider = new Slider($request->validated());
if (!$slider->saveOrFail()) {
return to_route('bo.sliders.edit', $slider->id)->with('error', 'Le slider n\'a pas été crée');
return redirect()->route('bo.sliders.edit', $slider->id)->with('error', 'Le slider n\'a pas été crée');
}
return to_route('bo.sliders.edit', $slider->id)->with('success', 'Slider créé !');
return redirect()->route('bo.sliders.edit', $slider->id)->with('success', 'Slider créé !');
}
/**
@ -75,10 +75,10 @@ class SlidersController extends Controller
$slider->fill($request->validated());
if (!$slider->saveOrFail()) {
return to_route('bo.sliders.edit', $slider->id)->with('error', 'La modification a échoué');
return redirect()->route('bo.sliders.edit', $slider->id)->with('error', 'La modification a échoué');
}
return to_route('bo.sliders.edit', $slider->id)->with('success', 'Modifications enregistrées !');
return redirect()->route('bo.sliders.edit', $slider->id)->with('success', 'Modifications enregistrées !');
}
/**
@ -92,12 +92,12 @@ class SlidersController extends Controller
$count = Slider::count();
if ($count === 1) {
return back()->withErrors("Suppression impossible : Vous devez conserver au moins 1 Slider");
return redirect()->back()->withErrors("Suppression impossible : Vous devez conserver au moins 1 Slider");
}
if (!$slider->delete()) {
return to_route('bo.sliders.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.sliders.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.sliders.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.sliders.index')->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -52,7 +52,7 @@ class SlidesController extends Controller
$slide->saveOrFail();
return to_route('bo.slides.edit', $slide->id)->with('success', 'Slide créé !');
return redirect()->route('bo.slides.edit', $slide->id)->with('success', 'Slide créé !');
}
/**
@ -84,10 +84,10 @@ class SlidesController extends Controller
}
if (!$slide->saveOrFail()) {
return to_route('bo.slides.edit', $slide->id)->with('error', trans('La modification a échoué'));
return redirect()->route('bo.slides.edit', $slide->id)->with('error', trans('La modification a échoué'));
}
return to_route('bo.slides.edit', $slide->id)->with('success', trans('Modifications enregistrées !'));
return redirect()->route('bo.slides.edit', $slide->id)->with('success', trans('Modifications enregistrées !'));
}
/**
@ -99,10 +99,10 @@ class SlidesController extends Controller
public function destroy(Slide $slide)
{
if (!$slide->delete()) {
return to_route('bo.slides.index')->with('error', trans('La suppression a échoué'));
return redirect()->route('bo.slides.index')->with('error', trans('La suppression a échoué'));
}
return to_route('bo.slides.index')->with('success', trans('Suppression faite avec succès'));
return redirect()->route('bo.slides.index')->with('success', trans('Suppression faite avec succès'));
}
/**

View file

@ -46,10 +46,12 @@ class TextsController extends Controller
$text->page = Page::newsQuestions();
if (!$text->saveOrFail()) {
return to_route('bo.texts.edit', $text->id)
return redirect()
->route('bo.texts.edit', $text->id)
->with('error', 'La question/réponse n\'a pas été créée');
}
return to_route('bo.texts.edit', $text->id)
return redirect()
->route('bo.texts.edit', $text->id)
->with('success', 'Question/réponse créée !');
}
@ -78,11 +80,11 @@ class TextsController extends Controller
$text->fill($request->validated());
if (!$text->saveOrFail()) {
return to_route('bo.texts.edit', $text->id)
return redirect()->route('bo.texts.edit', $text->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.texts.edit', $text->id)
return redirect()->route('bo.texts.edit', $text->id)
->with('success', trans('Modifications enregistrées !'));
}
@ -95,11 +97,11 @@ class TextsController extends Controller
public function destroy(Text $text)
{
if (!$text->delete()) {
return to_route('bo.texts.content', $text->page)
return redirect()->route('bo.texts.content', $text->page)
->with('error', trans('La suppression a échoué'));
}
return to_route('bo.texts.content', $text->page)
return redirect()->route('bo.texts.content', $text->page)
->with('success', trans('Suppression faite avec succès'));
}
}

View file

@ -33,11 +33,11 @@ class TitlesController extends Controller
$title->fill($request->validated());
if (!$title->saveOrFail()) {
return to_route('bo.titles.edit', $title->id)
return redirect()->route('bo.titles.edit', $title->id)
->with('error', trans('La modification a échoué'));
}
return to_route('bo.titles.edit', $title->id)
return redirect()->route('bo.titles.edit', $title->id)
->with('success', trans('Modifications enregistrées !'));
}
}

View file

@ -18,9 +18,13 @@ class ContactController extends Controller
*/
public function contact()
{
$listCountries = Cache::remember('listCountries', 86400, fn() => Country::toArray());
$listCountries = Cache::remember('listCountries', 86400, function () {
return Country::toArray();
});
$listDeps = Cache::remember('listDeps', 86400, fn() => Department::toArray());
$listDeps = Cache::remember('listDeps', 86400, function () {
return Department::toArray();
});
return view('front.contact', compact('listCountries', 'listDeps'));
}
@ -43,7 +47,7 @@ class ContactController extends Controller
Mail::to(config('mail.contactsList.contactform'))->send(new SendContactMail($data->all()));
$lang = session()->get('lang', config('app.locale'));
return to_route(session()->get('lang', config('app.locale')) === 'fr' ? 'contact' : $lang . ".contact")
->with('status', true);
return redirect()->route(session()->get('lang', config('app.locale')) === 'fr' ? 'contact' : $lang . ".contact")
->with('status', true);
}
}

View file

@ -45,7 +45,7 @@ class GammesController extends Controller
foreach ($dbGammes as $dbGamme) {
$gammes->push($dbGamme->id);
$dbGamme->childGammes->sortBy('title')
->map(function (Gamme $childGamme) use (&$gammes): void {
->map(function (Gamme $childGamme) use (&$gammes) {
$gammes->push($childGamme->id);
});
}

View file

@ -26,15 +26,15 @@ class HomeController extends Controller
$slider = Slider::where('published', 1)->first();
if ($slider) {
$slides = Slide::whereHas('slider', function (\Illuminate\Contracts\Database\Query\Builder $q) use ($slider): void {
$slides = Slide::whereHas('slider', function ($q) use ($slider) {
$q->whereId($slider->id);
})->where(function ($q): void {
})->where(function ($q) {
$q->where(
function ($q): void {
$q->where('date_start', '<=', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s'))
->where('date_end', '>', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s'));
function ($q) {
$q->where('date_start', '<=', Carbon::now()->format('Y-m-d H:i:s'))
->where('date_end', '>', Carbon::now()->format('Y-m-d H:i:s'));
}
)->orWhere(function ($q): void {
)->orWhere(function ($q) {
$q->whereNull('date_start')
->whereNull('date_end');
});
@ -47,8 +47,8 @@ class HomeController extends Controller
$encart_home = Encart::where('page', Page::homeHeader()->value)->first();
$post_home = Post::where([
['date_start', '<=', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s')],
['date_end', '>', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s')],
['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')],
['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')],
['on_top', true]
])->first();
// Limitation à 3 produits affichés sur la homepage.

View file

@ -28,8 +28,8 @@ class NewsController extends Controller
$title_newsPosts = Title::where('page', Page::newsPosts()->value)->first();
$posts = Post::where([
['date_start', '<=', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s')],
['date_end', '>', \Illuminate\Support\Facades\Date::now()->format('Y-m-d H:i:s')],
['date_start', '<=', Carbon::now()->format('Y-m-d H:i:s')],
['date_end', '>', Carbon::now()->format('Y-m-d H:i:s')],
])
->orderBy('created_at', 'DESC')
->get();

View file

@ -18,7 +18,7 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
@ -37,7 +37,7 @@ class Kernel extends HttpKernel
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
'lang-check',
\Illuminate\Foundation\Http\Middleware\PreventRequestForgery::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\SecureHeaders::class
],
@ -55,7 +55,7 @@ class Kernel extends HttpKernel
*
* @var array
*/
protected $middlewareAliases = [
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
@ -68,6 +68,5 @@ class Kernel extends HttpKernel
'lang-check' => LangCheck::class,
'front-end-globals' => FrontEndGlobals::class,
'back-end-globals' => BackEndGlobals::class,
'admin-secure' => \App\Http\Middleware\AdminSecureMiddleware::class,
];
}

View file

@ -1,46 +0,0 @@
<?php
namespace App\Http\Middleware;
use App\Lib\AdminSecure;
use Closure;
use Dxw\CIDR\IP;
use Illuminate\Http\Request;
class AdminSecureMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (config('app.env') === 'local') {
return $next($request);
}
$client_ip = AdminSecure::fetchClientIp();
$ip_is_allowed = \collect(AdminSecure::getOptions()->getCidrList())
->reduce(fn($initial, $ip_range) => $initial || IP::contains(
$ip_range,
$client_ip
)->unwrap());
$ip_is_allowed_by_config = \collect(AdminSecure::getOptions()->getCidrAllowedList())
->reduce(fn($initial, $ip_range) => $initial || IP::contains(
$ip_range,
$client_ip
)->unwrap());
if ($ip_is_allowed or $ip_is_allowed_by_config or AdminSecure::ipIsPrivate($client_ip)) {
return $next($request);
}
abort(403, \trans('Denied IP'));
}
}

View file

@ -11,7 +11,6 @@ class EncryptCookies extends Middleware
*
* @var array
*/
#[\Override]
protected $except = [
];
}

View file

@ -25,9 +25,9 @@ class FrontEndGlobals
$routeParamsFR = Route::current()->parameters();
$routeParamsEN = $routeParamsFR;
$routeParamsES = $routeParamsFR;
array_walk($routeParamsFR, $this->unbind(...), '');
array_walk($routeParamsEN, $this->unbind(...), 'en');
array_walk($routeParamsES, $this->unbind(...), 'es');
array_walk($routeParamsFR, array($this, 'unbind'), '');
array_walk($routeParamsEN, array($this, 'unbind'), 'en');
array_walk($routeParamsES, array($this, 'unbind'), 'es');
if (preg_match('/^(en|es)/', $currentRoute)) {
$currentRouteFR = preg_replace('/^(en|es)\./', '', $currentRoute, 1);
$currentRouteEN = preg_replace('/^(en|es)/', 'en', $currentRoute, 1);

View file

@ -41,9 +41,9 @@ class LangCheck
if ($this->checkFirstAccess($request)) {
$sess_lang = $request->session()->get('lang', config('app.locale'));
if ($sess_lang === config('app.locale')) {
return to_route($routName, $request->route()->parameters());
return redirect()->route($routName, $request->route()->parameters());
}
return to_route($sess_lang . '.' . $routName, $request->route()->parameters());
return redirect()->route($sess_lang . '.' . $routName, $request->route()->parameters());
}
$this->saveUserLocale(
config('app.locale'),
@ -88,9 +88,6 @@ class LangCheck
*/
private function checkFirstAccess(Request $request)
{
if (str_contains($request->header('User-Agent'), "Uptime-Kuma")) {
return false;
}
// Do we have session ?
if (!$request->session()->has('lang')) {
$fromC = Cookie::get('language');

View file

@ -11,7 +11,6 @@ class PreventRequestsDuringMaintenance extends Middleware
*
* @var array
*/
#[\Override]
protected $except = [
];
}

View file

@ -45,20 +45,28 @@ class SecureHeaders
$cspPolicies = [
// "default-src 'none';",
"manifest-src 'self';",
"connect-src 'self' https://yl.s-web.fr blob:;",
"img-src * https://yl.s-web.fr data: blob:;",
"connect-src 'self' blob: " . \implode(' ', [
'https://*.google-analytics.com',
'https://*.analytics.google.com',
'https://*.googletagmanager.com',
'https://*.g.doubleclick.net',
'https://*.google.com',
]) . ';',
"img-src * data: blob: " . \implode(' ', [
'https://*.google-analytics.com',
'https://*.analytics.google.com',
'https://*.googletagmanager.com',
'https://*.g.doubleclick.net',
'https://*.google.com',
]) . ';',
'frame-src ' . implode(' ', [
'https://www.google.com/recaptcha/',
'https://recaptcha.google.com/recaptcha/',
]) . ';',
]),
// "font-src 'self' data:;",
// ! Using CKEditor will must have unsafe-inline style
// phpcs:ignore Generic.Files.LineLength.TooLong
'style-src ' . implode(" ", [
'\'self\'',
'\'unsafe-inline\'',
'https://cdn.jsdelivr.net',
]) . ';',
"style-src 'self' 'unsafe-inline';",
// ! If you dont use ckeditor use this
// "style-src 'self' 'nonce-$nonce';",
// phpcs:ignore Generic.Files.LineLength.TooLong
@ -66,7 +74,7 @@ class SecureHeaders
'\'self\'',
'https://www.google.com/recaptcha/',
'https://www.gstatic.com/recaptcha/',
'https://yl.s-web.fr',
'https://*.googletagmanager.com',
'https://cdn.ckeditor.com',
'https://cdn.jsdelivr.net',
]) . ' ' . $jsDev . ';'

View file

@ -11,7 +11,6 @@ class TrimStrings extends Middleware
*
* @var array
*/
#[\Override]
protected $except = [
'current_password',
'password',

View file

@ -12,7 +12,6 @@ class TrustProxies extends Middleware
*
* @var array|string|null
*/
#[\Override]
protected $proxies;
/**
@ -20,7 +19,6 @@ class TrustProxies extends Middleware
*
* @var integer
*/
#[\Override]
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |

View file

@ -0,0 +1,16 @@
<?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
*/
protected $except = [
];
}

View file

@ -30,11 +30,11 @@ class StorePostRequest extends FormRequest
{
try {
$this->merge([
'date_start' => \Illuminate\Support\Facades\Date::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(),
'date_end' => \Illuminate\Support\Facades\Date::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(),
'date_start' => Carbon::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(),
'date_end' => Carbon::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(),
'on_top' => $this->on_top ? true : false,
]);
} catch (InvalidFormatException) {
} catch (InvalidFormatException $e) {
$error = ValidationException::withMessages([
'date_start_date' => ['Format de date incorrect'],
'date_end_date' => ['Format de date incorrect'],
@ -58,13 +58,13 @@ class StorePostRequest extends FormRequest
'date_start' => [
'required',
'date_format:Y-m-d H:i:s',
'before:' . \Illuminate\Support\Facades\Date::now()->parse('2037-12-31')
'before:' . Carbon::now()->parse('2037-12-31')
],
'date_end' => [
'required',
'date_format:Y-m-d H:i:s',
'after:date_start',
'before:' . \Illuminate\Support\Facades\Date::now()->parse('2037-12-31')
'before:' . Carbon::now()->parse('2037-12-31')
],
'picture_home' => 'required|image|mimes:jpeg,png,jpg|max:2048|dimensions:max_width=1030,max_height=239',
'alt_text_picture_home' => 'required|max:255',

View file

@ -26,78 +26,78 @@ class StoreProductRequest extends FormRequest
*/
protected function prepareForValidation()
{
$tabFour = [
$tabFour = array(
'id' => 0,
'name' => 'Four',
'url' => '/assets/images/four.png',
'time' => $this->time_cook0,
'temp' => $this->temp_cook0,
'status' => $this->is_activated0 ? true : false
];
$tabFriteuse = [
);
$tabFriteuse = array(
'id' => 1,
'name' => 'Friteuse',
'url' => '/assets/images/friteuse.png',
'time' => $this->time_cook1,
'temp' => $this->temp_cook1,
'status' => $this->is_activated1 ? true : false
];
$tabPoele = [
);
$tabPoele = array(
'id' => 2,
'name' => 'Poêle',
'url' => '/assets/images/poele.png',
'time' => $this->time_cook2,
'temp' => $this->temp_cook2,
'status' => $this->is_activated2 ? true : false
];
$tabCocotte = [
);
$tabCocotte = array(
'id' => 3,
'name' => 'Cocotte',
'url' => '/assets/images/cocotte.png',
'time' => $this->time_cook3,
'temp' => $this->temp_cook3,
'status' => $this->is_activated3 ? true : false
];
$tabPlancha = [
);
$tabPlancha = array(
'id' => 4,
'name' => 'Plancha',
'url' => '/assets/images/plancha.png',
'time' => $this->time_cook4,
'temp' => $this->temp_cook4,
'status' => $this->is_activated4 ? true : false
];
$tabBainMarie = [
);
$tabBainMarie = array(
'id' => 5,
'name' => 'Bain Marie',
'url' => '/assets/images/bainmarie.png',
'time' => $this->time_cook5,
'temp' => $this->temp_cook5,
'status' => $this->is_activated5 ? true : false
];
$tabBarbecue = [
);
$tabBarbecue = array(
'id' => 6,
'name' => 'Barbecue',
'url' => '/assets/images/barbecue.png',
'time' => $this->time_cook6,
'temp' => $this->temp_cook6,
'status' => $this->is_activated6 ? true : false
];
$tabMicroOndes = [
);
$tabMicroOndes = array(
'id' => 7,
'name' => 'Micro Ondes',
'url' => '/assets/images/micro-onde.png',
'time' => $this->time_cook7,
'temp' => $this->temp_cook7,
'status' => $this->is_activated7 ? true : false
];
$tabCasserole = [
);
$tabCasserole = array(
'id' => 8,
'name' => 'Casserole',
'url' => '/assets/images/casserole.png',
'time' => $this->time_cook8,
'temp' => $this->temp_cook8,
'status' => $this->is_activated8 ? true : false
];
);
$tabCuisson = json_encode([
'four' => $tabFour,
'friteuse' => $tabFriteuse,
@ -114,29 +114,29 @@ class StoreProductRequest extends FormRequest
if ($this->pictogramme0) {
$urlPlusProduit = "/assets/images/" . $this->pictogramme0->getClientOriginalName();
}
$tabPlusProduit1 = [
$tabPlusProduit1 = array(
'id' => 0,
'name' => $this->content0,
'url' => $urlPlusProduit,
];
);
$urlPlusProduit = "";
if ($this->pictogramme1) {
$urlPlusProduit = "/assets/images/" . $this->pictogramme1->getClientOriginalName();
}
$tabPlusProduit2 = [
$tabPlusProduit2 = array(
'id' => 1,
'name' => $this->content1,
'url' => $urlPlusProduit,
];
);
$urlPlusProduit = "";
if ($this->pictogramme2) {
$urlPlusProduit = "/assets/images/" . $this->pictogramme2->getClientOriginalName();
}
$tabPlusProduit3 = [
$tabPlusProduit3 = array(
'id' => 2,
'name' => $this->content2,
'url' => $urlPlusProduit,
];
);
$tabPlusProduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]);
$this->merge([
'slug' => Str::slug($this->name),

View file

@ -29,10 +29,10 @@ class StoreSlideRequest extends FormRequest
{
try {
$this->merge([
'date_start' => \Illuminate\Support\Facades\Date::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(),
'date_end' => \Illuminate\Support\Facades\Date::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(),
'date_start' => Carbon::parse("$this->date_start_date $this->date_start_time:00")->toDateTimeString(),
'date_end' => Carbon::parse("$this->date_end_date $this->date_end_time:00")->toDateTimeString(),
]);
} catch (InvalidFormatException) {
} catch (InvalidFormatException $e) {
$error = \Illuminate\Validation\ValidationException::withMessages([
'date_start_date' => ['Format de date incorrect'],
'date_end_date' => ['Format de date incorrect'],
@ -40,8 +40,8 @@ class StoreSlideRequest extends FormRequest
throw $error;
}
$this->merge([
'title' => 'lorem title ' . random_int(0, mt_getrandmax()),
'text' => 'lorem text ' . random_int(0, mt_getrandmax()),
'title' => 'lorem title ' . rand(),
'text' => 'lorem text ' . rand(),
'link_new_tab' => $this->link_new_tab ? true : false
]);
}
@ -65,13 +65,13 @@ class StoreSlideRequest extends FormRequest
'date_start' => [
'nullable',
'date_format:Y-m-d H:i:s',
'before:' . \Illuminate\Support\Facades\Date::now()->parse('2037-12-31')
'before:' . Carbon::now()->parse('2037-12-31')
],
'date_end' => [
'nullable',
'date_format:Y-m-d H:i:s',
'after:date_start',
'before:' . \Illuminate\Support\Facades\Date::now()->parse('2037-12-31')
'before:' . Carbon::now()->parse('2037-12-31')
],
];
}

View file

@ -1,123 +0,0 @@
<?php
namespace App\Lib;
use App\Lib\Options;
use Dxw\CIDR\IPAddress;
use Dxw\CIDR\IPv4Address;
use Dxw\CIDR\IPv4Range;
use Dxw\CIDR\IPv6Address;
use Dxw\CIDR\IPv6Range;
abstract class AdminSecure
{
/**
* Private ipV4 CIDR list
*
* @var array
*/
private static $private_ip_v4_cidr_list = [
'10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'
];
/**
* Private ipV4 CIDR loopback
*
* @var string
*/
private static $private_ip_v4_loopback_cidr = '127.0.0.0/8';
/**
* Private ipV6 CIDR list
*
* @var array
*/
private static $private_ip_v6_cidr_list = [
'fd00::/8'
];
/**
* Private ipV6 CIDR loopback
*
* @var string
*/
private static $private_ip_v6_loopback_cidr = '::1/128';
/**
* Private options
*
* @var \Uwil\AdminSecure\Laravel\Options|null
*/
private static $options = null;
/**
* Check if ip is private
*
* @param \Dxw\CIDR\IPv4Address|\Dxw\CIDR\IPv6Address $ip_address
* @return boolean
*/
public static function ipIsPrivate($ip_address): bool
{
return $ip_address::class === IPv4Address::class ?
self::ipV4IsPrivate($ip_address) : self::ipV6IsPrivate($ip_address);
}
/**
* Fetch client IP
*
* @return \Dxw\CIDR\IPv4Address|\Dxw\CIDR\IPv6Address
* @throws \Uwil\AdminSecure\Laravel\Exceptions\AdminSecureException If the ip is invalid.
*/
public static function fetchClientIp()
{
// ! REVERSE PROXY HACK.
$ip = request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
$ip = IPAddress::Make($ip);
if ($ip->isErr()) {
throw new \Exception(\trans('Client IP not valid ') . $ip->getErr());
}
return $ip->unwrap();
}
/**
* Check if ipV4 is private
*
* @param \Dxw\CIDR\IPv4Address $ipv4_address
* @return boolean
*/
private static function ipV4IsPrivate(IPv4Address $ipv4_address): bool
{
return \collect(self::$private_ip_v4_cidr_list)
->concat([self::$private_ip_v4_loopback_cidr])
->map(fn(string $ipv4_cidr) => IPv4Range::Make($ipv4_cidr)->unwrap())
->reduce(fn($initial, IPv4Range $ipv4_range) => $initial || $ipv4_range->containsAddress($ipv4_address));
}
/**
* Check if ipV6 is private
*
* @param \Dxw\CIDR\IPv6Address $ipv6_address
* @return boolean
*/
private static function ipV6IsPrivate(IPv6Address $ipv6_address): bool
{
return \collect(self::$private_ip_v6_cidr_list)
->concat([self::$private_ip_v6_loopback_cidr])
->map(fn(string $ipv6_cidr) => IPv6Range::Make($ipv6_cidr)->unwrap())
->reduce(fn($initial, IPv6Range $ipv6_range) => $initial || $ipv6_range->containsAddress($ipv6_address));
}
/**
* Get Admin secure options
*
* @return \App\Lib\Options
*/
public static function getOptions(): Options
{
if (!self::$options) {
self::$options = new Options(\config('admin-secure'));
}
return self::$options;
}
}

View file

@ -170,12 +170,19 @@ class ExceptionsHelper
$argsCount = count($stack['args']);
for ($i = 0; $i < $argsCount; $i++) {
$type = \gettype($stack['args'][$i]);
match ($type) {
'object' => $traceArgs .= sprintf('Object(%s)', $stack['args'][$i]::class),
'array' => $traceArgs .= sprintf('Array(%d)', \count($stack['args'][$i])),
'string' => $traceArgs .= sprintf('String(%d)', \strlen($stack['args'][$i])),
default => $traceArgs .= \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;

View file

@ -22,30 +22,40 @@ class ToolboxHelper
'g-recaptcha-response' => [
'required', 'string',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) use ($isV3): void {
function ($attribute, $value, $fail) use ($isV3) {
try {
$response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [
'secret' => config('services.google.recaptcha.private'),
'response' => \strval($value),
'remoteip' => resolve('clientIp')
'remoteip' => app('clientIp')
]);
throw_if($e = $response->toException(), $e);
if ($e = $response->toException()) {
throw $e;
}
if ($isV3) {
throw_if(!$response->json('success') or
!$response->json('challenge_ts') or
\Illuminate\Support\Facades\Date::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST) or
!$response->json('score'), \RuntimeException::class);
if (
!$response->json('success') or
!$response->json('challenge_ts') or
Carbon::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST) or
!$response->json('score')
) {
throw new \RuntimeException();
}
if (\floatval($response->json('score')) < 0.8) {
$fail("Vous n'avez pas obtenu un score assez élevé lors de la validation du recaptcha");
}
return;
}
throw_if(!$response->json('success') or
!$response->json('challenge_ts') or
\Illuminate\Support\Facades\Date::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST), \RuntimeException::class);
} catch (\Exception) {
if (
!$response->json('success') or
!$response->json('challenge_ts') or
Carbon::parse($response->json('challenge_ts'))->lessThan(\now('utc')->subMinutes(5)) or
$response->json('hostname') !== \parse_url(config('app.url'), \PHP_URL_HOST)
) {
throw new \RuntimeException();
}
} catch (\Exception $e) {
$fail('Erreur lors de la validation du formulaire veuillez réssayer');
} //end try
}

View file

@ -1,157 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Lib;
use Dxw\CIDR\IPv4Range;
use Dxw\CIDR\IPv6Range;
use Illuminate\Support\Facades\Cache;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Configuration
*/
final class Options
{
/**
* @var array<string, mixed> The configuration options
*/
private $options;
/**
* @var \Symfony\Component\OptionsResolver\OptionsResolver The options resolver
*/
private $resolver;
/**
* The cache key where to store config cidr list.
*
* @var string
*/
private static $cache_config_key = 'uwil_ip_cidr_config_list';
/**
* Class constructor.
*
* @param array<string, mixed> $options The configuration options.
*/
public function __construct(array $options = [])
{
$this->resolver = new OptionsResolver();
$this->configureOptions($this->resolver);
$this->options = $this->resolver->resolve($options);
}
/**
* Get cidr list
*
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
public function getCidrList(): array
{
return $this->options['cidrList'];
}
/**
* Get cidr project allowed list
*
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
public function getCidrAllowedList(): array
{
return $this->options['cidrProjectAllowedList'];
}
/**
* Configures the options of the client.
*
* @param \Symfony\Component\OptionsResolver\OptionsResolver $resolver The resolver for the options.
* @return void
*/
private function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'cidrList' => [],
'cidrProjectAllowedList' => []
]);
$resolver->setNormalizer('cidrList', $this->normalizeCidrList(...));
$resolver->setNormalizer('cidrProjectAllowedList', $this->normalizeCidrProjectList(...));
}
/**
* Normalise Cidr list for cidrList option
*
* @param \Symfony\Component\OptionsResolver\Options $options
* @param string|null $value
* @return array
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/
private function normalizeCidrList(
\Symfony\Component\OptionsResolver\Options $options,
?string $value
): array {
// phpcs:enable
return $this->doNormalizeCidrList($value, 'cidrList');
}
/**
* Normalise Cidr list for cidrProjectAllowedList option
*
* @param \Symfony\Component\OptionsResolver\Options $options
* @param string|null $value
* @return array
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/
private function normalizeCidrProjectList(
\Symfony\Component\OptionsResolver\Options $options,
?string $value
): array {
// phpcs:enable
return $this->doNormalizeCidrList($value, 'cidrProjectAllowedList');
}
/**
* Normalize CIDR list with specific cache key.
*
* @param string|null $value
* @param string $optionName
* @return array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range>
*/
private function doNormalizeCidrList(?string $value, string $optionName): array
{
$cacheConfigKey = self::$cache_config_key . '_' . $optionName;
$allowed_cidr_config_list = collect(explode(',', strval($value)))->filter();
$allowed_cidr_config_list_hash = \md5($allowed_cidr_config_list->implode(','));
$allowed_cidr_list = [];
// Flush cache if config hash changed
if ($allowed_cidr_config_list_hash !== \collect(Cache::get($cacheConfigKey))->get('hash')) {
Cache::forget($cacheConfigKey);
/** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */
$allowed_cidr_list = $allowed_cidr_config_list
->map(function (string $cidr) {
$ip_range = !IPv4Range::Make($cidr)->isErr() ? IPv4Range::Make($cidr) : IPv6Range::Make($cidr);
if ($ip_range->isErr()) {
throw new \Exception(\trans(
'CIDR LIST not valid (ipv4 or ipv6 cidr) :cidr',
[
'cidr' => $cidr
]
));
}
return $ip_range->unwrap();
})->all();
}
/** @var array<\Dxw\CIDR\IPv4Range|\Dxw\CIDR\IPv6Range> $allowed_cidr_list */
return \collect(Cache::rememberForever($cacheConfigKey, fn() => [
'list' => $allowed_cidr_list,
'hash' => $allowed_cidr_config_list_hash
]))->get('list');
}
}

View file

@ -29,7 +29,7 @@ class Utils
*/
public static function storeImage($image, string $folderName): string
{
if (\is_object($image) and $image::class === UploadedFile::class) {
if (\is_object($image) and get_class($image) === UploadedFile::class) {
/** @var UploadedFile */
$image = $image;
$newPath = self::prepareMoveFile($image->getClientOriginalName(), $folderName);
@ -37,7 +37,7 @@ class Utils
$image->storePubliclyAs(pathinfo($newPath, \PATHINFO_DIRNAME), pathinfo($newPath, \PATHINFO_BASENAME));
return '/storage' . str_replace('/public', '', $newPath);
}
if (\is_object($image) and $image::class === SplFileInfo::class) {
if (\is_object($image) and get_class($image) === SplFileInfo::class) {
/** @var SplFileInfo */
$image = $image;
$newPath = self::prepareMoveFile($image->getBaseName(), $folderName);

View file

@ -18,7 +18,6 @@ class Advice extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title1',
'title2',
@ -58,7 +57,7 @@ class Advice extends Model
*/
protected static function boot()
{
static::creating(function (Advice $advice): void {
static::creating(function (Advice $advice) {
if (is_a($advice->picture1, "SplFileInfo")) {
$advice->picture1 = Utils::storeImage($advice->picture1, $advice->getTable());
}
@ -70,7 +69,7 @@ class Advice extends Model
}
});
static::updating(function (Advice $advice): void {
static::updating(function (Advice $advice) {
if (is_a($advice->picture1, "SplFileInfo")) {
$advice->picture1 = Utils::storeImage($advice->picture1, $advice->getTable());
}
@ -82,7 +81,7 @@ class Advice extends Model
}
});
static::deleted(function (Advice $advice): void {
static::deleted(function (Advice $advice) {
if ($advice->picture1) {
$urlPicture = public_path() . $advice->picture1;
if ($urlPicture) {

View file

@ -28,7 +28,6 @@ class Encart extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'subtitle',
@ -57,19 +56,19 @@ class Encart extends Model
*/
protected static function boot()
{
static::creating(function (Encart $encart): void {
static::creating(function (Encart $encart) {
if (is_a($encart->picture, "SplFileInfo")) {
$encart->picture = Utils::storeImage($encart->picture, $encart->getTable());
}
});
static::updating(function (Encart $encart): void {
static::updating(function (Encart $encart) {
if (is_a($encart->picture, "SplFileInfo")) {
$encart->picture = Utils::storeImage($encart->picture, $encart->getTable());
}
});
static::deleted(function (Encart $encart): void {
static::deleted(function (Encart $encart) {
if ($encart->picture) {
$urlPicture = public_path() . $encart->picture;
if ($urlPicture) {

View file

@ -18,7 +18,6 @@ class Gamme extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'parent_gamme_id',
'title',
@ -54,7 +53,7 @@ class Gamme extends Model
*/
protected static function boot()
{
static::creating(function (Gamme $gamme): void {
static::creating(function (Gamme $gamme) {
if (is_a($gamme->picture, "SplFileInfo")) {
$gamme->picture = Utils::storeImage($gamme->picture, $gamme->getTable());
}
@ -68,7 +67,7 @@ class Gamme extends Model
}
});
static::updating(function (Gamme $gamme): void {
static::updating(function (Gamme $gamme) {
if (is_a($gamme->picture, "SplFileInfo")) {
$gamme->picture = Utils::storeImage($gamme->picture, $gamme->getTable());
}
@ -94,14 +93,14 @@ class Gamme extends Model
}
});
static::deleting(function (Gamme $gamme): void {
static::deleting(function (Gamme $gamme) {
if ($gamme->childGammes()->exists()) {
Gamme::whereParentGammeId($gamme->id)
->update(['parent_gamme_id' => null]);
}
});
static::deleted(function (Gamme $gamme): void {
static::deleted(function (Gamme $gamme) {
if ($gamme->picture) {
$urlPicture = public_path() . $gamme->picture;
if ($urlPicture) {
@ -127,7 +126,7 @@ class Gamme extends Model
*
* @return string
*/
protected function getRgbaColorAttribute()
public function getRgbaColorAttribute()
{
$color = $this->color;
@ -137,7 +136,7 @@ class Gamme extends Model
if ($color[0] == '#') {
$color = substr($color, 1);
}
[$r, $g, $b] = array_map(hexdec(...), str_split($color, (strlen($color) / 3)));
list($r, $g, $b) = array_map("hexdec", str_split($color, (strlen($color) / 3)));
return "rgba($r,$g,$b,1)";
}

View file

@ -28,7 +28,6 @@ class Moment extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'subtitle',
@ -57,19 +56,19 @@ class Moment extends Model
*/
protected static function boot()
{
static::creating(function (Moment $moment): void {
static::creating(function (Moment $moment) {
if (is_a($moment->picture, "SplFileInfo")) {
$moment->picture = Utils::storeImage($moment->picture, $moment->getTable());
}
});
static::updating(function (Moment $moment): void {
static::updating(function (Moment $moment) {
if (is_a($moment->picture, "SplFileInfo")) {
$moment->picture = Utils::storeImage($moment->picture, $moment->getTable());
}
});
static::deleted(function (Moment $moment): void {
static::deleted(function (Moment $moment) {
if ($moment->picture) {
$urlPicture = public_path() . $moment->picture;
if ($urlPicture) {

View file

@ -28,7 +28,6 @@ class Picto extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'picture',
'alt_text_picture',
@ -53,19 +52,19 @@ class Picto extends Model
*/
protected static function boot()
{
static::creating(function (Picto $picto): void {
static::creating(function (Picto $picto) {
if (is_a($picto->picture, "SplFileInfo")) {
$picto->picture = Utils::storeImage($picto->picture, $picto->getTable());
}
});
static::updating(function (Picto $picto): void {
static::updating(function (Picto $picto) {
if (is_a($picto->picture, "SplFileInfo")) {
$picto->picture = Utils::storeImage($picto->picture, $picto->getTable());
}
});
static::deleted(function (Picto $picto): void {
static::deleted(function (Picto $picto) {
if ($picto->picture) {
$urlPicture = public_path() . $picto->picture;
if ($urlPicture) {

View file

@ -18,7 +18,6 @@ class PictoBrand extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'picture',
@ -45,19 +44,19 @@ class PictoBrand extends Model
*/
protected static function boot()
{
static::creating(function (PictoBrand $pictoBrand): void {
static::creating(function (PictoBrand $pictoBrand) {
if (is_a($pictoBrand->picture, "SplFileInfo")) {
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
}
});
static::updating(function (PictoBrand $pictoBrand): void {
static::updating(function (PictoBrand $pictoBrand) {
if (is_a($pictoBrand->picture, "SplFileInfo")) {
$pictoBrand->picture = Utils::storeImage($pictoBrand->picture, $pictoBrand->getTable());
}
});
static::deleted(function (PictoBrand $pictoBrand): void {
static::deleted(function (PictoBrand $pictoBrand) {
if ($pictoBrand->picture) {
$urlPicture = public_path() . $pictoBrand->picture;
if ($urlPicture) {

View file

@ -18,7 +18,6 @@ class Post extends Model
*
* @var array
*/
#[\Override]
protected $casts = [
'date_start' => 'datetime',
'date_end' => 'datetime',
@ -29,7 +28,6 @@ class Post extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'text',
@ -64,7 +62,7 @@ class Post extends Model
*/
protected static function boot()
{
static::creating(function (Post $post): void {
static::creating(function (Post $post) {
if (is_a($post->picture_home, "SplFileInfo")) {
$post->picture_home = Utils::storeImage($post->picture_home, $post->getTable());
}
@ -73,7 +71,7 @@ class Post extends Model
}
});
static::updating(function (Post $post): void {
static::updating(function (Post $post) {
if (is_a($post->picture_home, "SplFileInfo")) {
$post->picture_home = Utils::storeImage($post->picture_home, $post->getTable());
}
@ -82,7 +80,7 @@ class Post extends Model
}
});
static::deleted(function (Post $post): void {
static::deleted(function (Post $post) {
if ($post->picture_home) {
$urlPicture = public_path() . $post->picture_home;
if ($urlPicture) {

View file

@ -18,7 +18,6 @@ class Product extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'gamme_id',
'name',
@ -61,19 +60,19 @@ class Product extends Model
*/
protected static function boot()
{
static::creating(function (Product $product): void {
static::creating(function (Product $product) {
if (is_a($product->picture, "SplFileInfo")) {
$product->picture = Utils::storeImage($product->picture, $product->getTable());
}
});
static::updating(function (Product $product): void {
static::updating(function (Product $product) {
if (is_a($product->picture, "SplFileInfo")) {
$product->picture = Utils::storeImage($product->picture, $product->getTable());
}
});
static::deleted(function (Product $product): void {
static::deleted(function (Product $product) {
if ($product->picture) {
$urlPicture = public_path() . $product->picture;
if ($urlPicture) {

View file

@ -26,7 +26,6 @@ class SeoDatum extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'description',

View file

@ -18,7 +18,6 @@ class Slide extends Model
*
* @var array
*/
#[\Override]
protected $casts = [
'date_start' => 'datetime',
'date_end' => 'datetime',
@ -29,7 +28,6 @@ class Slide extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'text',
@ -64,19 +62,19 @@ class Slide extends Model
*/
protected static function boot()
{
static::creating(function (Slide $slide): void {
static::creating(function (Slide $slide) {
if (is_a($slide->picture, "SplFileInfo")) {
$slide->picture = Utils::storeImage($slide->picture, $slide->getTable());
}
});
static::updating(function (Slide $slide): void {
static::updating(function (Slide $slide) {
if (is_a($slide->picture, "SplFileInfo")) {
$slide->picture = Utils::storeImage($slide->picture, $slide->getTable());
}
});
static::deleted(function (Slide $slide): void {
static::deleted(function (Slide $slide) {
if ($slide->picture) {
$urlPicture = public_path() . $slide->picture;
if ($urlPicture) {

View file

@ -17,7 +17,6 @@ class Slider extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'label',
'slug',
@ -53,12 +52,12 @@ class Slider extends Model
*/
public function showableSlides()
{
$now = \Illuminate\Support\Facades\Date::now();
$now = Carbon::now();
return $this->hasMany(Slide::class, 'slider_id')
->orderBy('order', 'ASC')->where(function (\Illuminate\Contracts\Database\Query\Builder $q) use ($now): void {
->orderBy('order', 'ASC')->where(function ($q) use ($now) {
$q->whereDate('date_start', '<=', $now)
->orWhereNull('date_start');
})->where(function (\Illuminate\Contracts\Database\Query\Builder $q) use ($now): void {
})->where(function ($q) use ($now) {
$q->whereDate('date_end', '>=', $now)
->orWhereNull('date_end');
});

View file

@ -26,7 +26,6 @@ class Text extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'text',

View file

@ -26,7 +26,6 @@ class Title extends Model
*
* @var array
*/
#[\Override]
protected $fillable = [
'title',
'text',

View file

@ -29,7 +29,6 @@ class User extends Authenticatable
*
* @var string[]
*/
#[\Override]
protected $fillable = [
'name',
'email',
@ -41,7 +40,6 @@ class User extends Authenticatable
*
* @var array
*/
#[\Override]
protected $hidden = [
'password',
'remember_token',
@ -52,7 +50,6 @@ class User extends Authenticatable
*
* @var array
*/
#[\Override]
protected $casts = [
'email_verified_at' => 'datetime',
];
@ -64,13 +61,13 @@ class User extends Authenticatable
*/
protected static function boot()
{
static::creating(function (User $user): void {
static::creating(function (User $user) {
if (Hash::needsRehash($user->password)) {
$user->password = Hash::make($user->password);
}
});
static::updating(function (User $user): void {
static::updating(function (User $user) {
if (Hash::needsRehash($user->password)) {
$user->password = Hash::make($user->password);
}

View file

@ -11,7 +11,6 @@ class AuthServiceProvider extends ServiceProvider
*
* @var array
*/
#[\Override]
protected $policies = [];
/**

View file

@ -13,7 +13,6 @@ class EventServiceProvider extends ServiceProvider
*
* @var array
*/
#[\Override]
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,

View file

@ -26,7 +26,7 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
$this->routes(function (): void {
$this->routes(function () {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
@ -37,7 +37,7 @@ class RouteServiceProvider extends ServiceProvider
$vars = $this->getRouteBinderVars($value);
\extract($vars);
/** @var \App\Models\Gamme */
$gamme = Gamme::where(function (Builder $q) use ($locale, $defaultLocale, $value): void {
$gamme = Gamme::where(function (Builder $q) use ($locale, $defaultLocale, $value) {
$q->whereRaw("JSON_EXTRACT(slug, '$.$locale') = '$value'")
->orWhereRaw("JSON_EXTRACT(slug, '$.$defaultLocale') = '$value'");
})->firstOrFail();
@ -52,7 +52,7 @@ class RouteServiceProvider extends ServiceProvider
$vars = $this->getRouteBinderVars($value);
\extract($vars);
/** @var \App\Models\Product */
$product = Product::where(function (Builder $q) use ($locale, $defaultLocale, $value): void {
$product = Product::where(function (Builder $q) use ($locale, $defaultLocale, $value) {
$q->whereRaw("JSON_EXTRACT(slug, '$.$locale') = '$value'")
->orWhereRaw("JSON_EXTRACT(slug, '$.$defaultLocale') = '$value'");
})->where('gamme_id', $gamme->id)

View file

@ -12,7 +12,7 @@
*/
$app = new Illuminate\Foundation\Application(
\Illuminate\Support\Env::get('APP_BASE_PATH', dirname(__DIR__))
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*

View file

@ -8,30 +8,28 @@
],
"license": "MIT",
"require": {
"php": "^8.5",
"dxw/cidr": "^4.0",
"php": "^7.3",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"joedixon/laravel-translation": "^1.1",
"kwaadpepper/enum": "^2.1",
"laravel/framework": "^13.0",
"laravel/tinker": "^3.0",
"laravel/ui": "^4.0",
"kwaadpepper/refresh-sitemap": "^1.0",
"laravel/framework": "^8.65",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.3",
"ldc/web-admin-secure-laravel": "^1.0",
"mews/purifier": "^3.3",
"sentry/sentry-laravel": "^4.1",
"spatie/laravel-translatable": "^6.0",
"uwil/laravel-k8s": "*"
"spatie/laravel-translatable": "^4.6"
},
"require-dev": {
"driftingly/rector-laravel": "^2.5",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^12.0",
"rector/rector": "^2.8",
"slevomat/coding-standard": "^8.31",
"spatie/laravel-ignition": "^2.0",
"squizlabs/php_codesniffer": "^4.0"
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10",
"slevomat/coding-standard": "^7.0"
},
"autoload": {
"psr-4": {
@ -74,20 +72,9 @@
},
"gitlab-domains": [
"lab.s-web.fr"
],
"policy": {
"advisories": {
"ignore": {
"laravel/framework": {
"constraint": "^10.0",
"on-audit": false,
"reason": "Palier temporaire de migration vers une version Laravel maintenue. Ne pas deployer."
}
}
}
}
]
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": {
"lab.s-web.fr": {

7369
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
<?php
return [
'cidrList' => env('UWIL_ADMIN_SECURE_CIDR_LIST'),
'cidrProjectAllowedList' => env('UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST')
];

View file

@ -177,6 +177,7 @@ return [
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,

View file

@ -59,7 +59,7 @@ return [
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
\Pdo\Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],

View file

@ -13,7 +13,7 @@ return [
|
*/
'default' => env('FILESYSTEM_DISK', 'local'),
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------

5
config/google.php Normal file
View file

@ -0,0 +1,5 @@
<?php
return [
'analyticsKey' => env('ANALYTICS_GOOGLE_ID')
];

View file

@ -17,7 +17,7 @@ return [
|
*/
'default' => env('LOG_CHANNEL', 'k8s'),
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------

114
config/refresh-sitemap.php Normal file
View file

@ -0,0 +1,114 @@
<?php
use App\Models\Gamme;
use App\Models\Product;
use Spatie\Sitemap\Tags\Url;
return [
/**
* A list of url to ignore
* These are hard coded
* Each url does not have to be exhaustive
*
* For example, if you want to ignore all routes
* of the backoffice group
* just add '/backoffice' into this table
*/
'ignoreRoutes' => [
'/bo'
],
/**
* This table is needed to resolve models matching
* routes
*
* it has to be filled like following
*
* 'products.meat-type' => [
* 'slugMeatType' => [MeatTypes::class, 'slug']
* ],
* 'kitchen-side.health-nutrition.balanced-menu.menu' => [
* 'type' => [BalancedMenuType::class, 'type']
* ]
*
* The index is the complete route name, the array content is an array
* within index is the argument name with its model class.
* This will allow the generator to generate a route for each of the models
* in this table
*/
'routesBinder' => [
'gammes.show' => [
'gammeSlug' => [Gamme::class, 'slug'],
],
'product.show' => [
'gammeSlug' => [Gamme::class, 'slug'],
'productSlug' => [Product::class, 'slug']
]
],
/**
* You can put route conditions here
* These will be used to decide whether the route should appear
* in the sitemap or not
*
* These are called in Eloquent where
*
* example
*
* 'queryConditions' => [
* 'status' => true,
* 'ocbStatus' => EleveurOcbStatus::yes()->value,
* 'star_moment' => true
* ]
*
*/
'queryConditions' => [],
/**
* The default route frequency to use with sitemap generator
*/
'routeDefaultFrequency' => Url::CHANGE_FREQUENCY_DAILY,
/**
* The default route priority to use with sitemap generator
*
* priority should be a number between 0 and 1
* https://www.sitemaps.org/protocol.html
*/
'routeDefaultPriority' => 0.5,
/**
* Frequencies for routes
* use the full or partial route name as index
* and a frequency within \Spatie\Sitemap\Tags\Url constants
*/
'routeFrequencies' => [],
/**
* Priorities for routes
* use the full or partial route name as index
* and a priority number between 0 and 1
*/
'routePriorities' => [],
/**
* Enable or disable schedule for the job
* If set to true the sitemap generator will be run
* using the 'cron' instruction
*/
'schedule' => false,
/**
* If you want to set specific
* instruction for when to schedule job
* you can set this with a cron instruction
* You can generate one using https://crontab.guru/
* https://laravel.com/docs/8.x/scheduling#schedule-frequency-options
*
* schedule must be set to true
*
* Default is every day at 15:45
*/
'cron' => '45 15 * * *'
];

View file

@ -57,5 +57,5 @@ return [
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces-sample-rate.
'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? null : (float)env('SENTRY_TRACES_SAMPLE_RATE'),
'before_send' => \App\Lib\Helpers\ExceptionsHelper::sentryEventHandler(...),
'before_send' => [\App\Lib\Helpers\ExceptionsHelper::class, 'sentryEventHandler'],
];

View file

@ -38,7 +38,4 @@ return [
]
],
'matomo' => [
'site_id' => env('MATOMO_SITE_ID')
],
];

View file

@ -14,7 +14,6 @@ class AdviceFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Advice::class;
/**

View file

@ -14,7 +14,6 @@ class EncartFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Encart::class;
/**

View file

@ -17,7 +17,7 @@ class GammeFactory extends Factory
*/
public function definition()
{
$title = $this->faker->text(10) . random_int(1, 100);
$title = $this->faker->text(10) . rand(1, 100);
$upload = new SplFileInfo(resource_path('assets/images/cookrange.jpg'));
$picture = new Gamme();

View file

@ -13,7 +13,6 @@ class MomentFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Moment::class;
/**

View file

@ -14,7 +14,6 @@ class PictoBrandFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = PictoBrand::class;
/**

View file

@ -14,7 +14,6 @@ class PictoFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Picto::class;
/**

View file

@ -31,8 +31,8 @@ class PostFactory extends Factory
'alt_text_picture_home' => $this->faker->sentence(10),
'picture_news' => $imgnewspath,
'alt_text_picture_news' => $this->faker->sentence(10),
'date_start' => \Illuminate\Support\Facades\Date::now(),
'date_end' => \Illuminate\Support\Facades\Date::now()->addDays(2),
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
'on_top' => true
];
}

View file

@ -17,94 +17,94 @@ class ProductFactory extends Factory
*/
public function definition()
{
$name = $this->faker->text(10) . random_int(1, 100);
$tabFour = [
$name = $this->faker->text(10) . rand(1, 100);
$tabFour = array(
'id' => 0,
'name' => 'Four',
'url' => '/assets/images/four.png',
'time' => '1h30mins.',
'temp' => '200°C',
'status' => true
];
$tabFriteuse = [
);
$tabFriteuse = array(
'id' => 1,
'name' => 'Friteuse',
'url' => '/assets/images/friteuse.png',
'time' => '15 minutes',
'temp' => '100°C',
'status' => true
];
$tabPoele = [
);
$tabPoele = array(
'id' => 2,
'name' => 'Poêle',
'url' => '/assets/images/poele.png',
'time' => '5 minutes sur chaque face',
'temp' => '100°C',
'status' => false
];
$tabCocotte = [
);
$tabCocotte = array(
'id' => 3,
'name' => 'Cocotte',
'url' => '/assets/images/cocotte.png',
'time' => '3 h',
'temp' => '80°C',
'status' => true
];
$tabPlancha = [
);
$tabPlancha = array(
'id' => 4,
'name' => 'Plancha',
'url' => '/assets/images/plancha.png',
'time' => '20mins',
'temp' => '130°C',
'status' => false
];
$tabBainMarie = [
);
$tabBainMarie = array(
'id' => 5,
'name' => 'Bain Marie',
'url' => '/assets/images/bainmarie.png',
'time' => '30 mins à 45 mins',
'temp' => '80°C',
'status' => false
];
$tabBarbecue = [
);
$tabBarbecue = array(
'id' => 6,
'name' => 'Barbecue',
'url' => '/assets/images/barbecue.png',
'time' => '30 minutes',
'temp' => '200°C',
'status' => false
];
$tabMicroOndes = [
);
$tabMicroOndes = array(
'id' => 7,
'name' => 'Micro Ondes',
'url' => '/assets/images/microondes.png',
'time' => '3mins',
'temp' => '900 Watts',
'status' => false
];
$tabCasserole = [
);
$tabCasserole = array(
'id' => 8,
'name' => 'Casserole',
'url' => '/assets/images/casserole.png',
'time' => '10mins',
'temp' => '90°C',
'status' => false
];
$tabPlusProduit1 = [
);
$tabPlusProduit1 = array(
'id' => 0,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
];
$tabPlusProduit2 = [
);
$tabPlusProduit2 = array(
'id' => 1,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
];
$tabPlusProduit3 = [
);
$tabPlusProduit3 = array(
'id' => 2,
'name' => 'Lorem ipsum set doloris',
'url' => '/assets/images/sans-label.jpg',
];
);
$upload = new SplFileInfo(resource_path('assets/images/product_sample_01.png'));
$picture = new Product();
@ -129,10 +129,10 @@ class ProductFactory extends Factory
]),
'plusproduit' => json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]),
'is_published' => true,
'is_on_top' => random_int(true, false),
'is_news' => random_int(true, false),
'is_food_service' => random_int(true, false),
'is_halal' => random_int(true, false),
'is_on_top' => rand(true, false),
'is_news' => rand(true, false),
'is_food_service' => rand(true, false),
'is_halal' => rand(true, false),
'seo_title' => $this->faker->text(5),
'seo_description' => $this->faker->sentence(20),
];

View file

@ -15,7 +15,6 @@ class SlideFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Slide::class;
/**
@ -34,10 +33,10 @@ class SlideFactory extends Factory
'title' => $this->faker->unique()->word(),
'text' => $this->faker->realText(25),
'link_label' => $this->faker->text(128),
'link' => 'route(\'wasup\')',
'link_new_tab' => random_int(0, 1),
'date_start' => \Illuminate\Support\Facades\Date::now(),
'date_end' => \Illuminate\Support\Facades\Date::now()->addDays(2),
'link' => route('wasup'),
'link_new_tab' => rand(0, 1),
'date_start' => Carbon::now(),
'date_end' => Carbon::now()->addDays(2),
'picture' => $imgpath,
'alt_text_picture' => $this->faker->sentence(10),
];

View file

@ -13,7 +13,6 @@ class SliderFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Slider::class;
/**

View file

@ -12,7 +12,6 @@ class TextFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Text::class;
/**

View file

@ -12,7 +12,6 @@ class TitleFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = Title::class;
/**

View file

@ -13,7 +13,6 @@ class UserFactory extends Factory
*
* @var string
*/
#[\Override]
protected $model = User::class;
/**
@ -41,8 +40,10 @@ class UserFactory extends Factory
public function unverified()
{
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
return $this->state(fn(array $attributes) => [
'email_verified_at' => null,
]);
return $this->state(function (array $attributes) {
return [
'email_verified_at' => null,
];
});
}
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('users', function (Blueprint $table): void {
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->smallInteger('role');
$table->string('name');
@ -23,6 +23,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -32,4 +33,4 @@ return new class extends Migration
{
Schema::dropIfExists('users');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
@ -13,12 +13,13 @@ return new class extends Migration
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table): void {
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
@ -28,4 +29,4 @@ return new class extends Migration
{
Schema::dropIfExists('password_resets');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table): void {
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
@ -23,6 +23,7 @@ return new class extends Migration
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*
@ -32,4 +33,4 @@ return new class extends Migration
{
Schema::dropIfExists('failed_jobs');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateEncartsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('encarts', function (Blueprint $table): void {
Schema::create('encarts', function (Blueprint $table) {
$table->id();
$table->smallInteger('page');
$table->text('title');
@ -24,6 +24,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -33,4 +34,4 @@ return new class extends Migration
{
Schema::dropIfExists('encarts');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateSlidersTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('sliders', function (Blueprint $table): void {
Schema::create('sliders', function (Blueprint $table) {
$table->id();
$table->text('label');
$table->string('slug')->unique();
@ -22,6 +22,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -31,4 +32,4 @@ return new class extends Migration
{
Schema::dropIfExists('sliders');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateSlidesTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('slides', function (Blueprint $table): void {
Schema::create('slides', function (Blueprint $table) {
$table->id();
$table->foreignId('slider_id')->default(1)->constrained('sliders');
@ -32,6 +32,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -41,4 +42,4 @@ return new class extends Migration
{
Schema::dropIfExists('slides');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreatePictosTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('pictos', function (Blueprint $table): void {
Schema::create('pictos', function (Blueprint $table) {
$table->id();
$table->smallInteger('page');
$table->text('picture')->nullable();
@ -22,6 +22,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -31,4 +32,4 @@ return new class extends Migration
{
Schema::dropIfExists('pictos');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreatePictoBrandsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('picto_brands', function (Blueprint $table): void {
Schema::create('picto_brands', function (Blueprint $table) {
$table->id();
$table->text('title');
$table->text('picture')->nullable();
@ -22,6 +22,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -31,4 +32,4 @@ return new class extends Migration
{
Schema::dropIfExists('picto_brands');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateTitlesTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('titles', function (Blueprint $table): void {
Schema::create('titles', function (Blueprint $table) {
$table->id();
$table->smallInteger('page')->unique();
$table->text('title');
@ -21,6 +21,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -30,4 +31,4 @@ return new class extends Migration
{
Schema::dropIfExists('titles');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateTextsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('texts', function (Blueprint $table): void {
Schema::create('texts', function (Blueprint $table) {
$table->id();
$table->smallInteger('page');
$table->text('title');
@ -21,6 +21,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -30,4 +31,4 @@ return new class extends Migration
{
Schema::dropIfExists('texts');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateAdviceTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('advice', function (Blueprint $table): void {
Schema::create('advice', function (Blueprint $table) {
$table->id();
$table->text('title1');
$table->text('title2');
@ -28,6 +28,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -37,4 +38,4 @@ return new class extends Migration
{
Schema::dropIfExists('advice');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreatePostsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('posts', function (Blueprint $table): void {
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->text('title');
$table->mediumText('text');
@ -27,6 +27,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -36,4 +37,4 @@ return new class extends Migration
{
Schema::dropIfExists('posts');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateGammesTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('gammes', function (Blueprint $table): void {
Schema::create('gammes', function (Blueprint $table) {
$table->id();
$table->foreignId('parent_gamme_id')->nullable();
$table->text('title');
@ -27,6 +27,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -36,4 +37,4 @@ return new class extends Migration
{
Schema::dropIfExists('gammes');
}
};
}

View file

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
@ -13,7 +13,7 @@ return new class extends Migration
*/
public function up()
{
Schema::create('products', function (Blueprint $table): void {
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->foreignId('gamme_id')->nullable();
$table->text('name');
@ -32,6 +32,7 @@ return new class extends Migration
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
@ -41,4 +42,4 @@ return new class extends Migration
{
Schema::dropIfExists('products');
}
};
}

Some files were not shown because too many files have changed in this diff Show more