Merge branch 'develop' into trunk

This commit is contained in:
Jérémy Munsch 2026-11-04 10:33:01 +01:00
commit 0cfd8cf5aa
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
49 changed files with 1934 additions and 1683 deletions

View file

@ -62,14 +62,18 @@ SAML2_CONTACT_TECHNICAL_EMAIL=
SAML2_CONTACT_SUPPORT_EMAIL=
SAML2_DEFAULT_TENANT_UUID=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ACCESS_KEY_ID=minioadmin
AWS_SECRET_ACCESS_KEY=minioadmin
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_BUCKET=ovoteam
AWS_ENDPOINT=http://127.0.0.1:9000
AWS_URL=http://127.0.0.1:9000/ovoteam
AWS_USE_PATH_STYLE_ENDPOINT=true
VITE_APP_NAME="${APP_NAME}"
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=
MEILISEARCH_KEY=
STORAGE_SERVICE_PREFIX=media

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Database\Eloquent\Model;
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
/** @implements CastsAttributes<StorageFilePath|null, StorageFilePath|string|null> */
class FilePathCast implements CastsAttributes
{
/** @param array<string, mixed> $attributes */
public function get(Model $model, string $key, mixed $value, array $attributes): ?StorageFilePath
{
if ($value === null) {
return null;
}
if (! is_string($value)) {
throw new \InvalidArgumentException('The given value is not a valid file path string.');
}
return new StorageFilePath($value);
}
/** @param array<string, mixed> $attributes */
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
{
if ($value === null) {
return null;
}
if ($value instanceof StorageFilePath) {
return $value->value;
}
if (is_string($value)) {
return (new StorageFilePath($value))->value;
}
throw new \InvalidArgumentException('The given value is not a valid StorageFilePath instance or path string.');
}
}

View file

@ -169,7 +169,7 @@ class EloquentProductDirectory implements ProductDirectory
return new ProductSummary(
id: (string) $product->id,
name: $product->name,
picture: $product->picture,
picture: $product->picture?->value,
);
}
@ -194,10 +194,10 @@ class EloquentProductDirectory implements ProductDirectory
seoDescription: $product->seo_description,
conservationAfterOpening: $product->conservation_after_opening,
nutritionalValues: $product->nutritional_values,
picture: $product->picture,
picture: $product->picture->value,
pictureAlt: $product->picture_alt,
pictureTitle: $product->picture_title,
pdfFilePath: $product->pdf,
pdfFilePath: $product->pdf?->value,
associatedRecipes: $product->recipes->map(
fn (Recipe $recipe): UuidInterface => $recipe->getId()->value
)->all()

View file

@ -103,7 +103,7 @@ class EloquentRecipeDirectory implements RecipeDirectory
id: new RecipeId(Uuid::fromString($recipe->id)),
name: $recipe->name,
slug: $recipe->slug,
picture: $recipe->picture,
picture: $recipe->picture->value,
seoTitle: $recipe->seo_title,
seoDescription: $recipe->seo_description,
productRange: $recipe->product_category,

View file

@ -18,9 +18,11 @@ use Domain\Models\ValueObjects\Products\Technology;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Inertia\Response;
use Uwil\Storage\Facades\StorageService;
class ProductController extends BackendController
{
@ -104,7 +106,15 @@ class ProductController extends BackendController
$product = new Product();
/** @var array<string, mixed> $data */
$data = $request->only($product->getFillable());
$product->fill($data);
/** @var array<string, mixed> $dataToFill */
$dataToFill = Arr::except($data, ['picture', 'pdf']);
$product->fill($dataToFill);
$product->picture = StorageService::storeUploaded($request->file('picture'));
if ($request->file('pdf')) {
$product->pdf = StorageService::storeUploaded($request->file('pdf'));
}
if ($product->saveOrFail()) {
return redirect()->route('back.products.edit', $product)
@ -144,7 +154,18 @@ class ProductController extends BackendController
return DB::transaction(function () use ($request, $product) {
/** @var array<string, mixed> $data */
$data = $request->only($product->getFillable());
$product->fill($data);
/** @var array<string, mixed> $dataToFill */
$dataToFill = Arr::except($data, ['picture', 'pdf']);
$product->fill($dataToFill);
if ($request->file('picture')) {
$product->picture = StorageService::storeUploaded($request->file('picture'));
}
if ($request->file('pdf')) {
$product->pdf = StorageService::storeUploaded($request->file('pdf'));
}
if ($product->saveOrFail()) {
return redirect()->route('back.products.edit', $product)

View file

@ -17,9 +17,11 @@ use Domain\Models\ValueObjects\Recipes\Season;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Inertia\Response;
use Uwil\Storage\Facades\StorageService;
class RecipeController extends BackendController
{
@ -105,7 +107,12 @@ class RecipeController extends BackendController
$recipe = new Recipe();
/** @var array<string, mixed> $data */
$data = $request->only($recipe->getFillable());
$recipe->fill($data);
/** @var array<string, mixed> $dataToFill */
$dataToFill = Arr::except($data, ['picture']);
$recipe->fill($dataToFill);
$recipe->picture = StorageService::storeUploaded($request->file('picture'));
if ($recipe->saveOrFail()) {
$recipe->products()
@ -149,7 +156,14 @@ class RecipeController extends BackendController
return DB::transaction(function () use ($request, $recipe) {
/** @var array<string, mixed> $data */
$data = $request->only($recipe->getFillable());
$recipe->fill($data);
/** @var array<string, mixed> $dataToFill */
$dataToFill = Arr::except($data, ['picture']);
$recipe->fill($dataToFill);
if ($request->file('picture')) {
$recipe->picture = StorageService::storeUploaded($request->file('picture'));
}
if ($recipe->saveOrFail()) {
$recipe->products()

View file

@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Config;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Uwil\Storage\Contracts\StorageService;
use Uwil\Storage\Exceptions\UnexpectedStorageException;
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
class MediaController extends Controller
{
public function __invoke(string $path, StorageService $storage): StreamedResponse
{
$prefix = Config::string('storage-service.prefix', 'media');
$fullPath = $prefix !== ''
? trim($prefix, '/') . '/' . ltrim($path, '/')
: ltrim($path, '/');
try {
$filePath = new StorageFilePath($fullPath);
} catch (UnexpectedStorageException) {
abort(404, 'Fichier introuvable ou chemin invalide.');
}
$fileStream = $storage->getFile($filePath);
if ($fileStream === null) {
abort(404, 'Fichier introuvable.');
}
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
$mimeType = $this->getMimeType($extension);
$headers = [
'Content-Type' => $mimeType,
'Content-Disposition' => 'inline; filename="' . basename($path) . '"',
'Cache-Control' => 'public, max-age=31536000, immutable',
];
$size = $fileStream->getSize();
if ($size !== null) {
$headers['Content-Length'] = (string) $size;
}
return response()->stream(
function () use ($fileStream): void {
$resource = $fileStream->stream();
if (is_resource($resource)) {
fpassthru($resource);
}
},
200,
$headers
);
}
/**
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
*/
private function getMimeType(string $extension): string
{
return match ($extension) {
'png' => 'image/png',
'jpg', 'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'webp' => 'image/webp',
'pdf' => 'application/pdf',
'svg' => 'image/svg+xml',
'mp4' => 'video/mp4',
'webm' => 'video/webm',
'txt' => 'text/plain',
'csv' => 'text/csv',
default => 'application/octet-stream',
};
}
}

View file

@ -4,88 +4,33 @@ declare(strict_types=1);
namespace App\Http\Requests\Back\Products;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
class UpdateProductRequest extends StoreProductRequest
{
public function rules(): array
{
return array_merge(parent::rules(), [
'pdf' => [
'nullable',
$this->validatePdf(...),
],
'picture' => [
'required',
$this->validatePicture(...),
$this->hasFile('picture')
? Rule::imageFile()
->max(self::MAX_FILE_SIZE_KB)
->dimensions(
Rule::dimensions()
->width(self::PICTURE_WIDTH)
->height(self::PICTURE_HEIGHT)
)
: 'string',
],
'pdf' => [
'nullable',
$this->hasFile('pdf')
? Rule::file()
->max(self::MAX_FILE_SIZE_KB)
->types('pdf')
: 'string',
],
]);
}
private function validatePdf(string $attribute, mixed $value, \Closure $fail): void
{
$valuePath = match (true) {
is_string($value) => $value,
$value instanceof UploadedFile => $value->getPathname(),
default => null
};
if (is_string($valuePath)) {
$this->validateMaxFileSize($attribute, $valuePath, $fail);
ToolboxHelper::validatePdf(
$attribute,
$valuePath,
$fail
);
} elseif ($value !== null) {
$fail('Unexpected value for pdf');
}
}
private function validatePicture(string $attribute, mixed $value, \Closure $fail): void
{
$valuePath = match (true) {
is_string($value) => $value,
$value instanceof UploadedFile => $value->getPathname(),
default => null
};
if (is_string($valuePath)) {
$this->validateMaxFileSize($attribute, $valuePath, $fail);
ToolboxHelper::validatePicture(
$attribute,
$valuePath,
$fail,
(object) [
'minWidth' => self::PICTURE_WIDTH,
'maxWidth' => self::PICTURE_WIDTH,
'minHeight' => self::PICTURE_HEIGHT,
'maxHeight' => self::PICTURE_HEIGHT,
]
);
} elseif ($value !== null) {
$fail('Unexpected value for picture');
}
}
private function validateMaxFileSize(string $attribute, string $valuePath, \Closure $fail): void
{
$sizeInBytes = match (true) {
Storage::exists($valuePath) => Storage::size($valuePath),
File::exists($valuePath) => File::size($valuePath),
default => 0,
};
if (($sizeInBytes / 1024) > self::MAX_FILE_SIZE_KB) {
$fail(trans('validation.max.file', [
'attribute' => $this->attributes()[$attribute] ?? $attribute,
'max' => self::MAX_FILE_SIZE_KB,
]));
}
}
}

View file

@ -4,68 +4,25 @@ declare(strict_types=1);
namespace App\Http\Requests\Back\Recipes;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\Rule;
class UpdateRecipeRequest extends StoreRecipeRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Validation\Rule|array<mixed>|string>
*/
public function rules(): array
{
return array_merge(parent::rules(), [
'picture' => [
'required',
$this->validatePicture(...),
$this->hasFile('picture')
? Rule::imageFile()
->max(self::MAX_FILE_SIZE_KB)
->dimensions(
Rule::dimensions()
->width(static::PICTURE_WIDTH)
->height(static::PICTURE_HEIGHT)
)
: 'string',
],
]);
}
private function validatePicture(string $attribute, mixed $value, \Closure $fail): void
{
$valuePath = match (true) {
is_string($value) => $value,
$value instanceof UploadedFile => $value->getPathname(),
default => null
};
if (is_string($valuePath)) {
$this->validateMaxFileSize($attribute, $valuePath, $fail);
ToolboxHelper::validatePicture(
$attribute,
$valuePath,
$fail,
(object) [
'minWidth' => self::PICTURE_WIDTH,
'maxWidth' => self::PICTURE_WIDTH,
'minHeight' => self::PICTURE_HEIGHT,
'maxHeight' => self::PICTURE_HEIGHT,
]
);
} elseif ($value !== null) {
$fail('Unexpected value for picture');
}
}
private function validateMaxFileSize(string $attribute, string $valuePath, \Closure $fail): void
{
$sizeInBytes = match (true) {
Storage::exists($valuePath) => Storage::size($valuePath),
File::exists($valuePath) => File::size($valuePath),
default => 0,
};
if (($sizeInBytes / 1024) > self::MAX_FILE_SIZE_KB) {
$fail(trans('validation.max.file', [
'attribute' => $this->attributes()[$attribute] ?? $attribute,
'max' => self::MAX_FILE_SIZE_KB,
]));
}
}
}

View file

@ -1,529 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Lib\Helpers;
use App\Exceptions\Helpers\FileStorageOperationException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
/**
* This class is used to handle files in LDC Laravel stack
*
* * The storage strategy will be using date.
* The file name may contain sufix timestamp highresolution time (hrtime or microtime) if is duplicate.
* (function() { return time() . ' ' . Str::slug(microtime(true)) . ' ' . hrtime(true); })();
*
* posts/ - The model table name
* 10/ - Year
* 04/ - Month
* 19/ - Day
* 5f/ - First two letters of sha256 file hash
* black-cat-under-red-car.png - Slugified file name
* black-cat-under-red-car-286071690833400.png - Slugified file name that is duplicated
*
* The final path will be storage/modelfiles/posts/10/04/19/5f/black-cat-under-red-car-286071690833400.png
*
* ! No limits of file per folder will be handled.
*/
class FileStorageHelper
{
private const string STORAGE_PREFIX = 'storage/';
/**
* Remove all files from string attribute html that are stored in public
*
* @param string $publicStorageFilePath The file path from public directory.
* @return string The local storage path.
*/
public static function getFileFullPath(string $publicStorageFilePath): string
{
/** @var \Illuminate\Filesystem\FilesystemAdapter */
$disk = Storage::disk('public');
$path = Str::replace(self::STORAGE_PREFIX, '', \ltrim(\urldecode($publicStorageFilePath), '/'));
return $disk->path($path);
}
/**
* Destroy the file associate with the attribute.
*/
public static function removeFile(Model $model, string $attribute): void
{
$attributeValue = $model->getAttribute($attribute);
if (! is_scalar($attributeValue)) {
return;
}
$path = \ltrim(\urldecode(strval($attributeValue)), '/');
if (! str_starts_with($path, 'storage')) {
return;
}
$path = Str::replace(self::STORAGE_PREFIX, '', $path);
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
}
/**
* Destroy the file associate with the attribute old value (before updated to DB).
*/
public static function removeOldFile(Model $model, string $attribute, bool $onlyIfUpdated = true): void
{
$originalValue = ToolboxHelper::getOriginal($model, $attribute);
// * Ignore If removal has to be done only if the field has changed and it actually hasnt.
if ($onlyIfUpdated && $model->{$attribute} === $originalValue) {
return;
}
if (! is_string($originalValue)) {
return;
}
$originalPath = \ltrim(\urldecode($originalValue), '/');
if (! str_starts_with($originalPath, 'storage')) {
return;
}
$originalPath = Str::replace(self::STORAGE_PREFIX, '', $originalPath);
if (Storage::disk('public')->exists($originalPath)) {
Storage::disk('public')->delete($originalPath);
}
}
/**
* Store a file using optimized storage strategy
*
* You can use filename param to overload file name.
*
* @param Model $model The model that will hold the picture.
* @param UploadedFile|\SplFileInfo|string $file The file, will just return itself is string.
* @param bool $slugify Force filename slugification.
* @param string|null $filename This string may be used to store the file.
* @param bool $private To store the file in a private space.
*
* @throws FileStorageOperationException If file copy fails.
*
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
*/
public static function storeFile(
Model $model,
UploadedFile | \SplFileInfo | string | null $file,
bool $slugify = false,
?string $filename = null,
bool $private = false
): string {
// phpcs:enable
$tableName = $model->getTable();
if ($file instanceof UploadedFile) {
return self::storeUploadedFile($file, $tableName, $slugify, $filename, $private);
}
if ($file instanceof \SplFileInfo) {
return self::storeSplFileInfo($file, $tableName, $slugify, $filename, $private);
}
return (string) $file;
}
private static function storeUploadedFile(
UploadedFile $file,
string $tableName,
bool $slugify,
?string $filename,
bool $private
): string {
$filename = $filename ?: $file->getClientOriginalName();
$filename = $slugify ? self::slugifyFileName($filename) : $filename;
$disk = $private ? 'private' : 'public';
$newPath = str_replace(
storage_path("app/{$disk}"),
'',
self::prepareMoveFile($tableName, $filename, $private)
);
$directory = pathinfo($newPath, \PATHINFO_DIRNAME);
$basename = pathinfo($newPath, \PATHINFO_BASENAME);
if (! $private) {
$file->storePubliclyAs(
$directory,
$basename,
['disk' => $disk]
);
} else {
$file->storeAs(
$directory,
$basename,
['disk' => $disk]
);
}
return "storage{$newPath}";
}
private static function storeSplFileInfo(
\SplFileInfo $file,
string $tableName,
bool $slugify,
?string $filename,
bool $private
): string {
$filename = $filename ?: $file->getBaseName();
$filename = $slugify ? self::slugifyFileName($filename) : $filename;
$newPath = self::prepareMoveFile($tableName, $filename, $private);
if (! File::copy($file->getRealPath(), $newPath)) {
throw FileStorageOperationException::copyFailed($file->getRealPath(), $newPath);
}
if ($private) {
return \ltrim(str_replace(\storage_path('app/private'), '/storage/app/private', $newPath), '/');
}
return \ltrim(str_replace(\storage_path('app/public'), '/storage', $newPath), '/');
}
/**
* Store all files from string attribute html
* If oldHtmlString is passed, a diff is done with new and old files
* to keep only files that are present in the new html string.
*
* @param Model $model The model that will hold the picture.
* @param string|null $htmlString The html string to parse and modify files.
* @param string|null $oldHtmlString The old html string with alreadyParsed
* files using storeModelFilesFromHtml.
* @return string|null Html with files pathes replaced using storage strategy.
*/
public static function storeModelFilesFromHtml(
Model $model,
?string $htmlString,
?string $oldHtmlString = null
): ?string {
if (is_null($htmlString)) {
return null;
}
Collection::make(self::onlyUploadedFilesWithFileManager(self::findFilesInHtml($htmlString)))
->each(function (string $path) use ($model, &$htmlString): void {
/** @var \Illuminate\Filesystem\FilesystemAdapter */
$disk = Storage::disk('private');
$fileInfo = new \SplFileInfo($disk->path(
ToolboxHelper::mbReplaceSingle('/uploads/', '', \urldecode($path))
));
$htmlString = ToolboxHelper::mbReplaceSingle(
$path,
'/' . self::storeFile($model, $fileInfo, true),
$htmlString
);
});
if ($oldHtmlString) {
self::removeOldModelFilesFromHtml($htmlString, $oldHtmlString);
}
return $htmlString;
}
/**
* Remove all old files from string attribute html that are stored in public that
* are nove present anymore on new html string
*
* @param string $newHtmlString The html string with alreadyParsed files using storeModelFilesFromHtml.
* @param string $oldHtmlString The old html string with alreadyParsed files using storeModelFilesFromHtml.
*/
public static function removeOldModelFilesFromHtml(string $newHtmlString, string $oldHtmlString): void
{
self::removeOldFiles(self::findFilesInHtml($oldHtmlString), self::findFilesInHtml($newHtmlString));
}
/**
* Remove all old files that are stored in public that
* are not present anymore on new array files
*
* @param string[] $oldFiles The old array files.
* @param string[] $newFiles The new array files.
*/
public static function removeOldFiles(array $oldFiles, array $newFiles): void
{
$oldFiles = Collection::make(self::onlyUploadedFilesWithFileStorageHelper($oldFiles));
$filesToKeep = Collection::make(self::onlyUploadedFilesWithFileStorageHelper($newFiles));
$filesToRemove = $oldFiles->diff($filesToKeep);
$filesToRemove->each(function (string $publicStorageFilePath): void {
$path = Str::replace(self::STORAGE_PREFIX, '', \ltrim(\urldecode($publicStorageFilePath), '/'));
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
});
}
/**
* Remove all files from string attribute html that are stored in public
*
* @param string $htmlString The html string with alreadyParsed files using storeModelFilesFromHtml.
*/
public static function removeModelFilesOfHtml(string $htmlString): void
{
$filesToRemove = Collection::make(self::onlyUploadedFilesWithFileStorageHelper(self::findFilesInHtml($htmlString)));
$filesToRemove->each(function (string $publicStorageFilePath): void {
$path = Str::replace(self::STORAGE_PREFIX, '', \ltrim(\urldecode($publicStorageFilePath), '/'));
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
});
}
/**
* Find all occurence of files in html
*
* @param string $html The html string to parse and find files.
* @return string[] The array of files found in html.
*/
public static function findFilesInHtml(string $html): array
{
preg_match_all(
'/(?:href|src|url)="([^"]*)"/Ui',
$html,
$matches
);
return Collection::make($matches[1])->unique()->filter()->values()->all();
}
/**
* Filter array to get only uploaded files that exists
* on disk 'public' (using helper storage strategy)
*
* @param string[] $urls The array of urls to filter
* @return string[] The filtered array with only uploaded files that exists on disk 'public
*/
public static function onlyUploadedFilesWithFileStorageHelper(array $urls): array
{
return Collection::make($urls)->unique()
// * Filter to get only /uploads and using app url or empty
->filter(function (string $url) {
$path = (string) (\parse_url($url, \PHP_URL_PATH) ?? '');
return str_starts_with(\ltrim($path, '/'), 'storage/modelfiles');
})->filter(function (string $url) {
$path = (string) (\parse_url($url, \PHP_URL_PATH) ?? '');
return Storage::disk('public')
->exists(Str::replace(self::STORAGE_PREFIX, '', \ltrim(\urldecode($path), '/')));
})->all();
}
/**
* Filter array to get only uploaded files that exist on disk 'private'
*
* @param string[] $urls The array of urls to filter
* @return string[] The filtered array
*/
private static function onlyUploadedFilesWithFileManager(array $urls): array
{
$appUrl = Config::string('app.url');
if (empty($appUrl)) {
throw new \UnexpectedValueException('App URL must be set in config to filter uploaded files with file manager');
}
$appHost = parse_url((string) $appUrl, PHP_URL_HOST);
return Collection::make($urls)->unique()->filter(function (string $url) use ($appHost) {
$host = parse_url($url, PHP_URL_HOST);
// 1. Validation du domaine (Doit être identique à l'app ou être un chemin relatif)
if ($host !== null && $host !== $appHost) {
return false;
}
// 2. Extraction et nettoyage du chemin
$path = ltrim(urldecode((string) parse_url($url, PHP_URL_PATH)), '/');
// 3. Vérification du préfixe 'uploads/' et existence sur le disque
if (! str_starts_with($path, 'uploads/')) {
return false;
}
// On retire 'uploads/' pour tester l'existence sur le disque 'private'
$diskPath = substr($path, strlen('uploads/'));
return Storage::disk('private')->exists($diskPath);
})->values()->all();
}
/**
* Prepare storage path and return
* the file full path
*
* @param string $tableName Model table name.
* @param string $filename The basename for the file.
* @param bool $private May the file be stored in a private dir.
*/
private static function prepareMoveFile(string $tableName, string $filename, bool $private = false): string
{
// * Security filter
$filename = \htmlspecialchars($filename);
// * Security filter + beautifier
$filename = self::sanitizeFileName($filename);
// * Slugify filename
$ext = \pathinfo($filename, \PATHINFO_EXTENSION);
$filename = Str::slug(\pathinfo($filename, \PATHINFO_FILENAME)) .
(\strlen($ext) ? ".{$ext}" : '');
$folderPath = self::getStoragePath(
$private ? 'app/private/modelfiles' : 'app/public/modelfiles',
$tableName,
$filename
);
$filename = self::getFileUniqueName($folderPath, $filename);
return "{$folderPath}/{$filename}";
}
/**
* Create sub folders to store files using pattern
* storage/modelfiles/posts/10/04/19/5f
* year/month/day/sha256 first 2 letters
*/
private static function getStoragePath(string $storage_dir, string $table, string $filename): string
{
$filenameHash = \hash('sha256', $filename);
$pathFolder = \storage_path(sprintf(
'%s/%s/%s/%s/%s/%s',
$storage_dir,
$table,
gmdate('y'),
gmdate('m'),
gmdate('d'),
substr($filenameHash, 0, 2)
));
if (! File::exists($pathFolder)) {
File::makeDirectory($pathFolder, 0755, true);
}
return $pathFolder;
}
/**
* Get unique filename if the path is already occupied
*
* @throws FileStorageOperationException If a unique filename cannot be obtained.
*/
private static function getFileUniqueName(string $folderPath, string $filename): string
{
$attempts = 0;
$maxAttempts = 20;
while (File::exists("{$folderPath}/{$filename}")) {
if ($attempts++ >= $maxAttempts) {
throw FileStorageOperationException::cannotGenerateUniqueFilename($folderPath, $filename);
}
$filename = Str::of(pathinfo($filename, \PATHINFO_FILENAME))
->append(Str::random(8) . '-')
->append('.')
->append(pathinfo($filename, \PATHINFO_EXTENSION))
->toString();
}
return $filename;
}
/**
* Slugify the filename
*/
public static function slugifyFileName(string $filename): string
{
return Str::slug(pathinfo($filename, \PATHINFO_FILENAME)) . '.' . pathinfo($filename, \PATHINFO_EXTENSION);
}
/**
* Sanitize File name for uploaded files
*
* @param string $filename The original uploaded client file name.
* @param bool $beautify Beautify the filename.
* @return string The sanitized file name.
*/
public static function sanitizeFileName(string $filename, bool $beautify = true): string
{
$filename = preg_replace('/[<>:"\/\\|?*\x00-\x1F\x7F\xA0\xAD#\[\]@!$&\'()+,;={}^~`]/u', '-', $filename) ?? $filename;
// * Avoids '.' '..' or '.hiddenFiles' .
$filename = (string) Str::of($filename)->ltrim('.-');
// * Optional beautification
if ($beautify) {
$filename = self::beautifyFilename($filename);
}
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
/** @var string */
$extension = pathinfo($filename, \PATHINFO_EXTENSION);
/** @var string */
$filename = pathinfo($filename, \PATHINFO_FILENAME);
$encoding = mb_detect_encoding($filename);
$encoding = $encoding ?: null;
return \mb_strcut(
$filename,
0,
255 - (! empty($extension) ? strlen($extension) + 1 : 0),
$encoding
) . (! empty($extension) ? ".$extension" : '');
}
/**
* Beautify a filename
*/
private static function beautifyFilename(string $filename): string
{
// Reduce consecutive characters.
$filename = preg_replace([
// * "file name.zip" becomes 'file-name.zip'
'/ +/',
// * "file___name.zip" becomes 'file-name.zip'
'/_+/',
// * "file---name.zip" becomes 'file-name.zip'
'/-+/',
], '-', $filename) ?? $filename;
$filename = preg_replace([
// * "file--.--.-.--name.zip" becomes "file.name.zip"
'/-*\.-*/',
// * "file...name..zip" becomes "file.name.zip"
'/\.{2,}/',
], '.', $filename) ?? $filename;
// Lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 .
$encoding = mb_detect_encoding($filename);
$filename = mb_strtolower($filename, $encoding ?: 'UTF-8');
// * ".file-name.-" becomes "file-name"
$filename = trim($filename, '.-');
return $filename;
}
/**
* Remove all model files for the given Model.
*/
public static function removeModelFiles(Model $model): void
{
$tableName = $model::query()->getModel()->getTable();
if (! empty(Storage::disk('public')->allFiles("modelfiles/{$tableName}"))) {
Storage::disk('public')->deleteDirectory("modelfiles/{$tableName}");
}
if (! empty(Storage::disk('private')->allFiles("modelfiles/{$tableName}"))) {
Storage::disk('private')->deleteDirectory("modelfiles/{$tableName}");
}
}
public static function isMimeType(string $mimeType, \SplFileInfo $file): bool
{
if (! $file->getRealPath()) {
return false;
}
$actualMime = File::mimeType($file->getRealPath());
return $actualMime ? Str::is($mimeType, $actualMime) : false;
}
}

View file

@ -4,41 +4,12 @@ declare(strict_types=1);
namespace App\Lib\Helpers;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use Symfony\Component\Finder\SplFileInfo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class ToolboxHelper extends ToolboxHelperCore
{
/**
* @param array<int|string, mixed> $array1
* @param array<int|string, mixed> $array2
* @return array<int|string, mixed>
*/
public static function arrayMergeRecursiveDistinct(array &$array1, array &$array2): array
{
$merged = $array1;
foreach ($array2 as $key => &$value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
$merged[$key] = self::arrayMergeRecursiveDistinct($merged[$key], $value);
} else {
$merged[$key] = $value;
}
}
return $merged;
}
/**
* Strip scheme (https) on oembed urls
* Only embed allowed are for MP4 self hosted videos right now
@ -72,8 +43,8 @@ class ToolboxHelper extends ToolboxHelperCore
(string) str_replace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id),
], [
(string) str_replace('.', '\.', "{$field}.unique") => trans(
'crud.libs.toolbox.assertFieldIsUnique',
['attribute' => $field, 'value' => is_array($value) ? json_encode($value) : $value]
'validation.unique',
['attribute' => $field]
),
])->validate();
@ -83,326 +54,9 @@ class ToolboxHelper extends ToolboxHelperCore
$field => Rule::unique($table)->where($query)->ignore($id),
], [
$field . '.unique' => trans(
'crud.libs.toolbox.assertFieldIsUnique',
['attribute' => $field, 'value' => is_array($value) ? json_encode($value) : $value]
'validation.unique',
['attribute' => $field]
),
])->validate();
}
/**
* Assert That no Back Office url is present on txt
*
* @throws \Illuminate\Validation\ValidationException If url is a bo url.
*/
public static function assertNoInternalBoUrls(string $field, string $text): string
{
$routes = Route::getRoutes();
return self::replaceUrlsInText($text, function (string $url) use ($routes, $field): void {
$request = Request::create($url);
if (! self::isInternalHost($url)) {
return;
}
if (trim($routes->match($request)->getPrefix() ?? '', '/') === 'bo') {
throw ValidationException::withMessages([
$field => trans(
'crud.libs.toolbox.assertNoInternalBoUrls',
['attribute' => $field]
),
]);
}
});
}
/**
* Assert That only external url is present on txt
*
* @throws \Illuminate\Validation\ValidationException If url is a bo url.
*/
public static function assertNoInternalUrls(string $field, string $text): string
{
self::assertNoInternalBoUrls($field, $text);
$routes = Route::getRoutes();
return self::replaceUrlsInText($text, function (string $url) use ($routes, $field): void {
$request = Request::create($url);
$routes->match($request);
if (! self::isInternalHost($url)) {
return;
}
throw ValidationException::withMessages([
$field => trans(
'crud.libs.toolbox.assertNoInternalUrls',
['attribute' => $field, 'appname' => Config::string('app.name')]
),
]);
});
}
private static function isInternalHost(string $url): bool
{
return \parse_url((string) Config::string('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST);
}
private static function replaceUrlsInText(string $text, callable $onMatchedUrl): string
{
$result = preg_replace_callback(
// phpcs:ignore Generic.Files.LineLength.TooLong
'/(?P<url>(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@%._+~#=]{2,256}\.[a-z]{2,6}\b[-a-zA-Z0-9@:%_.+~#?&\/=]*)/',
function (array $matches) use ($onMatchedUrl): string {
$match = collect($matches)->first() ?? '';
$url = (string) $match;
try {
$onMatchedUrl($url);
} catch (NotFoundHttpException) {
return (string) $match;
}
return (string) $match;
},
$text
);
return is_string($result) ? $result : $text;
}
/**
* Get original polyfill with autotranslate behavior
*/
public static function getOriginal(Model $model, string $attribute): mixed
{
if (
\in_array('Spatie\Translatable\HasTranslations', \class_uses_recursive($model)) && // @phpstan-ignore-next-line
$model->isTranslatableAttribute($attribute)
) {
// @phpstan-ignore-next-line
return $model->getTranslation(
$attribute,
// @phpstan-ignore-next-line
$model->getLocale(),
// @phpstan-ignore-next-line
$model->useFallbackLocale()
);
}
return $model->getOriginal($attribute);
}
/**
* Generates an array from a dot separated string
*
* @param string $path The dot separated string to convert to an array.
* @param mixed $value The value to set at the end of the array.
* @param string $separator The separator used in the path (default is '.').
* @return array<string,mixed> The generated array.
*/
public static function dotStringToNestedArray(string $path, mixed $value, string $separator = '.'): array
{
throw_if($separator === '', \InvalidArgumentException::class, 'Separator cannot be an empty string.');
$arr = $value;
$keys = explode($separator, $path);
$keys = array_reverse($keys);
foreach ($keys as $key) {
$arr = [$key => $arr];
}
return $arr;
}
/**
* Validate pdf
*
* @param callable(string):void $fail A callback that should be called if the validation fails.
*
* @throws \Illuminate\Validation\ValidationException If the pdf is invalid.
*/
public static function validatePdf(string $attribute, ?string $value, callable $fail): void
{
if ($value === null) {
return;
}
if (! ($useStorage = Storage::exists($value)) && ! File::exists($value)) {
$fail(trans('validation.custom.has_picture.file_does_not_exist', [
'attribute' => $attribute,
]));
return;
}
if (self::getUploadedFileMimeType($value, $useStorage) !== 'application/pdf') {
$fail(trans('validation.mimetypes', [
'attribute' => $attribute,
'values' => 'application/pdf',
]));
}
}
/**
* Validate picture
*
* @param callable(string):void $fail A callback that should be called if the validation fails.
* @param object{
* minWidth: int,
* maxWidth: int,
* minHeight: int,
* maxHeight: int
* }&\stdClass $sizes An object containing the minimum and maximum width and height for the picture.
*
* @throws \Illuminate\Validation\ValidationException If the picture is invalid.
*/
public static function validatePicture(string $attribute, ?string $value, callable $fail, object $sizes): void
{
if ($value === null) {
return;
}
if (! ($useStorage = Storage::exists($value)) && ! File::exists($value)) {
$fail(trans('validation.custom.has_picture.file_does_not_exist', [
'attribute' => $attribute,
]));
return;
}
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
if (
! \in_array(self::getUploadedFileMimeType($value, $useStorage), [
'image/jpeg',
'image/jpg',
'image/png',
'image/gif',
])
) {
$fail(trans('validation.mimetypes', [
'attribute' => $attribute,
'values' => 'image/jpeg, image/jpg, image/png, image/gif',
]));
}
if (! ($dimensions = \getimagesize($fileFullPath))) {
$fail(trans('validation.dimensions', [
'attribute' => $attribute,
]));
return;
}
$width = intval($dimensions[0]);
$height = intval($dimensions[1]);
$xMessage = trans('validation.custom.has_picture.width_between', [
'attribute' => $attribute,
'min' => "{$sizes->minWidth}px",
'max' => "{$sizes->maxWidth}px",
]);
if ($sizes->minWidth === $sizes->maxWidth) {
$xMessage = trans('validation.custom.has_picture.width_equal', [
'attribute' => $attribute,
'value' => "{$sizes->minWidth}px",
]);
}
$yMessage = trans('validation.custom.has_picture.height_between', [
'attribute' => $attribute,
'min' => "{$sizes->minHeight}px",
'max' => "{$sizes->maxHeight}px",
]);
if ($sizes->minHeight === $sizes->maxHeight) {
$yMessage = trans('validation.custom.has_picture.height_equal', [
'attribute' => $attribute,
'value' => "{$sizes->minHeight}px",
]);
}
if (($width < $sizes->minWidth) || ($width > $sizes->maxWidth)) {
$fail($xMessage);
}
if (($height < $sizes->minHeight) || ($height > $sizes->maxHeight)) {
$fail($yMessage);
}
}
/**
* Fetch class list from a specific namespace
*
* @return array<string> An array of classe namespaces
*/
public static function getClassesUsingNamespace(string $namespace): array
{
return collect(File::files(\app_path((string) Str::of($namespace)->replaceFirst('\App', ''))))
->filter(fn (SplFileInfo $splFileInfo) => $splFileInfo->getExtension() === 'php')
->map(fn (SplFileInfo $splFileInfo) => (string) Str::of($splFileInfo->getBasename())
->replace('.' . $splFileInfo->getExtension(), '')->prepend("{$namespace}\\"))->all();
}
/**
* Get all classes from a specific namespace that implement a specific interface
*
* @return array<string> An array of classe namespaces
*/
public static function getClassesUsingInterface(string $namespace, string $interface): array
{
return Arr::where(
static::getClassesUsingNamespace($namespace),
fn (string $class_namespace) => \collect(class_implements($class_namespace, true) ?: [])->filter()
->contains(fn (string $class_interface) => $class_interface === $interface)
);
}
/**
* Convert Hex color to RGB
*
* @return int[]
*/
public static function hexToRgb(string $hexcolor): array
{
$hexcolor = (string) str($hexcolor)->replaceStart('#', '');
$r = (int) hexdec(substr($hexcolor, 0, 2));
$g = (int) hexdec(substr($hexcolor, 2, 2));
$b = (int) hexdec(substr($hexcolor, 4, 2));
return [$r, $g, $b];
}
/**
* Get text color contrast for a hex background color
*
* @return string "black" or "white"
*/
public static function getContrastYiq(string $hexcolor): string
{
[$r, $g, $b] = self::hexToRgb($hexcolor);
$yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($yiq >= 128) ? 'black' : 'white';
}
/**
* Convert an HTML string to plain text with proper word spacing.
*
* Replaces HTML tags with spaces, strips remaining tags,
* normalises whitespace and trims the result.
*
* @param string|null $html The HTML content to convert.
* @param int|null $limit Optional character limit (uses Str::limit).
*/
public static function htmlToText(?string $html, ?int $limit = null): string
{
if ($html === null || $html === '') {
return '';
}
$text = strip_tags((string) preg_replace('/<[^>]*>/', ' ', $html));
$text = trim((string) preg_replace('/\s+/', ' ', $text));
if ($limit !== null) {
return Str::limit($text, $limit);
}
return $text;
}
}

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Models;
use App\Casts\FilePathCast;
use App\Casts\NutritionalValuesCast;
use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use Domain\Models\ValueObjects\Entities\ProductId;
use Domain\Models\ValueObjects\Products\BreedingMethod;
@ -28,6 +28,7 @@ use Uwil\LaravelBackend\Traits\Models\HasActivityLog;
use Uwil\LaravelBackend\Traits\Models\HasCache;
use Uwil\LaravelBackend\Traits\Models\HasModelNaming;
use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
use Uwil\Storage\Facades\StorageService;
// phpcs:disable Generic.Files.LineLength.TooLong
@ -35,7 +36,7 @@ use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
* @property string $id
* @property string $seo_title
* @property string $seo_description
* @property string $picture
* @property \Uwil\Storage\Lib\ValueObjects\StorageFilePath $picture
* @property string $picture_alt
* @property string $picture_title
* @property string $name
@ -53,7 +54,7 @@ use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
* @property string $conservation_before_opening
* @property string|null $conservation_after_opening
* @property \Domain\Models\ValueObjects\Products\NutritionalValues|null $nutritional_values Domain\Models\ValueObjects\NutritionalValues
* @property string|null $pdf
* @property \Uwil\Storage\Lib\ValueObjects\StorageFilePath|null $pdf
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
@ -68,6 +69,7 @@ use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product whereJsonContainsLocales(string $column, array $locales, ?mixed $value, string $operand = '=')
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product whereLocale(string $column, string $locale)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product whereLocales(string $column, array $locales)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product whereTranslationLike(array|string $columns, string $search, ?array $locales = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Product withoutTrashed()
*
@ -120,6 +122,8 @@ class Product extends Model implements TranslatableModel
'businesses' => AsEnumCollection::class . ':' . Business::class,
'formats' => AsEnumCollection::class . ':' . ProductFormat::class,
'nutritional_values' => NutritionalValuesCast::class,
'picture' => FilePathCast::class,
'pdf' => FilePathCast::class,
];
public function newUniqueId(): string
@ -140,8 +144,10 @@ class Product extends Model implements TranslatableModel
});
static::deleting(function (self $model): void {
FileStorageHelper::removeFile($model, 'picture');
FileStorageHelper::removeFile($model, 'pdf');
StorageService::remove($model->picture);
if ($model->pdf) {
StorageService::remove($model->pdf);
}
});
}
@ -165,11 +171,7 @@ class Product extends Model implements TranslatableModel
{
self::assertNameIsUnique($model->name, $model->id);
$model->slug = Str::slug($model->name);
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
if ($model->pdf) {
$model->pdf = FileStorageHelper::storeFile($model, $model->pdf, true);
}
$model->slug = Str::slug($model->name);
}
private static function assertNameIsUnique(?string $name, string | int | null $id = null): void

View file

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Models;
use App\Lib\Helpers\FileStorageHelper;
use App\Casts\FilePathCast;
use App\Lib\Helpers\ToolboxHelper;
use Domain\Models\ValueObjects\Entities\RecipeId;
use Domain\Models\ValueObjects\Products\ProductCategory;
@ -25,6 +25,7 @@ use Uwil\LaravelBackend\Traits\Models\HasActivityLog;
use Uwil\LaravelBackend\Traits\Models\HasCache;
use Uwil\LaravelBackend\Traits\Models\HasModelNaming;
use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
use Uwil\Storage\Facades\StorageService;
// phpcs:disable Generic.Files.LineLength.TooLong
@ -34,7 +35,7 @@ use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
* @property string $id
* @property string $seo_title
* @property string $seo_description
* @property string $picture
* @property \Uwil\Storage\Lib\ValueObjects\StorageFilePath $picture
* @property string $picture_alt
* @property string $picture_title
* @property string $name
@ -62,6 +63,7 @@ use Uwil\LaravelBackend\Traits\Models\HasUwilImages;
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe whereJsonContainsLocales(string $column, array $locales, ?mixed $value, string $operand = '=')
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe whereLocale(string $column, string $locale)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe whereLocales(string $column, array $locales)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe whereTranslationLike(array|string $columns, string $search, ?array $locales = null)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Recipe withoutTrashed()
*
@ -106,6 +108,7 @@ class Recipe extends Model implements TranslatableModel
'consomption_time' => ConsumptionTime::class,
'inspiration' => Inspiration::class,
'season' => Season::class,
'picture' => FilePathCast::class,
];
public function newUniqueId(): string
@ -126,7 +129,7 @@ class Recipe extends Model implements TranslatableModel
});
static::deleting(function (self $model): void {
FileStorageHelper::removeFile($model, 'picture');
StorageService::remove($model->picture);
});
}
@ -150,8 +153,7 @@ class Recipe extends Model implements TranslatableModel
{
self::assertNameIsUnique($model->name, $model->id);
$model->slug = Str::slug($model->name);
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
$model->slug = Str::slug($model->name);
}
private static function assertNameIsUnique(?string $name, string | int | null $id = null): void

View file

@ -6,7 +6,7 @@ use App\Providers\AppServiceProvider;
use App\Providers\AuthServiceProvider;
use App\Providers\RouteServiceProvider;
use App\Providers\ViewServiceProvider;
use Uwil\AdminSecure\Laravel\AdminSecureServiceProvider;
use Uwil\LaravelAdminSecure\AdminSecureServiceProvider;
use Uwil\LaravelBackend\BackendServiceProvider;
use Uwil\LaravelCommon\CommonServiceProvider;
use Uwil\LaravelDynamicPages\DynamicPagesServiceProvider;

View file

@ -10,21 +10,23 @@
"license": "MIT",
"require": {
"php": "^8.5",
"scaler-tech/laravel-saml2": "^2.5",
"diglactic/laravel-breadcrumbs": "^10.0",
"inertiajs/inertia-laravel": "^3.0",
"laravel/framework": "^13.0",
"laravel/scout": "^11.3",
"laravel/telescope": "^5.7",
"laravel/tinker": "^3.0",
"league/flysystem-aws-s3-v3": "*",
"meilisearch/meilisearch-php": "^1.16",
"monolog/monolog": "^3.0",
"psr/log": "^3.0",
"scaler-tech/laravel-saml2": "^2.5",
"sentry/sentry-laravel": "^4.25",
"tightenco/ziggy": "^2.5",
"uwil/laravel-admin-secure": "^6.0.1",
"uwil/k8s-laravel": "^3.0",
"uwil/admin-secure-laravel": "^6.0",
"uwil/laravel-dynamic-pages": "^5.0"
"uwil/laravel-dynamic-pages": "^5.0",
"uwil/storage-laravel": "^1.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.7",

1443
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
return [
'default' => 's3',
'eligibleDisks' => [
's3',
],
'prefix' => env('STORAGE_SERVICE_PREFIX', 'media'),
'allowedExtensions' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'txt', 'doc', 'docx', 'csv', 'mp4', 'webm'],
];

View file

@ -0,0 +1,147 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
use Uwil\Storage\Facades\StorageService;
return new class () extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$this->migrateTableFiles('products', ['picture', 'pdf']);
$this->migrateTableFiles('recipes', ['picture']);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// One-way migration.
}
/**
* @param string[] $columns
*/
private function migrateTableFiles(string $tableName, array $columns): void
{
if (! Schema::hasTable($tableName)) {
return;
}
DB::table($tableName)
->select(array_merge(['id'], $columns))
->orderBy('id')
->each(fn (object $record) => $this->migrateRecord(
$tableName,
$record,
$columns
));
}
/**
* @param string[] $columns
*/
private function migrateRecord(string $tableName, object $record, array $columns): void
{
$updates = [];
foreach ($columns as $column) {
$newPath = $this->migrateColumnFile(
$tableName,
$column,
(string) $record->id,
$record->$column
);
if ($newPath !== null) {
$updates[$column] = $newPath;
}
}
if ($updates !== []) {
DB::table($tableName)
->where('id', $record->id)
->update($updates);
}
}
private function migrateColumnFile(
string $tableName,
string $column,
string $recordId,
mixed $rawPath
): ?string {
if (! is_string($rawPath) || trim($rawPath) === '') {
return null;
}
$cleanPath = ltrim($rawPath, '/');
if (! str_starts_with($cleanPath, 'storage/')) {
return null;
}
$resolvedFilePath = $this->resolveLocalFilePath($cleanPath);
if ($resolvedFilePath === null) {
Log::warning("Migration: file not found on disk for {$tableName}.{$column} (ID: {$recordId}): {$rawPath}");
return null;
}
return $this->storeLocalFile(
$tableName,
$column,
$recordId,
$rawPath,
$resolvedFilePath
);
}
private function storeLocalFile(string $tableName, string $column, string $recordId, string $rawPath, string $filePath): ?string
{
try {
$splFile = new \SplFileObject($filePath);
$newStoragePath = StorageService::storeFile($splFile);
Log::info("Migration: migrated {$tableName}.{$column} for ID {$recordId}: {$rawPath} -> {$newStoragePath->value}");
return $newStoragePath->value;
} catch (\Throwable $e) {
Log::error("Migration: failed to migrate file for {$tableName}.{$column} (ID: {$recordId}): "
. $e->getMessage(), [
'exception' => $e,
'path' => $filePath,
]);
return null;
}
}
private function resolveLocalFilePath(string $cleanPath): ?string
{
$subPath = substr($cleanPath, strlen('storage/'));
$candidates = [
storage_path('app/public/' . $subPath),
public_path($cleanPath),
storage_path('app/private/' . $subPath),
storage_path('app/' . $subPath),
base_path($cleanPath),
];
foreach ($candidates as $candidate) {
if (is_file($candidate) && is_readable($candidate)) {
return $candidate;
}
}
return null;
}
};

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,57 @@
[
{
"label": {
"fr": "Page home"
},
"view": "front/Pages/Home",
"config": {
"fr": [
{
"key": "string_title",
"type": 1,
"label": "Titre",
"order": 1,
"validation": "required|string|between:3,255"
}
]
}
},
{
"label": {
"fr": "Legals"
},
"view": "front/Pages/LegalPage",
"config": {
"fr": [
{
"key": "string_seo_title",
"type": 1,
"label": "SEO Title",
"order": 1,
"validation": "required|string|between:3,255"
},
{
"key": "string_seo_description",
"type": 1,
"label": "SEO Description",
"order": 2,
"validation": "required|string|between:3,255"
},
{
"key": "string_description",
"type": 1,
"label": "Description",
"order": 3,
"validation": "required|string|between:3,255"
},
{
"key": "wysiwyg_contenu",
"type": 3,
"label": "Contenu",
"order": 4,
"validation": "required|string|between:15,8000"
}
]
}
}
]

View file

@ -158,6 +158,7 @@ return [
'uppercase' => 'Le champ :attribute doit être en majuscules.',
'url' => 'Le format de l\'URL de :attribute n\'est pas valide.',
'uuid' => 'Le champ :attribute doit être un UUID valide.',
'file_exists' => 'Le fichier du champ :attribute n\'existe pas.',
'attributes' => [
'address' => 'adresse',
'affiliate_url' => 'URL d\'affiliation',
@ -243,17 +244,17 @@ return [
'name' => 'nom',
'national_code' => 'code national',
'number' => 'numéro',
'nutritional_values' => 'valeurs nutritionnelles',
'nutritional_refWeightG' => 'poids de référence (g)',
'nutritional_kj' => 'kJ',
'nutritional_kcal' => 'kcal',
'nutritional_fatG' => 'graisses (g)',
'nutritional_satFatG' => 'acides gras saturés (g)',
'nutritional_carbG' => 'glucides (g)',
'nutritional_sugarG' => 'sucres (g)',
'nutritional_fatG' => 'graisses (g)',
'nutritional_fiberG' => 'fibres (g)',
'nutritional_kcal' => 'kcal',
'nutritional_kj' => 'kJ',
'nutritional_proteinG' => 'protéines (g)',
'nutritional_refWeightG' => 'poids de référence (g)',
'nutritional_saltG' => 'sel (g)',
'nutritional_satFatG' => 'acides gras saturés (g)',
'nutritional_sugarG' => 'sucres (g)',
'nutritional_values' => 'valeurs nutritionnelles',
'nutritional_values_unit' => 'unité des valeurs nutritionnelles',
'password' => 'mot de passe',
'password_confirmation' => 'confirmation du mot de passe',

View file

@ -13,7 +13,7 @@ parameters:
ignoreErrors:
-
message: '#has PHPDoc tag @method for method where.*Locales\(\) parameter \#2 \$[a-zA-Z0-9_]+ with no value type specified in iterable type array#'
message: '#has PHPDoc tag @method for method (where.*Locales|whereTranslationLike)\(\) parameter \#[0-9]+ \$[a-zA-Z0-9_]+ with no value type specified in iterable type array#'
paths:
- app/Models/*
-

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -25,21 +25,23 @@ export default function BreadcrumbsBase({
<BreadcrumbList>
{breadcrumbs.map((breadcrumb, breadcrumbIndex) => (
<ul
key={breadcrumb.url}
className="flex flex-wrap items-center gap-1 break-words sm:gap-2.5"
key={`${breadcrumb.url}-${breadcrumbIndex}`}
className="flex flex-wrap items-center gap-1 break-words [overflow-wrap:anywhere] sm:gap-2.5 min-w-0 max-w-full"
>
{breadcrumbIndex >= 1 && <BreadcrumbSeparator />}
<BreadcrumbItem className="text-primary-foreground/70">
<BreadcrumbItem className="text-primary-foreground/70 min-w-0 break-words [overflow-wrap:anywhere] inline">
{breadcrumbIndex !== breadcrumbs.length - 1 &&
breadcrumb.url ? (
<Link
href={breadcrumb.url}
className="rounded-md text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
className="rounded-md text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 break-words [overflow-wrap:anywhere]"
>
{breadcrumb.title}
</Link>
) : (
breadcrumb.title
<span className="break-words [overflow-wrap:anywhere]">
{breadcrumb.title}
</span>
)}
</BreadcrumbItem>
</ul>

View file

@ -23,8 +23,7 @@ export default function Image({
}: Readonly<ThemeImageProps>) {
const customShape =
shape === imageShapes.SQUARE ? "rounded-none" : "rounded-full";
const objectFit =
shape === imageShapes.SQUARE ? "object-contain" : "object-fit";
const objectFit = "object-cover";
const lazyload = image.lazyload ? "lazy" : "eager";
return (
<div

View file

@ -56,14 +56,20 @@ export default function ItemCard({
<div className="w-full mt-6 text-center px-10 md:px-0 flex flex-col flex-1 items-center">
{title?.text && (
<h4 className={cn("text-3xl md:text-3xl", titleFont, titleWeight)}>
<h4
className={cn(
"text-3xl md:text-3xl break-words [overflow-wrap:anywhere] max-w-full",
titleFont,
titleWeight,
)}
>
{title.text}
</h4>
)}
{subtitle?.text && (
<h5
className={cn(
"text-2xl",
"text-2xl break-words [overflow-wrap:anywhere] max-w-full",
subtitle?.font ?? fonts.DELIUS_SWASH,
subtitle?.weight ?? "font-normal",
)}

View file

@ -1,11 +1,5 @@
import GroundChicken from "&/images/labels/1.Poules_Sol.png";
import AirChicken from "&/images/labels/2.Poules_Plein_Air.png";
import Bio from "&/images/labels/3.Logo_Bio.jpg";
import Cee2 from "&/images/labels/4.Logo_Gamme_CEE2.png";
import Heart from "&/images/labels/5.Logo_Bleu_Blanc_Coeur.png";
import Red from "&/images/labels/6.Logo_Label_Rouge.png";
import Master from "&/images/labels/7.Logo_C_est_qui_le_patron.png";
import Ethique from "&/images/labels/8.Logo_Agri-éthique.png";
import GroundChicken from "&/images/labels/poules_sol.png";
import AirChicken from "&/images/labels/poules_plein_air.png";
import CarouselSection from "@/front/Components/Theme/Sections/CarouselSection";
import { usePeekCarouselOptions } from "@/front/lib/carousels";
import { bgColors, imageShapes } from "@/front/lib/constants";
@ -24,7 +18,7 @@ export default function LabelSlider({
return (
<CarouselSection
carousel={usePeekCarouselOptions()}
shape={imageShapes.SQUARE}
shape={imageShapes.ROUNDED}
variant={bgColors.PRIMARY}
title={title}
description={description}
@ -50,7 +44,7 @@ export default function LabelSlider({
alt: 'Logo "Agriculture biologique".',
title:
"Nous proposons des produits issus de poules élevées en agriculture biologique.",
src: Bio,
src: "/assets/img/france/certifications/bio.png",
},
},
{
@ -58,7 +52,7 @@ export default function LabelSlider({
alt: 'Pictogramme "Gamme CEE2" Ovoteam.',
title:
'Nous proposons des produits "Certification environnementale de niveau 2" éligibles EGALIM.',
src: Cee2,
src: "/assets/img/france/certifications/cee2.png",
},
},
{
@ -66,14 +60,14 @@ export default function LabelSlider({
alt: 'Logo "Bleu Blanc Cœur"',
title:
'Nous proposons des produits labélisés "Bleu Blanc Cœur" éligibles EGALIM.',
src: Heart,
src: "/assets/img/france/certifications/bbc.png",
},
},
{
image: {
alt: 'Logo "Label Rouge"',
title: 'Nous proposons des produits "Label Rouge"',
src: Red,
src: "/assets/img/france/certifications/label_rouge.png",
},
},
{
@ -81,7 +75,7 @@ export default function LabelSlider({
alt: 'Logo "C\'est qui le patron?"',
title:
'Nous proposons des produits labélisés "C\'est qui le patron?"',
src: Master,
src: "/assets/img/france/certifications/c_est_qui_le_patron.png",
},
},
{
@ -89,7 +83,7 @@ export default function LabelSlider({
alt: 'Logo "Agri-Ethique France"',
title:
'Nous proposons des produits labélisés "Agri-Ethique France"',
src: Ethique,
src: "/assets/img/france/certifications/agri_ethique.png",
},
},
]}

View file

@ -17,10 +17,22 @@ export default function PageHeader(props: PageHeaderProps) {
containerClassName="space-y-0 md:px-4"
>
<Breadcrumbs />
<h1 className={cn("uppercase text-4xl font-bold mt-4", title.font)}>
<h1
className={cn(
"uppercase text-4xl font-bold mt-4 break-words [overflow-wrap:anywhere]",
title.font,
)}
>
{title.text}
</h1>
<p className={cn("mt-4", description.font)}>{description.text}</p>
<p
className={cn(
"mt-4 break-words [overflow-wrap:anywhere]",
description.font,
)}
>
{description.text}
</p>
</Section>
);
}

View file

@ -17,8 +17,8 @@ export default function Commitment() {
return (
<AppLayout>
<Head
seoTitle="Fabriqué en France, Gamme œufs Plein Air et À vos côtés depuis 1963"
seoDescription="3 sites de production Français et certifiés Œufs de France, une large gamme de produits Plein Air et le développement de solutions innovantes depuis 60 ans."
seoTitle="Fabriqué en France, Large gamme 100% alternative et un savoir-faire culinaire"
seoDescription="3 sites de production Français et certifiés Œufs de France, une large gamme de produits exclusivement alternatifs et le développement de solutions innovantes depuis 60 ans."
/>
<div className="bg-primary pb-6">
<PageHeader
@ -148,7 +148,7 @@ export default function Commitment() {
text: trans("front.gamme"),
}}
description={{
text: "Nous proposons une large gamme de produits issus d'élevages Sol, Plein Air & Bio ; ainsi qu'une large offre EGALIM.",
text: "Nous proposons une large gamme de produits issus exclusivement d'élevages Sol, Plein Air & Bio ; ainsi qu'une large offre EGALIM.",
}}
button={{
href: route("front.gamme"),

View file

@ -18,7 +18,7 @@ export default function Expertise() {
<AppLayout>
<Head
seoTitle="Créateur de solutions à base d'œuf innovantes depuis 1963."
seoDescription="Partenaire de la restauration, de l'industrie agro-alimentaire et de la GMS, nous développons des solutions à base d'œuf innovantes depuis plus de 60 ans."
seoDescription="Partenaire de la restauration, de l'industrie agro-alimentaire et de tous les consommateurs, nous développons des solutions à base d'œuf innovantes depuis plus de 60 ans."
/>
<Section className="md:hidden py-3">
<Breadcrumbs
@ -39,7 +39,7 @@ export default function Expertise() {
text: "Nous proposons des solutions à base d'œuf innovantes depuis 1963.",
}}
description={{
text: "Partenaire de la restauration, de l'industrie agro-alimentaire et de la GMS, nous développons des solutions à base d'œuf innovantes depuis plus de 60 ans.",
text: "Partenaire de la restauration, de l'industrie agro-alimentaire et de tous les consommateurs, nous développons des solutions à base d'œuf innovantes depuis plus de 60 ans.",
}}
image={{
alt: "Meringues pouvant être réalisées par des professionnels grâce au Blanc des Chefs Plein Air Ovoteam",
@ -209,6 +209,22 @@ export default function Expertise() {
text: "Lancement de notre Blanc d'œuf liquide 500mL en Grande et Moyenne surface.",
},
},
{
image: {
alt: "Nouvelle identité de marque Ovoteam & Produits à marques (Ovoteam & ROA) exclusivement 100% alternatifs et Œufs de France.",
title:
"Notre nouvelle identité de marque Ovoteam & nos produits à marques (Ovoteam & ROA) exclusivement 100% alternatifs et Œufs de France.",
src: "/assets/img/expertise/dates/2027.png",
},
title: {
text: "2027",
font: "font-gotham",
weight: "font-bold",
},
description: {
text: "Notre nouvelle identité de marque Ovoteam & nos produits à marques (Ovoteam & ROA) exclusivement 100% alternatifs et Œufs de France.",
},
},
]}
/>
@ -230,7 +246,7 @@ export default function Expertise() {
variant={bgColors.PRIMARY}
carousel={{
centeredSlides: isMobile,
wrapperClass: isMobile ? "pb-20" : "pb-0",
wrapperClass: "pb-20",
breakpoints: {
0: {
slidesPerView: 1.3,
@ -321,7 +337,7 @@ export default function Expertise() {
variant={bgColors.BACKGROUND}
carousel={{
centeredSlides: isMobile,
wrapperClass: isMobile ? "pb-20" : "pb-0",
wrapperClass: "pb-20",
breakpoints: {
0: {
slidesPerView: 1.3,
@ -403,7 +419,7 @@ export default function Expertise() {
variant={bgColors.BACKGROUND}
carousel={{
centeredSlides: isMobile,
wrapperClass: isMobile ? "pb-20" : "pb-0",
wrapperClass: "pb-20",
breakpoints: {
0: {
slidesPerView: 1.3,
@ -431,7 +447,7 @@ export default function Expertise() {
weight: "font-bold",
},
description: {
text: "Pour répondre à un marché de l'aide pâtissière en hausse (+3,5% en 2024), le Blanc d'œuf liquide 500mL Ovoteam est idéal pour vos pâtisseries (meringues, macarons, mousses au chocolat, pavlovas etc…).",
text: "Pour répondre à un marché de l'aide pâtissière en hausse (+3,5% en 2024), nos références de Blanc d'œuf et d'œuf Entier liquide 500mL Ovoteam sont idéales pour vos pâtisseries (meringues, macarons, mousses au chocolat, pavlovas etc…).",
},
image: {
alt: "Visuel d'une recette de mousse au chocolat réalisée grâce au Blanc d'œuf liquide 500mL Ovoteam pensé pour l'aide pâtissière.",

View file

@ -20,8 +20,8 @@ export default function Expertise() {
return (
<AppLayout>
<Head
seoTitle="Large Gamme disponible en alternatif : Sol, Plein Air et Bio."
seoDescription="Ovoteam propose une large gamme de produits issus d'élevages alternatif : Sol, Plein Air & Bio. Ainsi qu'une large offre éligible EGALIM."
seoTitle="Large Gamme 100% alternative Ovoteam : Sol, Plein Air et Bio."
seoDescription="Ovoteam propose une large gamme de produits issus exclusivement d'élevages alternatifs : Sol, Plein Air & Bio. Ainsi qu'une large offre éligible EGALIM."
/>
<Section className="md:hidden py-3">
<Breadcrumbs
@ -39,10 +39,10 @@ export default function Expertise() {
</Section>
<HeroImage
title={{
text: "Large choix de produits issus d'élevages alternatifs : Sol, <br /> Plein Air & Bio.",
text: "Large choix de produits issus exclusivement d'élevages alternatifs : Sol, Plein Air & Bio.",
}}
description={{
text: "Dans la démarche de diminuer l'élevage conventionnel, toutes nos gammes sont disponibles en élevage alternatif ; ainsi qu'une large offre éligible EGALIM.",
text: "Dans le cadre de notre engagement en faveur de la réduction de l'élevage conventionnel, l'ensemble de nos gammes, au 1er janvier 2027, sont exclusivement disponibles en élevage alternatif. Ainsi qu'une large offre de produits éligibles à la loi EGALIM.",
}}
image={{
alt: "Poules pondeuses élevées en Plein Air dans un champ verdoyant sous un ciel bleu.",
@ -108,6 +108,21 @@ export default function Expertise() {
solutions en élevage alternatif sur la totalité de nos gammes.
</p>
</div>
<div className="flex md:flex-row flex-col items-center gap-3 text-validated">
<Image
size="w-36 md:w-96 h-auto"
shape={imageShapes.SQUARE}
image={{
alt: 'Icône "validé" pour Engagement 2027 Ovoteam',
src: Validated,
title: "Validé",
}}
/>
<p className="text-3xl uppercase font-semibold">
Au 1er janvier 2027, nous nous engageons à proposer uniquement
des solutions en élevage alternatif à marque Ovoteam.
</p>
</div>
<div className="flex md:flex-row flex-col items-center gap-3">
<Image
size="w-36 md:w-96 h-auto"
@ -119,14 +134,10 @@ export default function Expertise() {
}}
/>
<p className="text-3xl uppercase text-tertiary font-semibold">
Au 1er janvier 2027, nous nous engageons à proposer uniquement
des solutions en élevage alternatif à marque Ovoteam.
En 2030, nous nous engageons à atteindre 90% de nos volumes
vendus en œufs issus d&apos;élevages alternatifs.
</p>
</div>
<p className="text-3xl uppercase text-tertiary font-semibold">
En 2030, nous nous engageons à atteindre 90% de nos volumes vendus
en œufs issus d&apos;élevages alternatifs.
</p>
</div>
</div>
</Section>

View file

@ -17,7 +17,7 @@ export default function Home() {
<AppLayout>
<Head
seoTitle="Ovoteam : spécialiste des Ovoproduits depuis 1963 !"
seoDescription="Ovoteam, spécialiste des ovoproduits pour la Restauration, l'Industrie et la GMS grâce à une large gamme de produits issus d'élevages alternatifs (Sol, Plein air et Bio)."
seoDescription="Ovoteam, spécialiste des ovoproduits pour la Restauration, l'Industrie et la GMS grâce à une large gamme de produits issus exclusivement d'élevages alternatifs."
/>
<VideoBanner />
<CarouselSection
@ -142,7 +142,7 @@ export default function Home() {
},
{
description: {
text: "Large gamme de produits issus de poules Sol, Plein Air & Bio ; ainsi qu’une large offre Egalim.",
text: "Large gamme de produits issus exclusivement de poules Sol, Plein Air & Bio ; ainsi qu'une large offre Egalim.",
},
image: {
alt: "Large gamme 100% alternatif",

View file

@ -151,8 +151,8 @@ export default function Show({
<div className="flex flex-col lg:flex-row gap-8 lg:gap-24 items-start">
{/* Left Column: Info */}
<div className="flex-1 space-y-6 w-full">
<h1 className="text-start text-3xl sm:text-4xl md:text-5xl font-bold text-primary-foreground uppercase tracking-tight">
<div className="flex-1 space-y-6 w-full min-w-0">
<h1 className="text-start text-3xl sm:text-4xl md:text-5xl font-bold text-primary-foreground uppercase tracking-tight break-words [overflow-wrap:anywhere]">
{product.name}
</h1>

View file

@ -187,8 +187,8 @@ export default function Show({
<div className="flex flex-col lg:flex-row gap-8 lg:gap-24 items-start">
{/* Left Column: Info */}
<div className="flex-1 space-y-5 w-full">
<h1 className="text-start text-3xl sm:text-4xl md:text-5xl font-bold text-primary-foreground uppercase tracking-tight">
<div className="flex-1 space-y-5 w-full min-w-0">
<h1 className="text-start text-3xl sm:text-4xl md:text-5xl font-bold text-primary-foreground uppercase tracking-tight break-words [overflow-wrap:anywhere]">
{recipe.name}
</h1>

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
use App\Http\Controllers\Front\ProductController;
use App\Http\Controllers\Front\RecipeController;
use App\Http\Controllers\MediaController;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
@ -15,11 +16,11 @@ Route::get('/nos-engagements/fabrique-en-france', function () {
return Inertia::render('front/Pages/MadeInFrance');
})->name('made-in-france');
Route::get('/nos-engagements/expertise-depuis-1963', function () {
Route::get('/nos-engagements/exhausteur-de-papilles', function () {
return Inertia::render('front/Pages/Expertise');
})->name('expertise');
Route::get('/nos-engagements/large-gamme-plein-air', function () {
Route::get('/nos-engagements/large-gamme-100-alternative', function () {
return Inertia::render('front/Pages/Gamme');
})->name('gamme');
@ -41,6 +42,8 @@ Route::name('recipes.')->prefix('recettes')->group(function () {
Route::get('/{recipe}', [RecipeController::class, 'show'])->name('show');
});
Route::get('/media/{path}', MediaController::class)->where('path', '.*');
if (! app()->isProduction()) {
Route::get('/demo', function () {
return Inertia::render('front/Pages/Demo');