Merge branch 'eslint-errors' into 'develop'
Eslint errors See merge request ldc-web/projets/ldc!131
This commit is contained in:
commit
dcd20c56ab
274 changed files with 11244 additions and 8612 deletions
|
|
@ -66,5 +66,10 @@ module.exports = {
|
|||
},
|
||||
],
|
||||
'prettier/prettier': 'error',
|
||||
"no-console": [
|
||||
"warn", {
|
||||
allow: ["warn", "error"],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,20 +2,43 @@
|
|||
|
||||
namespace App\Casts;
|
||||
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class LocalDateTime implements CastsAttributes
|
||||
{
|
||||
public function get($model, string $key, $value, array $attributes)
|
||||
/**
|
||||
* Get local date time.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param string|integer|null $value
|
||||
* @param array $attributes
|
||||
* @return \Carbon\Carbon|null
|
||||
* @phpcs:disable
|
||||
*/
|
||||
public function get(Model $model, string $key, string|int|null $value, array $attributes): ?\Carbon\Carbon
|
||||
{
|
||||
// phpcs:enable
|
||||
return $value
|
||||
? Carbon::parse($value)->setTimezone(config('app.timezone'))
|
||||
: null;
|
||||
}
|
||||
|
||||
public function set($model, string $key, $value, array $attributes)
|
||||
/**
|
||||
* Set the locale date time.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param string $key
|
||||
* @param string|integer|null $value
|
||||
* @param array $attributes
|
||||
* @return \Carbon\Carbon|null
|
||||
* @phpcs:disable
|
||||
*/
|
||||
public function set(Model $model, string $key, string|int|null $value, array $attributes): ?\Carbon\Carbon
|
||||
{
|
||||
// phpcs:enable
|
||||
return $value
|
||||
? Carbon::parse($value, config('app.timezone'))->setTimezone('UTC')
|
||||
: null;
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\DynamicPage;
|
||||
use App\Models\News;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class UpdateMeilisearch extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'update-meilisearch';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$models = [DynamicPage::class, News::class, Document::class];
|
||||
$locales = ['fr', 'en'];
|
||||
|
||||
foreach ($locales as $locale) {
|
||||
$this->info("Import {$locale}...");
|
||||
app()->setLocale($locale);
|
||||
|
||||
foreach ($models as $model) {
|
||||
$this->call('scout:import', ['model' => $model]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -24,5 +24,4 @@ enum BreedType: int
|
|||
self::chickenEggs->name => 'enums.breedType.chickenEggs',
|
||||
self::other->name => 'enums.breedType.other'
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,10 +132,13 @@ enum ContactFormType: int
|
|||
/**
|
||||
* Get the slug for each type
|
||||
*
|
||||
* @param string|null $locale
|
||||
* @return string|null
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
public function slug(?string $locale = null): ?string
|
||||
{
|
||||
// phpcs:enable
|
||||
return match ($this) {
|
||||
self::collaborator => Lang::get('enums.contactFormType.collaborator.slug', [], $locale),
|
||||
self::breeder => Lang::get('enums.contactFormType.breeder.slug', [], $locale),
|
||||
|
|
@ -152,6 +155,10 @@ enum ContactFormType: int
|
|||
|
||||
/**
|
||||
* Check if current lang slug match in specific lang slug
|
||||
*
|
||||
* @param string $slug
|
||||
* @param string $locale
|
||||
* @return self
|
||||
*/
|
||||
public static function fromSlug(string $slug, string $locale): ?self
|
||||
{
|
||||
|
|
@ -188,7 +195,8 @@ enum ContactFormType: int
|
|||
return match (true) {
|
||||
in_array($this, $commonRoutes, true) => route('front.contact.show', ['slug' => $this->slug()]),
|
||||
$this === self::professional => null,
|
||||
$this === self::press => RouteHelper::routeNameChecker('front.dynamic-pages.espace-presse') . '#page-press-form',
|
||||
$this === self::press =>
|
||||
RouteHelper::routeNameChecker('front.dynamic-pages.espace-presse') . '#page-press-form',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -240,38 +248,41 @@ enum ContactFormType: int
|
|||
* Get the slug for each type
|
||||
*
|
||||
* @return array
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
public function getContactMails(): ?array
|
||||
{
|
||||
// phpcs:enable
|
||||
return match ($this) {
|
||||
self::collaborator => [],
|
||||
self::breeder => [
|
||||
'marie-charlotte.garnier@ldc.fr',
|
||||
'dylan.chevalier@ldc.fr'
|
||||
'dylan.chevalier@ldc.fr',
|
||||
],
|
||||
self::professional => null,
|
||||
self::restauration => [
|
||||
'rhd@ldc.fr'
|
||||
'rhd@ldc.fr',
|
||||
],
|
||||
self::export => [
|
||||
'alexis.lambert@ldc.fr',
|
||||
'bruno.lafon@ldc.fr'
|
||||
'bruno.lafon@ldc.fr',
|
||||
],
|
||||
self::finance => [
|
||||
'david.eluaud@ldc.fr',
|
||||
'malaury.offe@ldc.fr'
|
||||
'malaury.offe@ldc.fr',
|
||||
],
|
||||
self::commitments => [
|
||||
'claire-marie.gesland@ldc.fr'
|
||||
'claire-marie.gesland@ldc.fr',
|
||||
],
|
||||
self::product => [],
|
||||
self::info => [
|
||||
'blandine.durand-gratian@ldc.fr',
|
||||
'malaury.offe@ldc.fr'
|
||||
'malaury.offe@ldc.fr',
|
||||
],
|
||||
self::press => [
|
||||
'communicationgroupe@ldc.fr'
|
||||
'communicationgroupe@ldc.fr',
|
||||
],
|
||||
};
|
||||
// phpcs:ignore Squiz.Commenting.InlineComment
|
||||
}; //end match
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,4 @@ enum CustomerAskingType: int
|
|||
self::gastronomy->name => 'enums.customerAskingType.gastronomy',
|
||||
self::other->name => 'enums.customerAskingType.other',
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,4 @@ enum PressType: int
|
|||
self::photo->name => 'enums.pressType.photo',
|
||||
self::other->name => 'enums.pressType.other'
|
||||
];
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ enum DynamicFieldTypes: int
|
|||
case model = 15;
|
||||
case staticroute = 16;
|
||||
|
||||
// Specific inputs
|
||||
case position = 101;
|
||||
// Specific inputs.
|
||||
case position = 101;
|
||||
|
||||
/**
|
||||
* Labels definition.
|
||||
|
|
@ -52,8 +52,8 @@ enum DynamicFieldTypes: int
|
|||
self::model->name => 'enums.dynamic-field-types.model',
|
||||
self::staticroute->name => 'enums.dynamic-field-types.staticroute',
|
||||
|
||||
// Specific inputs
|
||||
self::position->name => 'enums.dynamic-field-types.position',
|
||||
// Specific inputs.
|
||||
self::position->name => 'enums.dynamic-field-types.position',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -75,10 +75,10 @@ enum DynamicFieldTypes: int
|
|||
self::date->name => 'required|date',
|
||||
self::color->name => 'required|string|hex_color',
|
||||
self::model->name => 'required|numeric|exists:dynamic_pages,id',
|
||||
self::staticroute->name => 'required|numeric|between:1,10',
|
||||
self::staticroute->name => 'required|numeric|between:1,99',
|
||||
|
||||
// Specific inputs
|
||||
self::position->name => 'required|numeric|between:1,5',
|
||||
// Specific inputs.
|
||||
self::position->name => 'required|numeric|between:1,5',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -114,7 +114,7 @@ enum DynamicFieldTypes: int
|
|||
self::model->name => false,
|
||||
self::staticroute->name => false,
|
||||
|
||||
// Specific inputs
|
||||
self::position->name => false,
|
||||
// Specific inputs.
|
||||
self::position->name => false,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ enum ModelsList: int
|
|||
case documents = 3;
|
||||
|
||||
/**
|
||||
* Labels definition.
|
||||
* Key of the translation.
|
||||
* Labels definition (key of the translation).
|
||||
* etc: enums.model-list.dynamic-page etc...
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
|
|
@ -30,7 +29,6 @@ enum ModelsList: int
|
|||
];
|
||||
|
||||
/**
|
||||
* Validations definition.
|
||||
* Target field used to present the resource.
|
||||
* ex: title, label, name etc...
|
||||
*/
|
||||
|
|
@ -41,7 +39,7 @@ enum ModelsList: int
|
|||
];
|
||||
|
||||
/**
|
||||
* Get validation.
|
||||
* Get target field.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ enum NewsYearsEnum: int
|
|||
/**
|
||||
* Get the years to display using the app locale
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function yearsWithLocal(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ enum OrdersEnum: int
|
|||
/**
|
||||
* Get the orders to display using the app locale
|
||||
*
|
||||
* @return bool
|
||||
* @return boolean
|
||||
*/
|
||||
public function ordersWithLocal(): bool
|
||||
{
|
||||
|
|
@ -39,6 +39,9 @@ enum OrdersEnum: int
|
|||
|
||||
/**
|
||||
* Optional factory from label.
|
||||
*
|
||||
* @param string $name
|
||||
* @return self
|
||||
*/
|
||||
public static function makeFromLabel(string $name): ?self
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ namespace App\Enums;
|
|||
use App\Enums\Contact\ContactFormType;
|
||||
use Uwil\LaravelCommon\Traits\Enums\BaseEnum;
|
||||
|
||||
enum StaticRoutes: int
|
||||
enum StaticRoutesEnum: int
|
||||
{
|
||||
use BaseEnum;
|
||||
|
||||
// Set all cases for each static routes.
|
||||
// Set all cases for each static routes.
|
||||
case collaborator = 1;
|
||||
case breeder = 2;
|
||||
case professional = 3;
|
||||
|
|
@ -20,22 +20,21 @@ enum StaticRoutes: int
|
|||
case product = 8;
|
||||
case info = 9;
|
||||
case press = 10;
|
||||
// case google = 11;
|
||||
case search = 11;
|
||||
|
||||
/**
|
||||
* Get array of each route with his matching value.
|
||||
* @param callable $callback
|
||||
*
|
||||
* @param callable|null $callback
|
||||
* @return array
|
||||
*/
|
||||
public static function getRoutes(?callable $callback = null): array
|
||||
{
|
||||
|
||||
$dataKeyValue = array_merge(ContactFormType::getLabelisedRoutes(), [
|
||||
// self::google->name => (object) [
|
||||
// 'label' => 'Google',
|
||||
// 'route' => 'https://google.com',
|
||||
// ]
|
||||
self::search->name => (object) [
|
||||
'label' => trans('front.search.title'),
|
||||
'route' => '/recherche?texte=LDC',
|
||||
]
|
||||
]);
|
||||
return collect($dataKeyValue)
|
||||
->reject(fn($item) => is_null($item->label) || is_null($item->route))
|
||||
|
|
@ -55,12 +54,12 @@ enum StaticRoutes: int
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the url of a given enum
|
||||
* e.g : \App\Enums\StaticRoutes::make(1)->getRoute();
|
||||
* Get the url of a given enum value.
|
||||
*
|
||||
* @param integer $value
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getRoute($value): ?string
|
||||
public static function getRoute(int $value): ?string
|
||||
{
|
||||
$collect = collect(self::getRoutes(fn ($route) => $route->value == $value));
|
||||
return $collect->isEmpty() ? null : $collect->first()->route;
|
||||
|
|
@ -45,6 +45,9 @@ enum YearsEnum: int
|
|||
|
||||
/**
|
||||
* Optional factory from label.
|
||||
*
|
||||
* @param string $label
|
||||
* @return self
|
||||
*/
|
||||
public static function makeFromLabel(string $label): ?self
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use Uwil\LaravelCommon\Controllers\Controller;
|
||||
|
||||
class BladeComponentHelper extends Controller
|
||||
{
|
||||
public function runSortQuery($query)
|
||||
{
|
||||
return $this->sortQuery($query);
|
||||
}
|
||||
|
||||
public function runPaginate($query)
|
||||
{
|
||||
return $this->paginate($query);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Helpers;
|
||||
|
||||
use App\Enums\Document\DocumentStatusEnum;
|
||||
use App\Models\Document;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DocumentHelper
|
||||
|
|
@ -22,8 +22,8 @@ class DocumentHelper
|
|||
*
|
||||
* HTML entities (e.g. `&`) are automatically decoded.
|
||||
*
|
||||
* @param string|null $issuIframe Raw Issuu iframe HTML or embed URL
|
||||
* @return string|null The normalized Issuu embed URL, or null if none is found
|
||||
* @param string|null $issuIframe Raw Issuu iframe HTML or embed URL.
|
||||
* @return string|null The normalized Issuu embed URL, or null if none is found.
|
||||
*/
|
||||
public static function extractDocumentFromIssuIframe(?string $issuIframe): ?string
|
||||
{
|
||||
|
|
@ -51,14 +51,14 @@ class DocumentHelper
|
|||
/**
|
||||
* Return a document query with all the request filters applied
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Database\Eloquent\Builder<\App\Models\Document> $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder<\App\Models\Document> $query
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder $query
|
||||
*/
|
||||
public static function getQueryWithFilters(Request $request, $query): \Illuminate\Database\Eloquent\Builder
|
||||
public static function getQueryWithFilters(Request $request, Builder $query): \Illuminate\Database\Eloquent\Builder
|
||||
{
|
||||
$statusFilter = $request->status;
|
||||
if($statusFilter) {
|
||||
if ($statusFilter) {
|
||||
$query->where('status', DocumentStatusEnum::make($statusFilter, 'name')->value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ class DynamicPageHelper
|
|||
$originalContent = $model->getOriginal('content');
|
||||
|
||||
$availableLocales = array_keys(config('laravellocalization.supportedLocales', ['fr' => "Français"]));
|
||||
$localesToProcess = ($forceDeleteImage)
|
||||
? $availableLocales // on delete it's all the locales
|
||||
: [$locale];
|
||||
// On delete it's all the locales.
|
||||
$localesToProcess = ($forceDeleteImage) ? $availableLocales : [$locale];
|
||||
|
||||
foreach ($localesToProcess as $lang) {
|
||||
if (isset($originalContent[$lang])) {
|
||||
|
|
@ -65,14 +64,14 @@ class DynamicPageHelper
|
|||
array $newContent,
|
||||
bool $forceDeleteImage
|
||||
): void {
|
||||
$prefix = DynamicFieldTypes::image->name . '_';
|
||||
$prefix = DynamicFieldTypes::image->name . '_';
|
||||
|
||||
$oldImages = static::extractImagePaths($oldContent, $prefix);
|
||||
$newImages = static::extractImagePaths($newContent, $prefix);
|
||||
$allPaths = collect(array_keys($oldImages))
|
||||
$allPaths = collect(array_keys($oldImages))
|
||||
->merge(array_keys($newImages))
|
||||
->unique();
|
||||
foreach ($allPaths as $key) {
|
||||
foreach ($allPaths as $key) {
|
||||
$old = $oldImages[$key] ?? null;
|
||||
$new = $newImages[$key] ?? null;
|
||||
// Case n°1 : Same values when force delete.
|
||||
|
|
@ -103,6 +102,15 @@ class DynamicPageHelper
|
|||
}
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract image path for fields with image key prefix.
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $prefix
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
protected static function extractImagePaths(
|
||||
array $array,
|
||||
string $prefix,
|
||||
|
|
@ -128,8 +136,8 @@ class DynamicPageHelper
|
|||
/**
|
||||
* Remove imgs from wysiwygs.
|
||||
*
|
||||
* @param array $oldContent
|
||||
* @param array $newContent
|
||||
* @param array $oldContent
|
||||
* @param array $newContent
|
||||
* @param boolean $forceDeleteImage
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -171,11 +179,11 @@ class DynamicPageHelper
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all segments url for dynamic pages
|
||||
* Get all segments url for dynamic pages.
|
||||
*
|
||||
* @param DynamicPage $page
|
||||
* @param Collection $pages
|
||||
* @param string $locale
|
||||
* @param \App\Models\DynamicPage $page
|
||||
* @param \Illuminate\Support\Collection $pages
|
||||
* @param string $locale
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getAllDynamicPageSegments(DynamicPage $page, Collection $pages, string $locale): ?array
|
||||
|
|
@ -185,10 +193,10 @@ class DynamicPageHelper
|
|||
|
||||
// Browse all relationships.
|
||||
while ($parentId) {
|
||||
/** @var \App\Models\DynamicPage|null $parentPage */
|
||||
/** @var \App\Models\DynamicPage|null $parent */
|
||||
$parent = $pages->find($parentId);
|
||||
|
||||
if (! $parent || !$parent->status->equals(PageStatusEnum::published)) {
|
||||
if (!$parent || !$parent->status->equals(PageStatusEnum::published)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class FinancePageChartHelper
|
|||
*/
|
||||
public static function getBilanSimplify(array $item): array
|
||||
{
|
||||
$active = $item['list_bilan_simplify_active_values'] ?? [];
|
||||
$active = $item['list_bilan_simplify_active_values'] ?? [];
|
||||
$passive = $item['list_bilan_simplify_passive_values'] ?? [];
|
||||
|
||||
$datasets = [];
|
||||
|
|
@ -79,7 +79,7 @@ class FinancePageChartHelper
|
|||
*/
|
||||
public static function getAutofinancement(array $item): array
|
||||
{
|
||||
$labels = [];
|
||||
$labels = [];
|
||||
$valuesCPT = [];
|
||||
$valuesIVT = [];
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ class FinancePageChartHelper
|
|||
* Routes chart building based on chart type.
|
||||
*
|
||||
* @param string $type Chart identifier.
|
||||
* @param array $data Raw chart data.
|
||||
* @param array $data Raw chart data.
|
||||
* @return array Chart.js-compatible configuration.
|
||||
*/
|
||||
public static function buildChart(string $type, array $data): array
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class RouteHelper extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true or false, if the passed route is actually active
|
||||
* Return true or false, if the passed route is actually active.
|
||||
*
|
||||
* @param string $routeName
|
||||
* @param mixed $locale
|
||||
|
|
@ -50,25 +50,25 @@ class RouteHelper extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the localized url in the langage switcher
|
||||
* Get the localized url in the langage switcher.
|
||||
*
|
||||
* @param string $localeCode LocaleCode from LaravelLocalization::getSupportedLocales()
|
||||
* @param string $localeCode LocaleCode from LaravelLocalization::getSupportedLocales().
|
||||
* @return string
|
||||
*/
|
||||
public static function getLocalizedUrl(string $localeCode): string
|
||||
{
|
||||
$route = request()->route();
|
||||
if (! $route) {
|
||||
$route = request()->route();
|
||||
if (!$route) {
|
||||
return LaravelLocalization::getLocalizedURL($localeCode);
|
||||
}
|
||||
return self::resolve(
|
||||
self::getDynamicPageLocalizedURL($route, $localeCode),
|
||||
self::getContactShowLocalizedURL($route, $localeCode),
|
||||
self::getDynamicPageLocalizedUrl($route, $localeCode),
|
||||
self::getContactShowLocalizedUrl($route, $localeCode),
|
||||
) ?? LaravelLocalization::getLocalizedURL($localeCode, null, [], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the url to be returned for the localized switcher
|
||||
* Resolve the url to be returned for the localized switcher.
|
||||
*
|
||||
* @param string|null ...$urls
|
||||
* @return string|null
|
||||
|
|
@ -84,13 +84,13 @@ class RouteHelper extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the localized url for contact page show
|
||||
* Return the localized url for contact page show.
|
||||
*
|
||||
* @param Route $route
|
||||
* @param string $localeCode
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @param string $localeCode
|
||||
* @return string|false|null
|
||||
*/
|
||||
private static function getContactShowLocalizedURL(Route $route, string $localeCode)
|
||||
private static function getContactShowLocalizedUrl(Route $route, string $localeCode)
|
||||
{
|
||||
$contactPage = $route->parameter('contactPage');
|
||||
|
||||
|
|
@ -101,11 +101,12 @@ class RouteHelper extends Controller
|
|||
[],
|
||||
false
|
||||
);
|
||||
$parsed = parse_url($localizedUrl);
|
||||
if (! isset($parsed['path'])) {
|
||||
$parsed = parse_url($localizedUrl);
|
||||
if (!isset($parsed['path'])) {
|
||||
return $localizedUrl;
|
||||
}
|
||||
$segments = explode('/', trim($parsed['path'], '/'));
|
||||
|
||||
$segments = explode('/', trim($parsed['path'], '/'));
|
||||
$currentSlug = end($segments);
|
||||
|
||||
$enum = ContactFormType::fromSlug(
|
||||
|
|
@ -121,19 +122,19 @@ class RouteHelper extends Controller
|
|||
}
|
||||
}
|
||||
return $localizedUrl;
|
||||
}
|
||||
} //end if
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the localized url for all dynamic pages
|
||||
* Return the localized url for all dynamic pages.
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @param string $localeCode
|
||||
* @param string $localeCode
|
||||
* @return string|false|null
|
||||
*/
|
||||
private static function getDynamicPageLocalizedURL(Route $route, string $localeCode)
|
||||
private static function getDynamicPageLocalizedUrl(Route $route, string $localeCode): string|false|null
|
||||
{
|
||||
/** @var DynamicPage|null $page */
|
||||
/** @var \App\Models\DynamicPage|null $dynamicPage */
|
||||
$dynamicPage = $route->parameter('dynamicPage');
|
||||
if ($dynamicPage instanceof DynamicPage) {
|
||||
$path = $dynamicPage->getLocalizedPath($localeCode);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class TranslationHelper
|
|||
* Assert fallback locale translation is present.
|
||||
*
|
||||
* @param \App\Contracts\TranslatableModel $model
|
||||
* @param array $excludeKeys key of the model we need to keep nullable
|
||||
* @param array $excludeKeys Key of the model we need to keep nullable.
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException Translations missing.
|
||||
*/
|
||||
|
|
@ -43,7 +43,7 @@ class TranslationHelper
|
|||
{
|
||||
$localeFallback = config('app.fallback_locale');
|
||||
$missingTranslations = [];
|
||||
$excludeFields = array_merge(['slug'], $excludeKeys);
|
||||
$excludeFields = array_merge(['slug'], $excludeKeys);
|
||||
foreach (Arr::except($model->getTranslations(), $excludeFields) as $key => $value) {
|
||||
if (!is_null($model->{$key}) && !$model->hasTranslation($key, $localeFallback)) {
|
||||
$validationTranslations = self::getCachedTranslations()['validation'];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class CompanyActivityController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "company-activities";
|
||||
|
||||
/**
|
||||
|
|
@ -144,8 +144,10 @@ class CompanyActivityController extends Controller
|
|||
* @param \App\Models\CompanyActivity $company_activity
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateCompanyActivityRequest $request, CompanyActivity $company_activity): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
public function update(
|
||||
UpdateCompanyActivityRequest $request,
|
||||
CompanyActivity $company_activity,
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $company_activity) {
|
||||
$company_activity->fill($request->validated());
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class CompanyController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "companies";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class CompanySectorController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "company-sectors";
|
||||
|
||||
/**
|
||||
|
|
@ -92,8 +92,10 @@ class CompanySectorController extends Controller
|
|||
*/
|
||||
public function show(CompanySector $company_sector): \Inertia\Response
|
||||
{
|
||||
$companies = $company_sector->companies()->paginate(ItemsPerPaginationEnum::five->value());
|
||||
return Inertia::render('CompanySectors/Show', [
|
||||
'data' => CommonResource::make($company_sector),
|
||||
'companies' => CommonResource::collection($companies),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
|
@ -144,8 +146,10 @@ class CompanySectorController extends Controller
|
|||
* @param \App\Models\CompanySector $company_sector
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateCompanySectorRequest $request, CompanySector $company_sector): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
public function update(
|
||||
UpdateCompanySectorRequest $request,
|
||||
CompanySector $company_sector,
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $company_sector) {
|
||||
$company_sector->fill($request->validated());
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,14 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "contact-counts";
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function index(): \Inertia\Response
|
||||
{
|
||||
$query = ContactCount::query();
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class DocumentCategoryController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "document-categories";
|
||||
|
||||
/**
|
||||
|
|
@ -132,11 +132,13 @@ class DocumentCategoryController extends Controller
|
|||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Back\News\UpdateDocumentCategoryRequest $request
|
||||
* @param \App\Models\DocumentCategory $document_category
|
||||
* @param \App\Models\DocumentCategory $document_category
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateDocumentCategoryRequest $request, DocumentCategory $document_category): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
public function update(
|
||||
UpdateDocumentCategoryRequest $request,
|
||||
DocumentCategory $document_category,
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $document_category) {
|
||||
$document_category->fill($request->validated());
|
||||
if ($document_category->saveOrFail()) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class DocumentController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "documents";
|
||||
|
||||
/**
|
||||
|
|
@ -62,6 +62,7 @@ class DocumentController extends Controller
|
|||
|
||||
/** Custom pagination */
|
||||
$docModels = $this->paginate($query);
|
||||
|
||||
return Inertia::render('Document/Index', [
|
||||
'documentsModel' => CommonResource::collection($docModels),
|
||||
'searchFields' => $searchFields,
|
||||
|
|
@ -144,7 +145,7 @@ class DocumentController extends Controller
|
|||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Back\Document\UpdateDocumentRequest $request
|
||||
* @param \App\Models\Document $document
|
||||
* @param \App\Models\Document $document
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateDocumentRequest $request, Document $document): \Illuminate\Http\RedirectResponse
|
||||
|
|
@ -160,6 +161,16 @@ class DocumentController extends Controller
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the specified resource.
|
||||
*
|
||||
* @param \App\Models\Document $document
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function duplicate(Document $document): \Inertia\Response
|
||||
{
|
||||
return $this->create($document->replicate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified resource.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class DocumentTagController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "document-tags";
|
||||
|
||||
/**
|
||||
|
|
@ -132,11 +132,13 @@ class DocumentTagController extends Controller
|
|||
* Update the specified resource.
|
||||
*
|
||||
* @param \App\Http\Requests\Back\News\UpdateDocumentTagRequest $request
|
||||
* @param \App\Models\DocumentTag $finance_document
|
||||
* @param \App\Models\DocumentTag $document_tag
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateDocumentTagRequest $request, DocumentTag $document_tag): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
public function update(
|
||||
UpdateDocumentTagRequest $request,
|
||||
DocumentTag $document_tag,
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $document_tag) {
|
||||
$document_tag->fill($request->validated());
|
||||
if ($document_tag->saveOrFail()) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class DynamicPageController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "dynamic-pages";
|
||||
|
||||
/**
|
||||
|
|
@ -141,7 +141,7 @@ class DynamicPageController extends Controller
|
|||
{
|
||||
$dynamicPageModel = $dynamic_page->load(['parentPage', 'config']);
|
||||
$dynamicPageModels = DynamicPage::getModelsCached()
|
||||
->filter(fn ($model) => $model->getKey() !== $dynamic_page->getKey())
|
||||
->filter(fn ($model) => $model->getKey() !== $dynamic_page->getKey())
|
||||
->values();
|
||||
$pageConfigModels = PageConfig::getModelsCached();
|
||||
return Inertia::render('DynamicPages/Edit', [
|
||||
|
|
|
|||
|
|
@ -43,9 +43,8 @@ class InputsController extends Controller
|
|||
return response()->json(['error' => 'Invalid model class'], 404);
|
||||
}
|
||||
|
||||
|
||||
// Determine the field to display.
|
||||
$model = new $modelClass();
|
||||
$model = new $modelClass();
|
||||
$isTranslatable = method_exists($model, 'getTranslations');
|
||||
|
||||
$locale = app()->getLocale();
|
||||
|
|
@ -70,7 +69,7 @@ class InputsController extends Controller
|
|||
return filled($getValue($item));
|
||||
});
|
||||
|
||||
// Apply search and exclude filters
|
||||
// Apply search and exclude filters.
|
||||
$items = $allItems
|
||||
->when(!empty($validated['exclude']), function ($collection) use ($validated) {
|
||||
return $collection->reject(fn($item) => $item->id == $validated['exclude']);
|
||||
|
|
@ -129,7 +128,7 @@ class InputsController extends Controller
|
|||
|
||||
|
||||
return response()->json([
|
||||
'url' => $url,
|
||||
'url' => $url,
|
||||
'token' => $token,
|
||||
]);
|
||||
}
|
||||
|
|
@ -138,7 +137,7 @@ class InputsController extends Controller
|
|||
* Get the url to access a specific resource.
|
||||
*
|
||||
* @param integer $modelId Id of the target model.
|
||||
* @param integer $modelName Name of the target model.
|
||||
* @param string $modelName Name of the target model.
|
||||
* @return string|null
|
||||
*/
|
||||
private function getAccessModel(int $modelId, string $modelName): string|null
|
||||
|
|
@ -184,7 +183,8 @@ class InputsController extends Controller
|
|||
public function uploadFile(UploadFileRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
// Get the class of the target model and verify its existence.
|
||||
$modelClass = "App\\Models\\$request->folder";
|
||||
$modelName = Str::singular($request->validated()['folder']);
|
||||
$modelClass = "App\\Models\\$modelName";
|
||||
if (!class_exists($modelClass)) {
|
||||
return response()->json(['error' => 'Invalid model class'], 404);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class NewsCategoryController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "news-categories";
|
||||
|
||||
/**
|
||||
|
|
@ -71,14 +71,14 @@ class NewsCategoryController extends Controller
|
|||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\News $news_category
|
||||
* @param \App\Models\NewsCategory $news_category
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function create(NewsCategory $news_category): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('NewsCategory/Create', [
|
||||
'data' => CommonResource::make($news_category),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_category),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ class NewsCategoryController extends Controller
|
|||
{
|
||||
$news = $news_category->news()->paginate(ItemsPerPaginationEnum::five->value());
|
||||
return Inertia::render('NewsCategory/Show', [
|
||||
'data' => CommonResource::make($news_category),
|
||||
'news' => CommonResource::collection($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_category),
|
||||
'news' => CommonResource::collection($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -126,8 +126,8 @@ class NewsCategoryController extends Controller
|
|||
public function edit(NewsCategory $news_category): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('NewsCategory/Edit', [
|
||||
'data' => CommonResource::make($news_category),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_category),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -138,8 +138,10 @@ class NewsCategoryController extends Controller
|
|||
* @param \App\Models\NewsCategory $news_category
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function update(UpdateNewsCategoryRequest $request, NewsCategory $news_category): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
public function update(
|
||||
UpdateNewsCategoryRequest $request,
|
||||
NewsCategory $news_category,
|
||||
): \Illuminate\Http\RedirectResponse {
|
||||
return DB::transaction(function () use ($request, $news_category) {
|
||||
$news_category->fill($request->validated());
|
||||
if ($news_category->saveOrFail()) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "news";
|
||||
|
||||
/**
|
||||
|
|
@ -71,30 +71,30 @@ class NewsController extends Controller
|
|||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\News $page_config
|
||||
* @param \App\Models\News $news
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function create(News $news): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('News/Create', [
|
||||
'data' => CommonResource::make($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a specific resource.
|
||||
*
|
||||
* @param \App\Models\PageConfig $news
|
||||
* @param \App\Models\News $news
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function show(News $news): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('News/Show', [
|
||||
'data' => CommonResource::make($news->load('categories', 'tags')),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news->load('categories', 'tags')),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -128,9 +128,9 @@ class NewsController extends Controller
|
|||
public function edit(News $news): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('News/Edit', [
|
||||
'data' => CommonResource::make($news->load('categories', 'tags')),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news->load('categories', 'tags')),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Uwil\LaravelCommon\Enums\ItemsPerPaginationEnum;
|
|||
|
||||
class NewsTagController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "news-tags";
|
||||
|
||||
/**
|
||||
|
|
@ -63,22 +63,22 @@ class NewsTagController extends Controller
|
|||
|
||||
return Inertia::render('NewsTag/Index', [
|
||||
'newsTagModels' => CommonResource::collection($newsTagModels),
|
||||
'searchFields' => $searchFields,
|
||||
'modelName' => $this->modelName,
|
||||
'searchFields' => $searchFields,
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\News $news_tag
|
||||
* @param \App\Models\NewsTag $news_tag
|
||||
* @return \Inertia\Response
|
||||
*/
|
||||
public function create(NewsTag $news_tag): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('NewsTag/Create', [
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -92,10 +92,10 @@ class NewsTagController extends Controller
|
|||
{
|
||||
$news = $news_tag->news()->paginate(ItemsPerPaginationEnum::five->value());
|
||||
return Inertia::render('NewsTag/Show', [
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'news' => CommonResource::collection($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'news' => CommonResource::collection($news),
|
||||
'enumNewsStatus' => NewsStatusEnum::toArray(),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -126,8 +126,8 @@ class NewsTagController extends Controller
|
|||
public function edit(NewsTag $news_tag): \Inertia\Response
|
||||
{
|
||||
return Inertia::render('NewsTag/Edit', [
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'modelName' => $this->modelName,
|
||||
'data' => CommonResource::make($news_tag),
|
||||
'modelName' => $this->modelName,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use Uwil\LaravelCommon\Controllers\Controller;
|
|||
|
||||
class PageConfigController extends Controller
|
||||
{
|
||||
/** @var string $modelName */
|
||||
/** @var string $modelName Name of the model in kebab case. */
|
||||
private $modelName = "page-configs";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ namespace App\Http\Controllers\Front;
|
|||
use App\Enums\Contact\ContactFormType;
|
||||
use App\Exceptions\AbortContactMailer;
|
||||
use App\Http\Requests\Front\Contact\ContactRequest;
|
||||
use App\Models\MailContactData;
|
||||
use App\Jobs\Mails\SendContactMail;
|
||||
use App\Models\ContactCount;
|
||||
use App\Models\MailContactData;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
|
|
@ -30,6 +31,7 @@ class ContactController
|
|||
/**
|
||||
* Show contact show page.
|
||||
*
|
||||
* @param string $slug
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(string $slug): \Illuminate\Contracts\View\View
|
||||
|
|
@ -46,6 +48,7 @@ class ContactController
|
|||
/**
|
||||
* Contact send.
|
||||
*
|
||||
* @param \App\Http\Requests\Front\Contact\ContactRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function send(ContactRequest $request): \Illuminate\Http\RedirectResponse
|
||||
|
|
@ -77,11 +80,13 @@ class ContactController
|
|||
}
|
||||
report($e);
|
||||
$hasNewsletterError = true;
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
// phpcs:ignore Generic.Files.LineLength
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
} catch (CrmException $e) {
|
||||
report($e);
|
||||
$hasNewsletterError = true;
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
// phpcs:ignore Generic.Files.LineLength
|
||||
$newsletterMessage = trans('Une erreur est survenue lors de l\'inscription à la newsletter, merci de réessayer ultérieurement.');
|
||||
}
|
||||
}
|
||||
ContactCount::updateOrInsert(
|
||||
|
|
@ -90,8 +95,11 @@ class ContactController
|
|||
);
|
||||
|
||||
$contactMessage = trans('Votre message a bien été envoyé.');
|
||||
$message = $newsletterMessage ? $contactMessage. ' <br /> ' . $newsletterMessage : $contactMessage;
|
||||
$message = $newsletterMessage ? $contactMessage . ' <br /> ' . $newsletterMessage : $contactMessage;
|
||||
return redirect()->back()
|
||||
->with($hasContactError || $hasNewsletterError ? 'info' : 'success', new \Illuminate\Support\HtmlString($message));
|
||||
->with(
|
||||
$hasContactError || $hasNewsletterError ? 'info' : 'success',
|
||||
new HtmlString($message)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class NewsController extends Controller
|
|||
/**
|
||||
* Show news show page.
|
||||
*
|
||||
* @param \App\Models\News $news
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function show(News $news): \Illuminate\Contracts\View\View
|
||||
|
|
|
|||
|
|
@ -17,17 +17,20 @@ use Uwil\LaravelCommon\Helpers\CollectionHelper;
|
|||
|
||||
class PostsController extends Controller
|
||||
{
|
||||
/** @var string */
|
||||
protected const DOCUMENTS = "documents";
|
||||
protected const NEWS = "news";
|
||||
|
||||
/** @var string */
|
||||
protected const NEWS = "news";
|
||||
|
||||
/**
|
||||
* Extract unique years from date field in a collection.
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $query
|
||||
* @param string $field
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $model
|
||||
* @param string $field
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
private function getUniqueYearsFromCollection(Collection $model, string $field): Collection
|
||||
private function getUniqueYearsFromCollection(Collection $model, string $field): \Illuminate\Support\Collection
|
||||
{
|
||||
return $model->pluck($field)
|
||||
->map(fn($date) => Carbon::parse($date)->year)
|
||||
|
|
@ -41,10 +44,9 @@ class PostsController extends Controller
|
|||
* @param \Illuminate\Support\Collection $array1
|
||||
* @param \Illuminate\Support\Collection $array2
|
||||
* @param string|null $field
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function getMatchingValues(Collection $array1, Collection $array2, ?string $field = null): array
|
||||
private function getMatchingValues(Collection $array1, Collection $array2, ?string $field = null): array
|
||||
{
|
||||
return $array2
|
||||
->filter(fn ($item) => $array1->contains($field ? $item[$field] : $item))
|
||||
|
|
@ -57,11 +59,10 @@ class PostsController extends Controller
|
|||
*
|
||||
* If the type is "documents" the "order" filter is included
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $category
|
||||
* @param string $type
|
||||
* @param string $category
|
||||
* @param \Illuminate\Database\Eloquent\Collection $publishedTags
|
||||
* @param \Illuminate\Database\Eloquent\Collection $model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFilters(string $type, string $category, Collection $publishedTags, Collection $model): array
|
||||
|
|
@ -76,7 +77,6 @@ class PostsController extends Controller
|
|||
])
|
||||
->values();
|
||||
|
||||
|
||||
$enumYears = collect(YearsEnum::toArray())
|
||||
->map(fn($year) => YearsEnum::make((int) $year->value))
|
||||
->map(fn($year) => [
|
||||
|
|
@ -98,7 +98,7 @@ class PostsController extends Controller
|
|||
])
|
||||
->values();
|
||||
|
||||
/** Sort displayed years */
|
||||
// Sort displayed years.
|
||||
$years = $this->getMatchingValues(
|
||||
$this->getUniqueYearsFromCollection($model, 'published_at'),
|
||||
$enumYears,
|
||||
|
|
@ -114,32 +114,34 @@ class PostsController extends Controller
|
|||
}
|
||||
|
||||
$filters[] = [
|
||||
'title' => $type === self::DOCUMENTS ? ucfirst(__('front.news.document')) : ucfirst(__('front.news.theme')),
|
||||
'title' => $type === self::DOCUMENTS
|
||||
? ucfirst(__('front.news.document'))
|
||||
: ucfirst(__('front.news.theme')),
|
||||
'name' => 'tags',
|
||||
'fields' => $tags,
|
||||
];
|
||||
|
||||
$filters[] = [
|
||||
'title' => $type === self::DOCUMENTS ? ucfirst(__('front.news.exercise')) : ucfirst(__('front.news.year')),
|
||||
'title' => $type === self::DOCUMENTS
|
||||
? ucfirst(__('front.news.exercise'))
|
||||
: ucfirst(__('front.news.year')),
|
||||
'name' => 'years',
|
||||
'fields' => $years,
|
||||
];
|
||||
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns news in JSON format filtered by category and language
|
||||
* Optionally, the results can be further filtered by tags, and years
|
||||
* Returns news in JSON format filtered by category and language.
|
||||
* Optionally, the results can be further filtered by tags, and years.
|
||||
*
|
||||
* @param \App\Http\Requests\Front\PostsRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function ajaxLoadNews(PostsRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$perPage = 9;
|
||||
$data = $request->validated();
|
||||
$perPage = 9;
|
||||
$selectedFilters = [];
|
||||
|
||||
$category = $data['category'];
|
||||
|
|
@ -197,34 +199,36 @@ class PostsController extends Controller
|
|||
|
||||
$filters = $this->getFilters('news', $category, $publishedNewsTags, $newsModel);
|
||||
|
||||
/** Custom pagination */
|
||||
// Custom pagination.
|
||||
$newsModel = CollectionHelper::paginate($newsModel, $perPage);
|
||||
|
||||
return response()->json([
|
||||
'pagination' => [
|
||||
'total' => $newsModel->total(),
|
||||
'nbItems' => count($newsModel->items()),
|
||||
'pagination' => [
|
||||
'total' => $newsModel->total(),
|
||||
'nbItems' => count($newsModel->items()),
|
||||
'currentPage' => $newsModel->currentPage(),
|
||||
'lastPage' => $newsModel->lastPage(),
|
||||
'hasMore' => $newsModel->currentPage() < $newsModel->lastPage(),
|
||||
'lastPage' => $newsModel->lastPage(),
|
||||
'hasMore' => $newsModel->currentPage() < $newsModel->lastPage(),
|
||||
],
|
||||
'filters' => view('components.front.posts.filters-dropdowns', ['filters' => $filters])->render(),
|
||||
'selectedFilters' => view('components.front.posts.selected-filters', ['selectedFilters' => $selectedFilters])->render(),
|
||||
'news' => view('components.front.posts.news', ['newsList' => $newsModel->items()])->render()
|
||||
'filters' => view('components.front.posts.filters-dropdowns', ['filters' => $filters])->render(),
|
||||
'selectedFilters' => view('components.front.posts.selected-filters', [
|
||||
'selectedFilters' => $selectedFilters,
|
||||
])->render(),
|
||||
'news' => view('components.front.posts.news', ['newsList' => $newsModel->items()])->render()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns documents in JSON format filtered by category and language
|
||||
* Optionally, the results can be further filtered by order, tags, and years
|
||||
* Returns documents in JSON format filtered by category and language.
|
||||
* Optionally, the results can be further filtered by order, tags, and years.
|
||||
*
|
||||
* @param \App\Http\Requests\Front\PostsRequest $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function ajaxLoadDocuments(PostsRequest $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
$perPage = 3;
|
||||
$data = $request->validated();
|
||||
$perPage = 3;
|
||||
$selectedFilters = [];
|
||||
|
||||
$category = $data['category'];
|
||||
|
|
@ -239,7 +243,8 @@ class PostsController extends Controller
|
|||
->unique()
|
||||
->values();
|
||||
|
||||
$selectedTags = $publishedDocumentsTags->filter(fn ($tag) => $requestedTags->contains($tag->slug ?? null))
|
||||
$selectedTags = $publishedDocumentsTags
|
||||
->filter(fn ($tag) => $requestedTags->contains($tag->slug ?? null))
|
||||
->map(fn ($tag) => [
|
||||
'id' => $tag->id,
|
||||
'title' => $tag->name,
|
||||
|
|
@ -300,20 +305,24 @@ class PostsController extends Controller
|
|||
|
||||
$filters = $this->getFilters('documents', $category, $publishedDocumentsTags, $documentsModel);
|
||||
|
||||
/** Custom pagination */
|
||||
// Custom pagination.
|
||||
$documentsModel = CollectionHelper::paginate($documentsModel, $perPage);
|
||||
|
||||
return response()->json([
|
||||
'pagination' => [
|
||||
'total' => $documentsModel->total(),
|
||||
'nbItems' => count($documentsModel->items()),
|
||||
'pagination' => [
|
||||
'total' => $documentsModel->total(),
|
||||
'nbItems' => count($documentsModel->items()),
|
||||
'currentPage' => $documentsModel->currentPage(),
|
||||
'lastPage' => $documentsModel->lastPage(),
|
||||
'hasMore' => $documentsModel->currentPage() < $documentsModel->lastPage(),
|
||||
'lastPage' => $documentsModel->lastPage(),
|
||||
'hasMore' => $documentsModel->currentPage() < $documentsModel->lastPage(),
|
||||
],
|
||||
'filters' => view('components.front.posts.filters-dropdowns', ['filters' => $filters])->render(),
|
||||
'selectedFilters' => view('components.front.posts.selected-filters', ['selectedFilters' => $selectedFilters])->render(),
|
||||
'news' => view('components.front.posts.documents', ['documentsList' => $documentsModel->items()])->render()
|
||||
'filters' => view('components.front.posts.filters-dropdowns', ['filters' => $filters])->render(),
|
||||
'selectedFilters' => view('components.front.posts.selected-filters', [
|
||||
'selectedFilters' => $selectedFilters,
|
||||
])->render(),
|
||||
'news' => view('components.front.posts.documents', [
|
||||
'documentsList' => $documentsModel->items(),
|
||||
])->render()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,18 +4,7 @@ namespace App\Http\Controllers\Front;
|
|||
|
||||
use App\Http\Requests\Front\Search\SearchAjaxRequest;
|
||||
use App\Http\Requests\Front\Search\SearchRequest;
|
||||
use App\Models\Document;
|
||||
use App\Models\DynamicPage;
|
||||
use App\Models\News;
|
||||
use App\Enums\Document\DocumentStatusEnum;
|
||||
use App\Enums\News\NewsStatusEnum;
|
||||
use App\Enums\DynamicPages\PageStatusEnum;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Mcamara\LaravelLocalization\LaravelLocalization;
|
||||
use Uwil\LaravelCommon\Controllers\Controller;
|
||||
use Uwil\LaravelCommon\Helpers\CollectionHelper;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
|
|
@ -25,7 +14,7 @@ class SearchController extends Controller
|
|||
* @param \App\Http\Requests\Front\Search\SearchRequest $request
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function search(SearchRequest $request)
|
||||
public function search(SearchRequest $request): \Illuminate\Contracts\View\View
|
||||
{
|
||||
$queryKey = trans('front.search.query');
|
||||
$searchTerm = $request->validated()[$queryKey];
|
||||
|
|
@ -46,85 +35,87 @@ class SearchController extends Controller
|
|||
$currentPage = (int) $request->validated()['page'];
|
||||
$currentLocale = $request->validated()['locale'];
|
||||
$perPage = 5;
|
||||
|
||||
|
||||
app()->setLocale($currentLocale);
|
||||
$searchQuery = $this->buildExactSearchQuery($searchTerm);
|
||||
|
||||
|
||||
$models = $class::search($searchQuery, function ($engine, $query, $options) use ($class, $currentLocale) {
|
||||
$options['attributesToSearchOn'] = $class::searchTransFields($currentLocale);
|
||||
return $engine->search($query, $options);
|
||||
})
|
||||
->where('status', $class::searchStatusEnum())
|
||||
->paginateRaw(perPage: $perPage, page: $currentPage);
|
||||
|
||||
|
||||
// Render items.
|
||||
$itemsHtml = collect($models['hits'])->map(fn ($result) =>
|
||||
view('components.front.search.card', [
|
||||
'class' => $class,
|
||||
'result' => $result,
|
||||
'mainField' => $class::searchMainField(),
|
||||
'routeName' => $class::searchRouteName($result['id_key'] ?? null),
|
||||
'customBreadcrumbs' => true,
|
||||
'searchTerm' => $searchTerm,
|
||||
'currentLocale' => $currentLocale,
|
||||
])->render()
|
||||
)->implode('');
|
||||
|
||||
$itemsHtml = collect($models['hits'])->map(fn ($result) => view('components.front.search.card', [
|
||||
'class' => $class,
|
||||
'result' => $result,
|
||||
'mainField' => $class::searchMainField(),
|
||||
'routeName' => $class::searchRouteName($result['id_key'] ?? null),
|
||||
'customBreadcrumbs' => true,
|
||||
'searchTerm' => $searchTerm,
|
||||
'currentLocale' => $currentLocale,
|
||||
])->render())->implode('');
|
||||
|
||||
// Pagination.
|
||||
$paginationHtml = view('components.front.search.pagination', [
|
||||
'models' => $models,
|
||||
])->render();
|
||||
|
||||
|
||||
return response()->json([
|
||||
'items' => $itemsHtml,
|
||||
'pagination' => $paginationHtml,
|
||||
'totalHits' => $models['totalHits'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set strict search term.
|
||||
*
|
||||
*
|
||||
* @param string $searchTerm
|
||||
* @return string
|
||||
*/
|
||||
private function buildExactSearchQuery(string $searchTerm): string
|
||||
{
|
||||
$words = preg_split('/\s+/', trim($searchTerm), -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
|
||||
if (count($words) === 1) {
|
||||
return '"' . $words[0] . '"';
|
||||
}
|
||||
|
||||
$exactTerms = array_map(function($word) {
|
||||
|
||||
$exactTerms = array_map(function ($word) {
|
||||
return $word . '*';
|
||||
}, $words);
|
||||
|
||||
|
||||
return '+' . implode(' +', $exactTerms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlights all search terms in a text.
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $searchTerm
|
||||
* @param string $text
|
||||
* @param string $searchTerm
|
||||
* @param integer $contextLength
|
||||
* @return string
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
public static function highlightTerms(string $text, string $searchTerm, int $contextLength = 150): string
|
||||
{
|
||||
// phpcs:enable
|
||||
if (trim($searchTerm) === '') {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
// Clean terms list.
|
||||
$words = preg_split('/\s+/', $searchTerm, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (empty($words)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
$fullText = strip_tags($text);
|
||||
$textLength = strlen($fullText);
|
||||
$ranges = [];
|
||||
|
||||
|
||||
// Collection of relevant ranges around each word.
|
||||
foreach ($words as $word) {
|
||||
$pattern = '/(?<!\w)' . preg_quote($word, '/') . '(?!\w)/iu';
|
||||
|
|
@ -140,12 +131,12 @@ class SearchController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return the entire text if there isn't matches.
|
||||
if (empty($ranges)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
// Merging overlapping intervals.
|
||||
usort($ranges, fn($a, $b) => $a['start'] <=> $b['start']);
|
||||
$merged = [];
|
||||
|
|
@ -159,21 +150,21 @@ class SearchController extends Controller
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$snippets = [];
|
||||
|
||||
|
||||
foreach ($merged as $r) {
|
||||
$snippet = substr($fullText, $r['start'], $r['end'] - $r['start']);
|
||||
|
||||
// Cut cleanly without breaking the words
|
||||
|
||||
// Cut cleanly without breaking the words.
|
||||
if ($r['start'] > 0) {
|
||||
$snippet = preg_replace('/^\S*\s/', '…', $snippet, 1);
|
||||
}
|
||||
if ($r['end'] < $textLength) {
|
||||
$snippet = preg_replace('/\s\S*$/', '…', $snippet, 1);
|
||||
}
|
||||
|
||||
// Highlighting searched words
|
||||
|
||||
// Highlighting searched words.
|
||||
foreach ($words as $word) {
|
||||
$pattern = '/(?<!\w)' . preg_quote($word, '/') . '(?!\w)/iu';
|
||||
$snippet = preg_replace(
|
||||
|
|
@ -182,14 +173,16 @@ class SearchController extends Controller
|
|||
$snippet
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$snippets[] = trim($snippet);
|
||||
if (count($snippets) >= 3) break;
|
||||
}
|
||||
|
||||
if (count($snippets) >= 3) {
|
||||
break;
|
||||
}
|
||||
} //end foreach
|
||||
|
||||
$result = implode('… ', $snippets);
|
||||
$result = preg_replace('/\s*…\s*(?:…\s*)+/', ' … ', $result);
|
||||
|
||||
|
||||
return trim($result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ class ForceLocale
|
|||
* The issue occurred when two browser tabs were open in different locales:
|
||||
* the data being saved could end up using the other tab’s locale.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
* @throws ValidationException Not supported locale.
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
|
|
@ -31,16 +32,9 @@ class ForceLocale
|
|||
return $next($request);
|
||||
}
|
||||
|
||||
// 1️⃣ Session
|
||||
if (Session::has('lang')) {
|
||||
$locale = Session::get('lang');
|
||||
}
|
||||
// 2️⃣ FallBack
|
||||
else {
|
||||
$locale = config('app.fallback_locale');
|
||||
}
|
||||
|
||||
$locale = (Session::has('lang')) ? Session::get('lang') : config('app.fallback_locale');
|
||||
App::setLocale($locale);
|
||||
|
||||
// 1. Is Post method or Inertia request ?
|
||||
if (
|
||||
in_array($request->method(), ['POST', 'PUT', 'PATCH'], true) and
|
||||
|
|
@ -50,7 +44,7 @@ class ForceLocale
|
|||
$requestLocale = $request->locale ?? config('app.fallback_locale');
|
||||
// 2. If prefix is not in supportedLocales
|
||||
if (!in_array($requestLocale, LaravelLocalization::getSupportedLanguagesKeys(), true)) {
|
||||
throw ValidationException::withMessages(["Langue" => "locale pas accepté"]);
|
||||
throw ValidationException::withMessages(["Langue" => "Not supported locale."]);
|
||||
}
|
||||
// 3. Set new locale if locale and prefix are not the same
|
||||
if ($requestLocale !== app()->getLocale()) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Enums\StaticRoutes;
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Enums\ModelsList;
|
||||
use App\Enums\StaticRoutesEnum;
|
||||
use App\Helpers\TranslationHelper;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyActivity;
|
||||
|
|
@ -138,9 +138,9 @@ class HandleInertiaRequests extends Middleware
|
|||
'enumUserRole' => RoleEnum::toArray(),
|
||||
'enumDynamicFieldTypes' => DynamicFieldTypes::toArray(),
|
||||
'enumModelsList' => ModelsList::toArray(),
|
||||
'enumStaticRoutes' => StaticRoutesEnum::getRoutes(),
|
||||
'errors' => $errors,
|
||||
'translations' => $translations,
|
||||
'contactFormRoutes' => StaticRoutes::getRoutes(),
|
||||
];
|
||||
if (Breadcrumbs::exists($request->route()->getName())) {
|
||||
$props = array_merge($props, [
|
||||
|
|
|
|||
|
|
@ -5,13 +5,18 @@ namespace App\Http\Middleware;
|
|||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
||||
class Lang
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
* Not used but need it for uwil package.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): mixed
|
||||
{
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
namespace App\Http\Requests\Back\Companies;
|
||||
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Traits\Requests\HasInertiaPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
use Uwil\LaravelCommon\Rules\WysiwygLength;
|
||||
|
||||
class StoreCompanyRequest extends FormRequest
|
||||
{
|
||||
|
|
@ -44,11 +43,13 @@ class StoreCompanyRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|between:3,255',
|
||||
'logo' => $this->pictureRules('required|nullable|file|mimes:jpg,jpeg,png,webp|max:5120|dimensions:width=500,height=500'),
|
||||
'name' => 'required|string|between:3,255|unique:companies,name',
|
||||
'logo' => $this->pictureRules(
|
||||
'required|nullable|file|mimes:jpg,jpeg,png,webp|max:5120|dimensions:width=500,height=500',
|
||||
),
|
||||
'responsable' => 'required|nullable|string|between:3,255',
|
||||
'url' => 'required|nullable|string|between:3,255',
|
||||
'informations' => 'required|string|between:3,255',
|
||||
'url' => 'nullable|string|between:3,255',
|
||||
'informations' => ['required', 'string', new WysiwygLength(10, 5000)],
|
||||
'employees' => 'required|nullable|numeric|between:0,100000',
|
||||
'latitude' => 'required|numeric|between:-90,90',
|
||||
'longitude' => 'required|numeric|between:-180,180',
|
||||
|
|
|
|||
|
|
@ -15,4 +15,22 @@ class UpdateCompanyRequest extends StoreCompanyRequest
|
|||
{
|
||||
return Gate::check('update', $this->route('company'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'between:3,255',
|
||||
'unique:companies,name,' . request()->company->getKey(),
|
||||
],
|
||||
];
|
||||
return \array_merge(parent::rules(), $rules);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace App\Http\Requests\Back\CompanyActivities;
|
||||
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Models\CompanyActivity;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreCompanyActivityRequest extends FormRequest
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace App\Http\Requests\Back\CompanySectors;
|
||||
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Models\CompanySector;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class StoreCompanySectorRequest extends FormRequest
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class StoreDocumentRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
@ -67,5 +69,4 @@ class StoreDocumentRequest extends FormRequest
|
|||
'is_issuu' => trans('validation.custom.is_issuu'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ class UpdateDocumentRequest extends StoreDocumentRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('document'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class StoreDocumentCategoryRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class UpdateDocumentCategoryRequest extends StoreDocumentCategoryRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class StoreDocumentTagRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class UpdateDocumentTagRequest extends StoreDocumentTagRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
class ModelListRequest extends FormRequest
|
||||
{
|
||||
use HasLaravelFailedValidation;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ class StoreNewsRequest extends FormRequest
|
|||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class StoreNewsCategoryRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
@ -24,12 +26,12 @@ class StoreNewsCategoryRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'slug' => 'required|string|between:3,255',
|
||||
'name' => 'required|string|between:3,255',
|
||||
'slug' => 'required|string|between:3,255',
|
||||
'name' => 'required|string|between:3,255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
|
|
@ -37,7 +39,7 @@ class StoreNewsCategoryRequest extends FormRequest
|
|||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => trans('validation.custom.name'),
|
||||
'name' => trans('validation.custom.name'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ class UpdateNewsCategoryRequest extends StoreNewsCategoryRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('news_category'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class StoreNewsTagRequest extends FormRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
|
|
@ -30,7 +32,7 @@ class StoreNewsTagRequest extends FormRequest
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
|
|
@ -38,8 +40,8 @@ class StoreNewsTagRequest extends FormRequest
|
|||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => trans('validation.custom.name'),
|
||||
'color' => trans('validation.custom.color'),
|
||||
'name' => trans('validation.custom.name'),
|
||||
'color' => trans('validation.custom.color'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ class UpdateNewsTagRequest extends StoreNewsTagRequest
|
|||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Gate::check('update', $this->route('news_tag'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ class StorePageConfigRequest extends FormRequest
|
|||
/**
|
||||
* Recursively generates rules for a given key.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param integer $depth
|
||||
* @return array
|
||||
*/
|
||||
protected function configRules(string $prefix, int $depth = 1): array
|
||||
|
|
@ -66,7 +68,7 @@ class StorePageConfigRequest extends FormRequest
|
|||
|
||||
if ($depth < 10) {
|
||||
$rules["{$prefix}.children"] = ['sometimes', 'array'];
|
||||
$rules += $this->configRules("{$prefix}.children.*", $depth + 1);
|
||||
$rules += $this->configRules("{$prefix}.children.*", $depth + 1);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
|
@ -89,6 +91,8 @@ class StorePageConfigRequest extends FormRequest
|
|||
/**
|
||||
* Recursively generates attributes for a given key.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @param integer $depth
|
||||
* @return array
|
||||
*/
|
||||
protected function configAttributes(string $prefix, int $depth = 1): array
|
||||
|
|
@ -101,12 +105,12 @@ class StorePageConfigRequest extends FormRequest
|
|||
"{$prefix}.label" => trans('validation.custom.label'),
|
||||
"{$prefix}.validation" => trans('validation.custom.validation'),
|
||||
];
|
||||
|
||||
|
||||
if ($depth < 10) {
|
||||
$rules["{$prefix}.children"] = trans('validation.custom.children');
|
||||
$rules += $this->configAttributes("{$prefix}.children.*", $depth + 1);
|
||||
$rules += $this->configAttributes("{$prefix}.children.*", $depth + 1);
|
||||
}
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace App\Http\Requests\Back;
|
|||
|
||||
use App\Enums\ElementPositionEnum;
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Enums\StaticRoutesEnum;
|
||||
use App\Models\PageConfig;
|
||||
use App\Traits\Requests\HasInertiaPicture;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
|
@ -61,10 +62,15 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
/**
|
||||
* Get rules from a specific input type.
|
||||
*
|
||||
* @param array $input
|
||||
* @param string $prefix
|
||||
* @return array
|
||||
* @throws \UnexpectedValueException Unrecognized dynamic type.
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
private function recursiveRules(&$input, $prefix): array
|
||||
private function recursiveRules(array &$input, string $prefix): array
|
||||
{
|
||||
// phpcs:enable
|
||||
$rules = [];
|
||||
$ruleKey = "$prefix.$input[key]";
|
||||
switch ($input['type']) {
|
||||
|
|
@ -86,7 +92,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
// remove them from the rules so that our custom rule WysiwygLength can apply it.
|
||||
$defaults = $this->extractMinMax($defaultRules);
|
||||
['min' => $min, 'max' => $max] = $this->extractMinMax($wysiwygRules, $defaults);
|
||||
$newWysiwygRules = array_values(array_filter($wysiwygRules, fn($rule) => !(
|
||||
$newWysiwygRules = array_values(array_filter($wysiwygRules, fn($rule) => !(
|
||||
is_string($rule) && preg_match('/^(min|max|between):/', $rule)
|
||||
)));
|
||||
|
||||
|
|
@ -112,7 +118,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
case DynamicFieldTypes::url->value:
|
||||
$rules = array_merge($rules, [
|
||||
$ruleKey => array_merge(explode("|", DynamicFieldTypes::url->getValidation()), [
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
try {
|
||||
ToolboxHelper::assertNoInternalUrls($attribute, $value);
|
||||
|
|
@ -173,29 +179,30 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
case DynamicFieldTypes::model->value:
|
||||
// Set a new rule key for the model name.
|
||||
$ruleKeyReserved = preg_replace('/([^.\s]+)$/', 'reserved_$1', $ruleKey);
|
||||
$rules = array_merge($rules, [
|
||||
$ruleKey => $this->compileValidate(DynamicFieldTypes::model->getValidation(), $input),
|
||||
$rules = array_merge($rules, [
|
||||
$ruleKey => $this->compileValidate(DynamicFieldTypes::model->getValidation(), $input),
|
||||
$ruleKeyReserved => 'required|string|between:3,255',
|
||||
]);
|
||||
break;
|
||||
case DynamicFieldTypes::staticroute->value:
|
||||
$rules = array_merge($rules, [
|
||||
$ruleKey => array_merge($this->compileValidate(DynamicFieldTypes::staticroute->getValidation(), $input), [
|
||||
new Enum(ElementPositionEnum::class),
|
||||
])
|
||||
$ruleKey => array_merge(
|
||||
$this->compileValidate(DynamicFieldTypes::staticroute->getValidation(), $input),
|
||||
[new Enum(StaticRoutesEnum::class)],
|
||||
),
|
||||
]);
|
||||
break;
|
||||
// Specific inputs.
|
||||
case DynamicFieldTypes::position->value:
|
||||
$rules = array_merge($rules, [
|
||||
$ruleKey => array_merge($this->compileValidate(DynamicFieldTypes::position->getValidation(), $input), [
|
||||
new Enum(ElementPositionEnum::class),
|
||||
])
|
||||
$ruleKey => array_merge(
|
||||
$this->compileValidate(DynamicFieldTypes::position->getValidation(), $input),
|
||||
[new Enum(ElementPositionEnum::class)],
|
||||
),
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
throw new \UnexpectedValueException("Unrecognized dynamic type: " . ($input['type'] ?? 'null'));
|
||||
break;
|
||||
} //end switch
|
||||
return $rules;
|
||||
}
|
||||
|
|
@ -217,9 +224,11 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
/**
|
||||
* Get attributes from a specific input type.
|
||||
*
|
||||
* @param array $input
|
||||
* @param string $prefix
|
||||
* @return array
|
||||
*/
|
||||
private function recursiveAttributes(&$input, $prefix): array
|
||||
private function recursiveAttributes(array &$input, string $prefix): array
|
||||
{
|
||||
$attributes = [];
|
||||
$attributeKey = sprintf("%s.%s", $prefix, $input['key']);
|
||||
|
|
@ -271,7 +280,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
* @param array $input
|
||||
* @return array
|
||||
*/
|
||||
private function mergeValidations($defaultValidations, $input): array
|
||||
private function mergeValidations(string|array $defaultValidations, array $input): array
|
||||
{
|
||||
if (\is_string($defaultValidations)) {
|
||||
$defaultValidations = explode('|', $defaultValidations);
|
||||
|
|
@ -305,7 +314,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
$defaultValidations[] = $validate;
|
||||
}
|
||||
}
|
||||
}
|
||||
} //end foreach
|
||||
return $defaultValidations;
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +369,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
}
|
||||
// Check if the key start with the pattern enum_.
|
||||
if (str_starts_with($key, sprintf("%s_", DynamicFieldTypes::boolean->name))) {
|
||||
// Manages values "true", "false", "1", "0", 1, 0, "on", "off".
|
||||
// Accepts boolean-like values (true/false, one/zero, on/off) as strings or numbers.
|
||||
$data[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +379,7 @@ abstract class UpdateDynamicFieldRequest extends FormRequest
|
|||
/**
|
||||
* Extract min and max values from laravel validation.
|
||||
*
|
||||
* @param array $rules
|
||||
* @param array $rules
|
||||
* @param array|null $fallback
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,7 +27,14 @@ class UploadFileRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'upload' => 'required|image|mimes:jpeg,png,jpg|max:5048|dimensions:min_width=567,min_height=567,max_width:1008,max_height:1008'
|
||||
'upload' => [
|
||||
'required',
|
||||
'image',
|
||||
'mimes:jpeg,png,jpg',
|
||||
'max:5048',
|
||||
'dimensions:min_width=567,min_height=567,max_width:1008,max_height:1008',
|
||||
],
|
||||
'folder' => 'required|string|between:3,255',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,52 +20,50 @@ class ContactRequest extends FormRequest
|
|||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
// ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
ToolboxHelper::validateRecaptcha($this, \config('services.google.recaptcha.version'));
|
||||
|
||||
$typeContactForm = $this->input('enumType');
|
||||
|
||||
/** Validation for common fields */
|
||||
// Validation for common fields.
|
||||
$rules = [
|
||||
'enumType' => ['required', Rule::enum(ContactFormType::class)],
|
||||
'lastname' => ['required', 'min:1', 'max:60'],
|
||||
'enumType' => ['required', Rule::enum(ContactFormType::class)],
|
||||
'lastname' => ['required', 'min:1', 'max:60'],
|
||||
'firstname' => ['required', 'min:1', 'max:60'],
|
||||
'message' => ['required', 'min:10', 'max:255'],
|
||||
'email' => ['required', 'min:1', 'max:60', 'email:rfc,dns,spoof'],
|
||||
'message' => ['required', 'min:10', 'max:255'],
|
||||
'email' => ['required', 'min:1', 'max:60', 'email:rfc,dns,spoof'],
|
||||
];
|
||||
|
||||
/** Validation for breeder enum */
|
||||
// Validation for breeder enum.
|
||||
if (ContactFormType::breeder->equals(ContactFormType::make($typeContactForm))) {
|
||||
$breeder = [
|
||||
'phone' => ['required', 'min:1', 'max:60'],
|
||||
'typeelevage' => ['array', 'min:1'],
|
||||
$rules = array_merge($rules, [
|
||||
'phone' => ['required', 'min:1', 'max:60'],
|
||||
'typeelevage' => ['array', 'min:1'],
|
||||
'typeelevage.*' => [Rule::enum(BreedType::class)],
|
||||
'zonegeo' => ['array', 'min:1'],
|
||||
'zonegeo.*' => [Rule::enum(Department::class)],
|
||||
];
|
||||
$rules = array_merge($rules, $breeder);
|
||||
'zonegeo' => ['array', 'min:1'],
|
||||
'zonegeo.*' => [Rule::enum(Department::class)],
|
||||
]);
|
||||
}
|
||||
|
||||
/** Validation for restauration enum */
|
||||
// Validation for restauration enum.
|
||||
if (ContactFormType::restauration->equals(ContactFormType::make($typeContactForm))) {
|
||||
$restauration = [
|
||||
'company' => 'string|max:255',
|
||||
];
|
||||
$rules = array_merge($rules, $restauration);
|
||||
$rules = array_merge($rules, [
|
||||
'company' => 'string|max:255',
|
||||
]);
|
||||
}
|
||||
|
||||
/** Add the country field */
|
||||
// Add the country field.
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::commitments->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::info->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addCountry = [
|
||||
$rules = array_merge($rules, [
|
||||
'country' => ['required', 'min:1', 'max:150'],
|
||||
];
|
||||
$rules = array_merge($rules, $addCountry);
|
||||
]);
|
||||
}
|
||||
|
||||
/** Add the optional phone field */
|
||||
// Add the optional phone field.
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
|
|
@ -73,13 +71,12 @@ class ContactRequest extends FormRequest
|
|||
ContactFormType::commitments->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::info->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addNoRequiredPhone = [
|
||||
$rules = array_merge($rules, [
|
||||
'phone' => ['max:60'],
|
||||
];
|
||||
$rules = array_merge($rules, $addNoRequiredPhone);
|
||||
]);
|
||||
}
|
||||
|
||||
/** Add the town and postalcode fields */
|
||||
// Add the town and postalcode fields.
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm)) ||
|
||||
|
|
@ -88,35 +85,33 @@ class ContactRequest extends FormRequest
|
|||
ContactFormType::info->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::press->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$addTownAndPostalCodeFields = [
|
||||
'town' => 'string|required|min:2|max:255',
|
||||
'postalcode' => 'string|required|min:2|max:60',
|
||||
];
|
||||
$rules = array_merge($rules, $addTownAndPostalCodeFields);
|
||||
$rules = array_merge($rules, [
|
||||
'town' => 'string|required|min:2|max:255',
|
||||
'postalcode' => 'string|required|min:2|max:60',
|
||||
]);
|
||||
}
|
||||
|
||||
/** Validation for restauration and export commun fields */
|
||||
// Validation for restauration and export commun fields.
|
||||
if (
|
||||
ContactFormType::restauration->equals(ContactFormType::make($typeContactForm)) ||
|
||||
ContactFormType::export->equals(ContactFormType::make($typeContactForm))
|
||||
) {
|
||||
$restaurationExport = [
|
||||
'type' => ['array', 'min:1'],
|
||||
$rules = array_merge($rules, [
|
||||
'type' => ['array', 'min:1'],
|
||||
'type.*' => [Rule::enum(CustomerAskingType::class)],
|
||||
];
|
||||
$rules = array_merge($rules, $restaurationExport);
|
||||
]);
|
||||
}
|
||||
|
||||
/** Validation for press enum */
|
||||
// Validation for press enum.
|
||||
if (ContactFormType::press->equals(ContactFormType::make($typeContactForm))) {
|
||||
$press = [
|
||||
'subject' => ['required', Rule::enum(PressType::class)],
|
||||
'company' => 'required|string|min:2|max:255',
|
||||
'phone' => ['required', 'max:60'],
|
||||
$rules = array_merge($rules, [
|
||||
'subject' => ['required', Rule::enum(PressType::class)],
|
||||
'company' => 'required|string|min:2|max:255',
|
||||
'phone' => ['required', 'max:60'],
|
||||
'newsletter' => 'boolean'
|
||||
];
|
||||
$rules = array_merge($rules, $press);
|
||||
]);
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,16 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
class PostsRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
|
@ -24,18 +14,15 @@ class PostsRequest extends FormRequest
|
|||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'page' => ['required', 'integer'],
|
||||
'category' => ['required', 'string'],
|
||||
'locale' => ['required', 'string'],
|
||||
|
||||
'filters' => ['nullable', 'array'],
|
||||
'filters.order' => ['nullable', 'string', 'in:asc,desc'],
|
||||
|
||||
'filters.tags' => ['nullable', 'array'],
|
||||
'filters.tags.*'=> ['string'],
|
||||
|
||||
'filters.years' => ['nullable', 'array'],
|
||||
'filters.years.*' => ['string'],
|
||||
'page' => 'required|integer',
|
||||
'category' => 'required|string',
|
||||
'locale' => 'required|string',
|
||||
'filters' => 'nullable|array',
|
||||
'filters.order' => 'nullable|string|in:asc,desc',
|
||||
'filters.tags' => 'nullable|array',
|
||||
'filters.tags.*' => 'string',
|
||||
'filters.years' => 'nullable|array',
|
||||
'filters.years.*' => 'string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
|
||||
class CleanTrashModels implements ShouldQueue, ShouldBeUnique
|
||||
|
|
@ -44,7 +43,5 @@ class CleanTrashModels implements ShouldQueue, ShouldBeUnique
|
|||
->cursor()
|
||||
->each(fn($model) => $model->forceDelete());
|
||||
});
|
||||
|
||||
dd($models);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ use Illuminate\Mail\Mailables\Address;
|
|||
|
||||
class ContactMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The order instance.
|
||||
|
|
@ -21,7 +22,6 @@ class ContactMail extends Mailable
|
|||
*/
|
||||
protected $data;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
|
|
@ -33,14 +33,12 @@ class ContactMail extends Mailable
|
|||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*
|
||||
* @return \Illuminate\Mail\Mailables\Envelope
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
public function envelope(): \Illuminate\Mail\Mailables\Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
from: new Address(\config('mail.from.address'), \config('mail.from.name')),
|
||||
|
|
@ -52,13 +50,12 @@ class ContactMail extends Mailable
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*
|
||||
* @return \Illuminate\Mail\Mailables\Content
|
||||
*/
|
||||
public function content(): Content
|
||||
public function content(): \Illuminate\Mail\Mailables\Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.contact',
|
||||
|
|
@ -67,7 +64,6 @@ class ContactMail extends Mailable
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use App\Traits\Models\HasTranslations;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
|
||||
|
||||
|
|
@ -111,8 +110,8 @@ class CompanyActivity extends Model implements TranslatableModel
|
|||
TranslationHelper::validateFallbackTranslations($model);
|
||||
}
|
||||
|
||||
// RELATIONSHIPS
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Get companies for this activity.
|
||||
*
|
||||
|
|
@ -122,4 +121,4 @@ class CompanyActivity extends Model implements TranslatableModel
|
|||
{
|
||||
return $this->hasMany(Company::class, 'activity_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use App\Traits\Models\HasTranslations;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
|
||||
|
||||
|
|
@ -109,8 +108,8 @@ class CompanySector extends Model implements TranslatableModel
|
|||
TranslationHelper::validateFallbackTranslations($model);
|
||||
}
|
||||
|
||||
// RELATIONSHIPS
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* Get companies for this sector.
|
||||
*
|
||||
|
|
@ -120,4 +119,4 @@ class CompanySector extends Model implements TranslatableModel
|
|||
{
|
||||
return $this->hasMany(Company::class, 'sector_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,20 +290,33 @@ class Document extends Model implements TranslatableModel
|
|||
'status' => $this->status->value,
|
||||
];
|
||||
foreach ($locales as $locale => $_) {
|
||||
$data["name_$locale"] = $this->hasTranslation('name', $locale) ? $this->getTranslation('name', $locale) : null;
|
||||
$data["path_$locale"] = $this->hasTranslation('path', $locale) ? $this->getTranslation('path', $locale) : null;
|
||||
$data["name_$locale"] = $this->hasTranslation('name', $locale)
|
||||
? $this->getTranslation('name', $locale)
|
||||
: null;
|
||||
$data["path_$locale"] = $this->hasTranslation('path', $locale)
|
||||
? $this->getTranslation('path', $locale)
|
||||
: null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function inertiaFill(array $attributes)
|
||||
/**
|
||||
* Override HasUwilImages trait method to fill the model without relations.
|
||||
*
|
||||
* @param array $attributes The attributes to fill the model with.
|
||||
* @return void
|
||||
*/
|
||||
public function inertiaFill(array $attributes): void
|
||||
{
|
||||
// Set issu_path if defined.
|
||||
$issuuPath = data_get($attributes, "issuu_path");
|
||||
if($issuuPath)
|
||||
{
|
||||
$attributes['issuu_path'] = DocumentHelper::extractDocumentFromIssuIframe(data_get($attributes, "issuu_path"));
|
||||
if ($issuuPath) {
|
||||
$attributes['issuu_path'] = DocumentHelper::extractDocumentFromIssuIframe(
|
||||
data_get($attributes, "issuu_path"),
|
||||
);
|
||||
}
|
||||
// Ommit some relations.
|
||||
$attributes = Arr::except($attributes, ['tags', 'categories']);
|
||||
$this->traitInertiaFill($attributes);
|
||||
}
|
||||
|
|
@ -324,13 +337,12 @@ class Document extends Model implements TranslatableModel
|
|||
->filter(function ($document) use ($category, $locale) {
|
||||
$hasPath = !empty($document->getTranslation('path', $locale, false));
|
||||
|
||||
$hasIssuuPath = $document->is_issuu === true && !empty($document->getTranslation('issuu_path', $locale, false));
|
||||
$hasIssuuPath = $document->is_issuu === true
|
||||
&& !empty($document->getTranslation('issuu_path', $locale, false));
|
||||
|
||||
return
|
||||
($hasPath || $hasIssuuPath)
|
||||
&& $document->categories->contains(
|
||||
fn($cat) => $cat->slug === $category
|
||||
);
|
||||
return ($hasPath || $hasIssuuPath) && $document->categories->contains(
|
||||
fn($cat) => $cat->slug === $category
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,27 +68,28 @@ class DocumentTag extends Model implements TranslatableModel
|
|||
/**
|
||||
* Get all Tags by category.
|
||||
*
|
||||
* @param string $category
|
||||
* @param string $slugCategory
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public static function getTagsByCategoryInCurrentLocale(string $category): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
public static function getTagsByCategoryInCurrentLocale(
|
||||
string $slugCategory,
|
||||
): \Illuminate\Database\Eloquent\Collection {
|
||||
$locale = App::getLocale();
|
||||
|
||||
return DocumentTag::getModelsCached()->load('documents.categories')->filter(function ($tag) use ($locale, $category) {
|
||||
return $tag->documents->filter(function ($document) use ($locale, $category) {
|
||||
return DocumentTag::getModelsCached()
|
||||
->load('documents.categories')
|
||||
->filter(function ($tag) use ($locale, $slugCategory) {
|
||||
return $tag->documents->filter(function ($document) use ($locale, $slugCategory) {
|
||||
$hasPath = !empty($document->getTranslation('path', $locale, false));
|
||||
$hasIssuuPath = $document->is_issuu === true;
|
||||
|
||||
$hasPath = !empty($document->getTranslation('path', $locale, false));
|
||||
|
||||
$hasIssuuPath = $document->is_issuu === true;
|
||||
|
||||
return (
|
||||
$hasPath || $hasIssuuPath
|
||||
) && $document->categories->contains(
|
||||
fn($cat) => $cat->slug === $category
|
||||
);
|
||||
})->isNotEmpty();
|
||||
});
|
||||
return (
|
||||
$hasPath || $hasIssuuPath
|
||||
) && $document->categories->contains(
|
||||
fn($cat) => $cat->slug === $slugCategory
|
||||
);
|
||||
})->isNotEmpty();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Contracts\TranslatableModel;
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Enums\DynamicPages;
|
||||
use App\Enums\DynamicPages\PageStatusEnum;
|
||||
use App\Helpers\DynamicPageHelper;
|
||||
use App\Helpers\RouteHelper;
|
||||
|
|
@ -12,17 +10,14 @@ use App\Helpers\TranslationHelper;
|
|||
use App\Traits\Models\HasCache;
|
||||
use App\Traits\Models\HasTranslations;
|
||||
use App\Traits\Models\HasUwilImages;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Laravel\Scout\Searchable;
|
||||
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
|
||||
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
|
||||
use Uwil\LaravelCommon\Helpers\FileHelper;
|
||||
|
||||
/**
|
||||
* @property string $id_key Unique key identification of the dynamic page.
|
||||
|
|
@ -136,11 +131,12 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Unpublished all children pages if change status published from draft/unpublished.
|
||||
*
|
||||
* @param self $model
|
||||
* @return boolean
|
||||
* @return void
|
||||
*/
|
||||
private static function setAllChildPageStatus(self $model): void
|
||||
{
|
||||
|
|
@ -159,7 +155,7 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
* Publish current page if all parents are published.
|
||||
*
|
||||
* @param self $model
|
||||
* @return boolean
|
||||
* @return void
|
||||
* @throws \Illuminate\Validation\ValidationException Parent must be published.
|
||||
*/
|
||||
private static function checkParentsStatus(self $model): void
|
||||
|
|
@ -198,7 +194,7 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
private static function manageFields(self $model): void
|
||||
{
|
||||
// Check unique fields.
|
||||
if($model->isRoot) {
|
||||
if ($model->isRoot) {
|
||||
self::assertRootIsUnique($model);
|
||||
} else {
|
||||
$slug = $model->slug ?? Str::slug($model->title);
|
||||
|
|
@ -218,10 +214,13 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
*/
|
||||
public static function assertRootIsUnique(self $model): void
|
||||
{
|
||||
$oldDynamicPageRoot = self::getModelsCached()->where('id', '!=', $model->getKey())->where('isRoot', true)->first();
|
||||
$oldDynamicPageRoot = self::getModelsCached()
|
||||
->where('id', '!=', $model->getKey())
|
||||
->where('isRoot', true)
|
||||
->first();
|
||||
if ($oldDynamicPageRoot) {
|
||||
$oldDynamicPageRoot->status = PageStatusEnum::unpublished;
|
||||
$oldDynamicPageRoot->isRoot = false;
|
||||
$oldDynamicPageRoot->isRoot = false;
|
||||
$oldDynamicPageRoot->saveQuietly();
|
||||
}
|
||||
}
|
||||
|
|
@ -394,7 +393,7 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
*/
|
||||
public function toSearchableArray(): array
|
||||
{
|
||||
$locales = config('laravellocalization.supportedLocales');
|
||||
$locales = LaravelLocalization::getSupportedLanguagesKeys();
|
||||
|
||||
$data = [
|
||||
'id' => $this->id,
|
||||
|
|
@ -402,24 +401,29 @@ class DynamicPage extends Model implements TranslatableModel
|
|||
'status' => $this->status->value,
|
||||
];
|
||||
|
||||
foreach ($locales as $locale => $_) {
|
||||
$data["title_$locale"] = $this->hasTranslation('title', $locale) ? $this->getTranslation('title', $locale) : null;
|
||||
$data["slug_$locale"] = $this->hasTranslation('slug', $locale) ? $this->getTranslation('slug', $locale) : null;
|
||||
foreach ($locales as $locale) {
|
||||
$data["title_$locale"] = $this->hasTranslation('title', $locale)
|
||||
? $this->getTranslation('title', $locale)
|
||||
: null;
|
||||
$data["slug_$locale"] = $this->hasTranslation('slug', $locale)
|
||||
? $this->getTranslation('slug', $locale)
|
||||
: null;
|
||||
|
||||
$content = $this->hasTranslation('content', $locale) ? strip_tags(collect($this->getTranslation('content', $locale))
|
||||
->flatten()
|
||||
->filter(fn($value, $key) =>
|
||||
is_string($value) &&
|
||||
!empty($value) &&
|
||||
!is_numeric($value) &&
|
||||
!in_array($key, ['order', 'id']) &&
|
||||
!str_starts_with($key, 'image_') &&
|
||||
!preg_match('/storage.*\.(?:png|jpe?g|gif|pdf|webp)/i', $value)
|
||||
)
|
||||
->values()
|
||||
->implode(' ')) : null;
|
||||
$content = $this->hasTranslation('content', $locale)
|
||||
? strip_tags(collect($this->getTranslation('content', $locale))
|
||||
->flatten()
|
||||
->filter(fn($value, $key) =>
|
||||
is_string($value) &&
|
||||
!empty($value) &&
|
||||
!is_numeric($value) &&
|
||||
!in_array($key, ['order', 'id']) &&
|
||||
!str_starts_with($key, 'image_') &&
|
||||
!preg_match('/storage.*\.(?:png|jpe?g|gif|pdf|webp)/i', $value))
|
||||
->values()
|
||||
->implode(' '))
|
||||
: null;
|
||||
$data["content_$locale"] = $content;
|
||||
}
|
||||
} //end foreach
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,24 +13,24 @@ use Illuminate\Database\Eloquent\Model;
|
|||
/**
|
||||
* This class is used to store data in memory only, not in databases.
|
||||
*
|
||||
* @property integer $id Id.
|
||||
* @property \App\Enums\Contact\ContactFormType $enumType The type enum.
|
||||
* @property string $lastname The customer's lastname.
|
||||
* @property string $firstname The customer's firstname.
|
||||
* @property string $message The message.
|
||||
* @property string $email The customer's email.
|
||||
* @property string|null $phone The customer's phone.
|
||||
* @property \App\Enums\Contact\BreedType[] $typeelevage The customer's breeding type
|
||||
* @property \App\Enums\Department[] $zonegeo The customer's greographic zone
|
||||
* @property string $company The customer's company.
|
||||
* @property string $country The customer's country.
|
||||
* @property string $town The customer's town.
|
||||
* @property string $postalcode The customer's postalcode.
|
||||
* @property boolean $newsletter The customer's optin response.
|
||||
* @property \App\Enums\Contact\CustomerAskingType[] $type The customer's type asking
|
||||
* @property \App\Enums\Contact\PressType $subject The message's subject
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
* @property integer $id Id.
|
||||
* @property \App\Enums\Contact\ContactFormType $enumType The type enum.
|
||||
* @property string $lastname The customer's lastname.
|
||||
* @property string $firstname The customer's firstname.
|
||||
* @property string $message The message.
|
||||
* @property string $email The customer's email.
|
||||
* @property string|null $phone The customer's phone.
|
||||
* @property \App\Enums\Contact\BreedType[] $typeelevage The customer's breeding type
|
||||
* @property \App\Enums\Department[] $zonegeo The customer's greographic zone
|
||||
* @property string $company The customer's company.
|
||||
* @property string $country The customer's country.
|
||||
* @property string $town The customer's town.
|
||||
* @property string $postalcode The customer's postalcode.
|
||||
* @property boolean $newsletter The customer's optin response.
|
||||
* @property \App\Enums\Contact\CustomerAskingType[] $type The customer's type asking
|
||||
* @property \App\Enums\Contact\PressType $subject The message's subject
|
||||
* @property-read \Carbon\Carbon $created_at Created date.
|
||||
* @property-read \Carbon\Carbon $updated_at Updated date.
|
||||
*/
|
||||
class MailContactData extends Model
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ class MailContactData extends Model
|
|||
'postalcode',
|
||||
'type',
|
||||
'subject',
|
||||
'newsletter'
|
||||
'newsletter',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -71,19 +71,21 @@ class MailContactData extends Model
|
|||
*/
|
||||
protected $casts = [
|
||||
'enumType' => ContactFormType::class,
|
||||
'typeelevage' => AsEnumArrayObject::class.':'.BreedType::class,
|
||||
'zonegeo' => AsEnumArrayObject::class.':'.Department::class,
|
||||
'type' => AsEnumArrayObject::class.':'.CustomerAskingType::class,
|
||||
'typeelevage' => AsEnumArrayObject::class . ':' . BreedType::class,
|
||||
'zonegeo' => AsEnumArrayObject::class . ':' . Department::class,
|
||||
'type' => AsEnumArrayObject::class . ':' . CustomerAskingType::class,
|
||||
'subject' => PressType::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Construct method.
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param array $attributes
|
||||
* @phpcs:disable Generic.CodeAnalysis.UselessOverridingMethod
|
||||
*/
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
// phpcs:enable
|
||||
parent::__construct($attributes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use App\Traits\Models\HasUwilImages;
|
|||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\App;
|
||||
|
|
@ -64,10 +63,13 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable
|
|||
/**
|
||||
* Get the value of the model's localized route key.
|
||||
*
|
||||
* @param string $locale
|
||||
* @return string
|
||||
* @phpcs:disable
|
||||
*/
|
||||
public function getLocalizedRouteKey($locale): string
|
||||
{
|
||||
// phpcs:enable
|
||||
return $this->getTranslation(
|
||||
$this->getRouteKeyName(),
|
||||
$locale
|
||||
|
|
@ -189,8 +191,15 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable
|
|||
self::makeStatusSense($model);
|
||||
}
|
||||
|
||||
public function inertiaFill(array $attributes)
|
||||
/**
|
||||
* Override HasUwilImages trait method to fill the model without relations.
|
||||
*
|
||||
* @param array $attributes The attributes to fill the model with.
|
||||
* @return void
|
||||
*/
|
||||
public function inertiaFill(array $attributes): void
|
||||
{
|
||||
// Ommit some relations.
|
||||
$attributes = Arr::except($attributes, ['categories', 'tags']);
|
||||
$this->traitInertiaFill($attributes);
|
||||
}
|
||||
|
|
@ -352,7 +361,7 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable
|
|||
* @param string $currentLocale
|
||||
* @return array
|
||||
*/
|
||||
public static function searchTransFields($currentLocale): array
|
||||
public static function searchTransFields(string $currentLocale): array
|
||||
{
|
||||
return [
|
||||
"title_$currentLocale",
|
||||
|
|
@ -405,9 +414,15 @@ class News extends Model implements TranslatableModel, LocalizedUrlRoutable
|
|||
'status' => $this->status->value,
|
||||
];
|
||||
foreach ($locales as $locale => $_) {
|
||||
$data["title_$locale"] = $this->hasTranslation('title', $locale) ? $this->getTranslation('title', $locale) : null;
|
||||
$data["slug_$locale"] = $this->hasTranslation('slug', $locale) ? $this->getTranslation('slug', $locale) : null;
|
||||
$data["content_$locale"] = $this->hasTranslation('content', $locale) ? strip_tags($this->getTranslation('content', $locale)) : null;
|
||||
$data["title_$locale"] = $this->hasTranslation('title', $locale)
|
||||
? $this->getTranslation('title', $locale)
|
||||
: null;
|
||||
$data["slug_$locale"] = $this->hasTranslation('slug', $locale)
|
||||
? $this->getTranslation('slug', $locale)
|
||||
: null;
|
||||
$data["content_$locale"] = $this->hasTranslation('content', $locale)
|
||||
? strip_tags($this->getTranslation('content', $locale))
|
||||
: null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Models;
|
|||
use App\Traits\Models\HasCache;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use App\Contracts\TranslatableModel;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Traits\Models\HasTranslations;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
|
@ -76,19 +75,22 @@ class NewsTag extends Model implements TranslatableModel
|
|||
/**
|
||||
* Get all Tags by category.
|
||||
*
|
||||
* @param string $slugCategory
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public static function getTagsByCategoryInCurrentLocale($category): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
public static function getTagsByCategoryInCurrentLocale(
|
||||
string $slugCategory,
|
||||
): \Illuminate\Database\Eloquent\Collection {
|
||||
$locale = App::getLocale();
|
||||
|
||||
return NewsTag::getModelsCached()->load('news.categories')->filter(function ($tag) use ($locale, $category) {
|
||||
return $tag->news->filter(function ($news) use ($locale, $category) {
|
||||
return !empty($news->getTranslation('slug', $locale, false)) && $news->categories->contains(
|
||||
fn ($cat) => $cat->slug === $category
|
||||
);
|
||||
})->isNotEmpty();
|
||||
});
|
||||
return NewsTag::getModelsCached()
|
||||
->load('news.categories')
|
||||
->filter(function ($tag) use ($locale, $slugCategory) {
|
||||
return $tag->news->filter(function ($news) use ($locale, $slugCategory) {
|
||||
return !empty($news->getTranslation('slug', $locale, false)) && $news->categories->contains(
|
||||
fn ($cat) => $cat->slug === $slugCategory
|
||||
);
|
||||
})->isNotEmpty();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Contracts\TranslatableModel;
|
||||
use App\Enums\DynamicPages\PageStatusEnum;
|
||||
use App\Helpers\TranslationHelper;
|
||||
use App\Traits\Models\HasCache;
|
||||
use App\Traits\Models\HasTranslations;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
use Uwil\LaravelActivityLogs\Traits\ActivityLog;
|
||||
|
||||
|
|
@ -147,11 +145,15 @@ class PageConfig extends Model implements TranslatableModel
|
|||
|
||||
/**
|
||||
* Get the target model from a specific id and model name.
|
||||
*
|
||||
*
|
||||
* @param string $modelId
|
||||
* @param string $modelName
|
||||
* @return \Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public static function getModelFromInputModelConfig(string $modelId, string $modelName): \Illuminate\Database\Eloquent\Model
|
||||
{
|
||||
public static function getModelFromInputModelConfig(
|
||||
string $modelId,
|
||||
string $modelName,
|
||||
): \Illuminate\Database\Eloquent\Model {
|
||||
$studly = Str::studly(Str::singular($modelName));
|
||||
$class = "App\\Models\\{$studly}";
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ class ContactCountPolicy
|
|||
{
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @return boolean
|
||||
*/
|
||||
public function viewAny(Model $authModel): bool
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Uwil\LaravelBackend\Policies\Rules\UserStaticRules;
|
|||
|
||||
class DocumentCategoryPolicy
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* Determine whether the user can view any models.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ class DocumentPolicy
|
|||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Model $authModel): bool
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ class NewsCategoryPolicy
|
|||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Model $authModel): bool
|
||||
|
|
@ -102,7 +101,6 @@ class NewsCategoryPolicy
|
|||
* Determine whether the user can force delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(Model $authModel): bool
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ class NewsPolicy
|
|||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Model $authModel): bool
|
||||
|
|
@ -102,7 +101,6 @@ class NewsPolicy
|
|||
* Determine whether the user can force delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(Model $authModel): bool
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ class NewsTagPolicy
|
|||
* Determine whether the user can delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete(Model $authModel): bool
|
||||
|
|
@ -102,7 +101,6 @@ class NewsTagPolicy
|
|||
* Determine whether the user can force delete the model.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $authModel
|
||||
* @param \App\Models\News $news
|
||||
* @return boolean
|
||||
*/
|
||||
public function forceDelete(Model $authModel): bool
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ class DynamicPageRouteServiceProvider extends ServiceProvider
|
|||
$slug = $dynamicPageModel->getTranslation('slug', $locale);
|
||||
|
||||
// If no slug for the locale → skip.
|
||||
if (!empty($slug) && !$slug) continue;
|
||||
if (!empty($slug) && !$slug) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Retrieves the parent segments for this locale.
|
||||
$segments = DynamicPageHelper::getAllDynamicPageSegments(
|
||||
|
|
@ -63,7 +65,9 @@ class DynamicPageRouteServiceProvider extends ServiceProvider
|
|||
);
|
||||
|
||||
// If a parent does not have a slug in this locale → skip.
|
||||
if ($segments === null) continue;
|
||||
if ($segments === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$segmentsPath = implode('/', $segments);
|
||||
$finalPath = $segmentsPath ? "/{$segmentsPath}/{$slug}" : "/{$slug}";
|
||||
|
|
@ -75,9 +79,9 @@ class DynamicPageRouteServiceProvider extends ServiceProvider
|
|||
})
|
||||
->defaults('dynamicPage', $dynamicPageModel)
|
||||
->name("front.dynamic-pages.{$dynamicPageModel->id_key}.{$locale}");
|
||||
}
|
||||
} //end foreach
|
||||
});
|
||||
}
|
||||
} //end foreach
|
||||
|
||||
// Share all published dynamic pages to all blade views.
|
||||
foreach ($dynamicPageModels as $dynamicPageModel) {
|
||||
|
|
|
|||
|
|
@ -61,9 +61,12 @@ trait HasCache
|
|||
|
||||
/** @var \Illuminate\Database\Eloquent\Model $class */
|
||||
return $class::query()
|
||||
->when(property_exists($class, 'cacheRelations') && is_array($class::$cacheRelations), function ($query) use ($class) {
|
||||
$query->with($class::$cacheRelations);
|
||||
})
|
||||
->when(
|
||||
property_exists($class, 'cacheRelations') && is_array($class::$cacheRelations),
|
||||
function ($query) use ($class) {
|
||||
$query->with($class::$cacheRelations);
|
||||
}
|
||||
)
|
||||
->get();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ namespace App\Traits\Models;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Uwil\LaravelCommon\Helpers\FileHelper;
|
||||
use Uwil\LaravelCommon\Helpers\ToolboxHelper;
|
||||
|
||||
|
|
@ -18,15 +17,16 @@ trait HasUwilImages
|
|||
* - champs basique translatable - image et wisigiw
|
||||
* - prise en compte du trait softDetele
|
||||
*
|
||||
* non testé :
|
||||
* - la suppression totale des images dans un champs translatable // ça fonctionne mais il y a des changements à mettre dans FileHelper
|
||||
* Non testé :
|
||||
* - la suppression totale des images dans un champs translatable
|
||||
* (ça fonctionne mais il y a des changements à mettre dans FileHelper)
|
||||
* - le cas ou le champs (ancien et current) ne sont que des tableaux (non translatable)
|
||||
* - la récursivité dans traverseAndManage, je ne suis pour l'instant passé qu'une fois dans cette méthode, via un champs translatable
|
||||
* - la récursivité dans traverseAndManage,
|
||||
* je ne suis pour l'instant passé qu'une fois dans cette méthode, via un champs translatable
|
||||
*
|
||||
* TODO :
|
||||
* - ajouter la possibilité de viser un nest array dans les tableau de fields
|
||||
* - job pour nettoyer les models
|
||||
*
|
||||
*/
|
||||
|
||||
protected const UPDATE_ACTION = 'update';
|
||||
|
|
@ -61,8 +61,7 @@ trait HasUwilImages
|
|||
/**
|
||||
* Get the field that are images, from the array in the model
|
||||
*
|
||||
* @param Model $model
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return array
|
||||
*/
|
||||
protected static function getImageFields(Model $model): array
|
||||
|
|
@ -76,8 +75,7 @@ trait HasUwilImages
|
|||
/**
|
||||
* Get the field that are wysiwyg, from the array in the model
|
||||
*
|
||||
* @param Model $model
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return array
|
||||
*/
|
||||
protected static function getWysiwygFields(Model $model): array
|
||||
|
|
@ -91,13 +89,14 @@ trait HasUwilImages
|
|||
/**
|
||||
* Loop over the image or wysiwyg fields
|
||||
*
|
||||
* @param array $fields
|
||||
* @param Model $model
|
||||
* @param boolean $isTranslatable
|
||||
* @param mixed $locale
|
||||
* @param array $availableLocales
|
||||
* @param bool $forceDeleteImage
|
||||
* @param string $fieldType
|
||||
* @param array $fields
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param boolean $isTranslatable
|
||||
* @param mixed $locale
|
||||
* @param array $availableLocales
|
||||
* @param boolean $forceDeleteImage
|
||||
* @param string $fieldType
|
||||
* @return void
|
||||
*/
|
||||
protected static function loopOverFields(
|
||||
array $fields,
|
||||
|
|
@ -109,7 +108,7 @@ trait HasUwilImages
|
|||
string $fieldType = self::IMAGE
|
||||
): void {
|
||||
foreach ($fields as $field) {
|
||||
$currentValue = data_get($model->getAttributes(), $field);
|
||||
$currentValue = data_get($model->getAttributes(), $field);
|
||||
$originalValue = data_get($model->getOriginal(), $field);
|
||||
|
||||
if (is_null($currentValue) && is_null($originalValue)) {
|
||||
|
|
@ -117,12 +116,8 @@ trait HasUwilImages
|
|||
}
|
||||
|
||||
if (is_array($originalValue) && $isTranslatable) {
|
||||
$localesToProcess = ($forceDeleteImage)
|
||||
? $availableLocales // on delete it's all the locales
|
||||
: [$locale]; // on update it's only the currentLocale
|
||||
|
||||
$localesToProcess = ($forceDeleteImage) ? $availableLocales : [$locale];
|
||||
foreach ($localesToProcess as $lang) {
|
||||
|
||||
$oldLocaleVal = $originalValue[$lang] ?? [];
|
||||
$newLocaleVal = json_decode(data_get($model->getAttributes(), $field), true)[$lang] ?? [];
|
||||
|
||||
|
|
@ -137,9 +132,9 @@ trait HasUwilImages
|
|||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
} //end if
|
||||
|
||||
// PAS TESTE
|
||||
// PAS TESTE.
|
||||
if (is_array($originalValue) && is_array($currentValue)) {
|
||||
dd('juste array');
|
||||
static::traverseAndManage(
|
||||
|
|
@ -154,7 +149,7 @@ trait HasUwilImages
|
|||
}
|
||||
|
||||
static::manageField($model, $originalValue, $currentValue, $field, $forceDeleteImage, $fieldType);
|
||||
}
|
||||
} //end foreach
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,22 +158,38 @@ trait HasUwilImages
|
|||
* Determines field types, handles localization, and delegates processing to `loopOverFields()`
|
||||
* for each supported field type. Used during update or forced delete events.
|
||||
*
|
||||
* @param Model $model The Eloquent model to process.
|
||||
* @param string $eventType The event type (e.g. self::UPDATE_ACTION or self::FORCE_DELETE_ACTION).
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model The Eloquent model to process.
|
||||
* @param string $eventType The event type
|
||||
* (e.g. self::UPDATE_ACTION or self::FORCE_DELETE_ACTION).
|
||||
* @return void
|
||||
*/
|
||||
protected static function initLoop(Model $model, string $eventType = self::UPDATE_ACTION): void
|
||||
{
|
||||
$forceDeleteImage = $eventType === self::FORCE_DELETE_ACTION;
|
||||
$imagesFields = self::getImageFields($model);
|
||||
$wysiwygFields = self::getWysiwygFields($model);
|
||||
$isTranslatable = method_exists($model, 'getTranslations') ?? false;
|
||||
$locale = config('app.locale');
|
||||
$imagesFields = self::getImageFields($model);
|
||||
$wysiwygFields = self::getWysiwygFields($model);
|
||||
$isTranslatable = method_exists($model, 'getTranslations') ?? false;
|
||||
$locale = config('app.locale');
|
||||
$availableLocales = array_keys(config('laravellocalization.supportedLocales', ['fr' => "Frenchouz"]));
|
||||
|
||||
self::loopOverFields($imagesFields, $model, $isTranslatable, $locale, $availableLocales, $forceDeleteImage, self::IMAGE);
|
||||
self::loopOverFields($wysiwygFields, $model, $isTranslatable, $locale, $availableLocales, $forceDeleteImage, self::WYSIWYG);
|
||||
self::loopOverFields(
|
||||
$imagesFields,
|
||||
$model,
|
||||
$isTranslatable,
|
||||
$locale,
|
||||
$availableLocales,
|
||||
$forceDeleteImage,
|
||||
self::IMAGE,
|
||||
);
|
||||
self::loopOverFields(
|
||||
$wysiwygFields,
|
||||
$model,
|
||||
$isTranslatable,
|
||||
$locale,
|
||||
$availableLocales,
|
||||
$forceDeleteImage,
|
||||
self::WYSIWYG,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -187,35 +198,37 @@ trait HasUwilImages
|
|||
* Compares old and new values, determines if fields are lists, and delegates handling
|
||||
* of each field to `manageField()`. Supports recursive traversal for nested arrays.
|
||||
*
|
||||
* @param Model $model The Eloquent model being processed.
|
||||
* @param array $old The previous state of the data.
|
||||
* @param array $new The new state of the data.
|
||||
* @param string $fieldPath The current dot-notated path of the field.
|
||||
* @param bool $forceDeleteImage Whether to force deletion of old images.
|
||||
* @param string $fieldType The type of field being managed (default: self::IMAGE).
|
||||
* @param string|null $locale The locale associated with the field, if any.
|
||||
* @param \Illuminate\Database\Eloquent\Model $model The Eloquent model being processed.
|
||||
* @param array $old The previous state of the data.
|
||||
* @param array $new The new state of the data.
|
||||
* @param string $fieldPath The current dot-notated path of the field.
|
||||
* @param boolean $forceDeleteImage Whether to force deletion of old images.
|
||||
* @param string $fieldType The type of field being managed
|
||||
* (default: self::IMAGE).
|
||||
* @param string|null $locale The locale associated with the field, if any.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function traverseAndManage(
|
||||
Model $model,
|
||||
array $old,
|
||||
array $new,
|
||||
string $fieldPath,
|
||||
bool $forceDeleteImage,
|
||||
string $fieldType = self::IMAGE,
|
||||
Model $model,
|
||||
array $old,
|
||||
array $new,
|
||||
string $fieldPath,
|
||||
bool $forceDeleteImage,
|
||||
string $fieldType = self::IMAGE,
|
||||
?string $locale = null
|
||||
): void {
|
||||
$allKeys = self::getFieldKeys($old, $new);
|
||||
|
||||
// This boolean is used to know if we need to keep the index (key) of the array or not e.g do we want to keep content.fr.0 or just content.fr
|
||||
// This boolean is used to know if we need to keep the index (key) of the array,
|
||||
// or not e.g do we want to keep content.fr.0 or just content.fr.
|
||||
$isList = self::isMeaningfulList($old) || self::isMeaningfulList($new);
|
||||
|
||||
foreach ($allKeys as $key) {
|
||||
$oldValue = $old[$key] ?? null;
|
||||
$newValue = $new[$key] ?? null;
|
||||
$path = $isList ? "$fieldPath.$key" : (is_int($key) ? $fieldPath : "$fieldPath.$key");
|
||||
// TODO cette récursivité n'a pas encore été testé
|
||||
$path = $isList ? "$fieldPath.$key" : (is_int($key) ? $fieldPath : "$fieldPath.$key");
|
||||
// TODO cette récursivité n'a pas encore été testé.
|
||||
if (is_array($oldValue) || is_array($newValue)) {
|
||||
dd('pas testé');
|
||||
static::traverseAndManage(
|
||||
|
|
@ -243,8 +256,8 @@ trait HasUwilImages
|
|||
* This helps distinguish between true lists of complex data
|
||||
* and simple value arrays like ["foo", "bar"].
|
||||
*
|
||||
* @param array $array
|
||||
* @return bool
|
||||
* @param array $array
|
||||
* @return boolean
|
||||
*/
|
||||
private static function isMeaningfulList(array $array): bool
|
||||
{
|
||||
|
|
@ -260,8 +273,8 @@ trait HasUwilImages
|
|||
* Useful for comparing field values or recursively traversing
|
||||
* nested array structures.
|
||||
*
|
||||
* @param array $old
|
||||
* @param array $new
|
||||
* @param array $old
|
||||
* @param array $new
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
protected static function getFieldKeys(array $old, array $new): \Illuminate\Support\Collection
|
||||
|
|
@ -274,13 +287,13 @@ trait HasUwilImages
|
|||
/**
|
||||
* Get the image field and manage the store image.
|
||||
*
|
||||
* @param Model $model
|
||||
* @param mixed $oldValue
|
||||
* @param mixed $newValue
|
||||
* @param mixed $fieldName The fieldName, can be nested e.g content.image
|
||||
* @param bool $forceDeleteImage Does the image be force deleted, even if old and new value are the same (on delete model most of case)
|
||||
* @param string $fieldType Choice between WYSIWYG and IMAGE
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @param mixed $oldValue
|
||||
* @param mixed $newValue
|
||||
* @param mixed $fieldName The fieldName, can be nested e.g content.image.
|
||||
* @param boolean $forceDeleteImage Does the image be force deleted,
|
||||
* even if old and new value are the same (on delete model most of case).
|
||||
* @param string $fieldType Choice between WYSIWYG and IMAGE.
|
||||
* @return void
|
||||
*/
|
||||
protected static function manageField(
|
||||
|
|
@ -289,31 +302,30 @@ trait HasUwilImages
|
|||
mixed $newValue,
|
||||
mixed $fieldName,
|
||||
bool $forceDeleteImage,
|
||||
$fieldType = self::IMAGE
|
||||
string $fieldType = self::IMAGE
|
||||
) {
|
||||
|
||||
if ($fieldType === self::IMAGE) {
|
||||
// Cas 1 : Valeurs identiques -> only for force deleting model
|
||||
// Cas 1 : Valeurs identiques -> only for force deleting model.
|
||||
if ((is_string($oldValue) === is_string($newValue)) && $forceDeleteImage) {
|
||||
// In this case we need to remove the actual file, not the old as we do in other conditions
|
||||
// In this case we need to remove the actual file, not the old as we do in other conditions.
|
||||
$path = ToolboxHelper::mbReplace('storage/', '', $newValue);
|
||||
if (Storage::disk('public')->exists($path)) {
|
||||
Storage::disk('public')->delete($path);
|
||||
}
|
||||
}
|
||||
// // Cas 2 : ancienne = string, nouvelle = null → suppression
|
||||
// // Cas 2 : ancienne = string, nouvelle = null → suppression.
|
||||
if (is_string($oldValue) && is_null($newValue)) {
|
||||
// Action suppression
|
||||
// Action suppression.
|
||||
FileHelper::removeOldFile($model, $fieldName);
|
||||
}
|
||||
|
||||
// // Cas 3 : ancienne = null, nouvelle = string → ajout
|
||||
|
||||
// // Cas 4 : ancienne = string, nouvelle = autre string → remplacement
|
||||
// // Cas 3 : ancienne = null, nouvelle = string → ajout.
|
||||
// // Cas 4 : ancienne = string, nouvelle = autre string → remplacement.
|
||||
if (is_string($oldValue) && is_string($newValue) && $oldValue !== $newValue) {
|
||||
FileHelper::removeOldFile($model, $fieldName);
|
||||
}
|
||||
}
|
||||
} //end if
|
||||
|
||||
if ($fieldType === self::WYSIWYG) {
|
||||
$valueToPass = $forceDeleteImage ? '' : ($newValue ?? '');
|
||||
|
|
@ -329,7 +341,7 @@ trait HasUwilImages
|
|||
* Recursively processes attribute values to store uploaded files via `FileHelper::storeFile()`,
|
||||
* and applies the transformed data to the model using `fill()`.
|
||||
*
|
||||
* @param array $attributes The attributes to fill the model with.
|
||||
* @param array $attributes The attributes to fill the model with.
|
||||
* @return void
|
||||
*/
|
||||
public function inertiaFill(array $attributes): void
|
||||
|
|
@ -343,12 +355,13 @@ trait HasUwilImages
|
|||
/**
|
||||
* Store recursively all uploaded files in array.
|
||||
*
|
||||
* @param array $content
|
||||
* @return array
|
||||
*/
|
||||
private function processContentFiles(array $content): array
|
||||
{
|
||||
return collect($content)
|
||||
->map(function ($value, $key) {
|
||||
->map(function ($value) {
|
||||
// Check the pattern of the key and the type of value.
|
||||
if ($value instanceof UploadedFile) {
|
||||
return FileHelper::storeFile($this, $value);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ trait HasLaravelFailedValidation
|
|||
{
|
||||
/**
|
||||
* Set manually a failed ajax response.
|
||||
*
|
||||
* @return \Illuminate\Http\Exceptions\HttpResponseException
|
||||
*
|
||||
* @param \Illuminate\Contracts\Validation\Validator $validator
|
||||
* @return void
|
||||
* @throws \Illuminate\Http\Exceptions\HttpResponseException Override ajax code error.
|
||||
*/
|
||||
protected function failedValidation(Validator $validator): \Illuminate\Http\Exceptions\HttpResponseException
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Traits\Requests;
|
||||
|
||||
use \Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
trait HasInertiaPicture
|
||||
{
|
||||
|
|
@ -17,7 +17,7 @@ trait HasInertiaPicture
|
|||
return;
|
||||
}
|
||||
$original = $this->all();
|
||||
$merged = self::arrayMergeRecursiveDistinct($original, $this->convertedFiles);
|
||||
$merged = self::arrayMergeRecursiveDistinct($original, $this->convertedFiles);
|
||||
$this->replace($merged);
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +89,7 @@ trait HasInertiaPicture
|
|||
// String path validations.
|
||||
if (is_string($value)) {
|
||||
// Validate the path.
|
||||
// phpcs:ignore Generic.Files.LineLength
|
||||
$pattern = '/^storage\/modelfiles\/[a-zA-Z0-9_]+\/[0-9]{2}\/[0-9]{2}\/[0-9]{2}\/[a-zA-Z0-9]{2}\/[a-zA-Z0-9_-]+/';
|
||||
if (!preg_match($pattern, $value)) {
|
||||
$fail(trans('validation.file_path', ['attribute' => $this->attributes()[$attribute]]));
|
||||
|
|
@ -99,7 +100,7 @@ trait HasInertiaPicture
|
|||
$mimesRule = collect($rules)->first(fn($r) => str_starts_with($r, 'mimes:'));
|
||||
if ($mimesRule) {
|
||||
$allowedExtensions = explode(',', str_replace('mimes:', '', $mimesRule));
|
||||
$ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));
|
||||
$ext = strtolower(pathinfo($value, PATHINFO_EXTENSION));
|
||||
if (!in_array($ext, $allowedExtensions)) {
|
||||
$fail(trans('validation.mimetypes', [
|
||||
'attribute' => $this->attributes()[$attribute],
|
||||
|
|
@ -109,7 +110,7 @@ trait HasInertiaPicture
|
|||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} //end if
|
||||
|
||||
// Unmanaged case (not null, not UploadedFile, not string).
|
||||
$fail("Invalide type for $attribute.");
|
||||
|
|
|
|||
|
|
@ -2,18 +2,14 @@
|
|||
|
||||
namespace App\View\Components\Front\News;
|
||||
|
||||
use Closure;
|
||||
use App\Models\News;
|
||||
use App\Models\NewsTag;
|
||||
use App\Models\NewsCategory;
|
||||
use Illuminate\View\Component;
|
||||
use App\Enums\News\NewsStatusEnum;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class NewsNextEventComponent extends Component
|
||||
{
|
||||
/** @var array<\App\Models\News> $nextEvents List of published news. */
|
||||
public $nextEvents;
|
||||
|
||||
/**
|
||||
|
|
@ -43,8 +39,10 @@ class NewsNextEventComponent extends Component
|
|||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function render(): View|Closure|string
|
||||
public function render(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('components.front.news.news-next-event-component', [
|
||||
'nextEvents' => $this->nextEvents
|
||||
|
|
|
|||
|
|
@ -8,15 +8,25 @@ use Illuminate\View\Component;
|
|||
|
||||
class OurImplantations extends Component
|
||||
{
|
||||
/** @var string $id Identification of the section. */
|
||||
public string $id;
|
||||
|
||||
/** @var $implantations Content section. */
|
||||
public $implantations;
|
||||
|
||||
/** @var array<\App\Models\Company> $companyModels List of published companies. */
|
||||
public $companyModels;
|
||||
|
||||
/** @var array<\App\Models\CompanyActivity> $companyActivityModels List of published company activities. */
|
||||
public $companyActivityModels;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $implantations
|
||||
*/
|
||||
public function __construct($id, $implantations)
|
||||
public function __construct(string $id, array $implantations)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->implantations = $implantations;
|
||||
|
|
@ -32,13 +42,14 @@ class OurImplantations extends Component
|
|||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
public function render(): \Illuminate\Contracts\View\View|\Closure|string
|
||||
public function render(): \Illuminate\Contracts\View\View
|
||||
{
|
||||
return view('components.front.pages.know-us.our-implantations', [
|
||||
'companyModels' => $this->companyModels,
|
||||
'companyActivityModels' => $this->companyActivityModels,
|
||||
'implantations' => $this->implantations,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ return [
|
|||
|
||||
'locale' => env('APP_LOCALE', 'fr'),
|
||||
|
||||
// FIXME: need this because of uwil packages
|
||||
// FIXME: need this because of uwil packages.
|
||||
'locales' => [
|
||||
'en',
|
||||
'fr',
|
||||
|
|
|
|||
|
|
@ -59,9 +59,7 @@ return [
|
|||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'options' => [],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
|
|
|
|||
|
|
@ -108,8 +108,6 @@ return [
|
|||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ return [
|
|||
'missing_routes' => false,
|
||||
],
|
||||
|
||||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send-default-pii.
|
||||
// See: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send-default-pii.
|
||||
'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false),
|
||||
|
||||
// @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'),
|
||||
// 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' => [\Uwil\LaravelCommon\Helpers\ExceptionsHelper::class, 'sentryEventHandler'],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CompanyActivity>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\DynamicFieldTypes;
|
||||
use App\Models\CompanyActivity;
|
||||
use App\Models\CompanySector;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Company>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\CompanySector>
|
||||
|
|
|
|||
|
|
@ -4,11 +4,7 @@ namespace Database\Factories;
|
|||
|
||||
use App\Enums\Document\DocumentStatusEnum;
|
||||
use App\Enums\YearsEnum;
|
||||
use App\Models\Document;
|
||||
use App\Models\DocumentCategory;
|
||||
use App\Models\DocumentTag;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Document>
|
||||
|
|
@ -23,10 +19,10 @@ class DocumentFactory extends Factory
|
|||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence(3),
|
||||
'exercice' => $this->faker->randomElement(YearsEnum::cases()),
|
||||
'status' => $this->faker->randomElement(DocumentStatusEnum::cases()),
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
|
||||
'name' => $this->faker->sentence(3),
|
||||
'exercice' => $this->faker->randomElement(YearsEnum::cases()),
|
||||
'status' => $this->faker->randomElement(DocumentStatusEnum::cases()),
|
||||
'published_at' => $this->faker->dateTimeBetween('-1 month', 'now'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,9 +46,11 @@ class DynamicPageFactory extends Factory
|
|||
*
|
||||
* @param \App\Models\PageConfig $configModel
|
||||
* @return array
|
||||
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
|
||||
*/
|
||||
private function getDataFromConfig(PageConfig $configModel): array
|
||||
{
|
||||
// phpcs:enable
|
||||
foreach ($configModel->config as $field) {
|
||||
switch ($field['type']) {
|
||||
case DynamicFieldTypes::string->value:
|
||||
|
|
@ -87,7 +89,7 @@ class DynamicPageFactory extends Factory
|
|||
default:
|
||||
$configValue = [];
|
||||
break;
|
||||
}
|
||||
} //end switch
|
||||
} //end foreach
|
||||
return $configValue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\News\NewsStatusEnum;
|
||||
use App\Models\News;
|
||||
use App\Models\NewsCategory;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class PageConfigFactory extends Factory
|
|||
];
|
||||
if ($enum->value === DynamicFieldTypes::list->value) {
|
||||
// Set only one string input for the example.
|
||||
$defaultEnum = DynamicFieldTypes::string;
|
||||
$defaultEnum = DynamicFieldTypes::string;
|
||||
$data['config'][0]['children'] = [
|
||||
[
|
||||
'type' => $defaultEnum->value(),
|
||||
|
|
|
|||
|
|
@ -368,6 +368,7 @@ return [
|
|||
],
|
||||
"static_route" => [
|
||||
"no_route_defined" => "no route defined in the config file",
|
||||
"select_value" => "select a value from the list",
|
||||
],
|
||||
"associated_model" => "associated :model|associated :model",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ return [
|
|||
'search' => [
|
||||
'seo_title' => 'You searched for :terms',
|
||||
'seo_description' => 'Search for a word on the entire LDC.fr website',
|
||||
'title' => 'Search',
|
||||
'placeholder' => 'Your search',
|
||||
'results_total' => ':nbr results for ":terms"',
|
||||
'no_results' => 'No results found.',
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ return [
|
|||
],
|
||||
"static_route" => [
|
||||
"no_route_defined" => "aucune route définie dans le fichier de config",
|
||||
"select_value" => "sélectionnez une valeur dans la liste",
|
||||
],
|
||||
"associated_model" => ":model associés|:model associées",
|
||||
];
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ return [
|
|||
'search' => [
|
||||
'seo_title' => 'Vous avez cherché :terms',
|
||||
'seo_description' => 'Recherche de mot sur la globalité du site LDC.fr',
|
||||
'title' => 'Recherche',
|
||||
'placeholder' => 'Votre recherche',
|
||||
'results_total' => ':nbr résultats pour ":terms"',
|
||||
'no_results' => 'Aucun résultat trouvé.',
|
||||
|
|
@ -141,8 +142,8 @@ return [
|
|||
'recaptcha_protect' => 'Ce site est protégé par reCAPTCHA et la <a href="https://policies.google.com/privacy">politique de confidentialité</a> et les <a href="https://policies.google.com/terms">conditions d\'utilisation</a> de Google s\'appliquent.',
|
||||
'pratical' => 'pratique',
|
||||
'our_offers' => [
|
||||
'title' => 'nos offres',
|
||||
'subtitle' => 'd\'emploi, de stage et d\'alternance',
|
||||
'title' => 'nos offres',
|
||||
'subtitle' => 'd\'emploi, de stage et d\'alternance',
|
||||
'link_text' => 'accédez à notre portail de recrutement'
|
||||
],
|
||||
'discover_our_jobs' => 'découvrez nos métiers'
|
||||
|
|
|
|||
36
package-lock.json
generated
36
package-lock.json
generated
|
|
@ -28,6 +28,7 @@
|
|||
"@tiptap/extension-image": "^3.17.0",
|
||||
"@tiptap/extension-invisible-characters": "^3.17.1",
|
||||
"@tiptap/extension-italic": "^3.17.0",
|
||||
"@tiptap/extension-link": "^3.19.0",
|
||||
"@tiptap/extension-list": "^3.17.1",
|
||||
"@tiptap/extension-ordered-list": "^3.17.0",
|
||||
"@tiptap/extension-placeholder": "^3.17.0",
|
||||
|
|
@ -47,6 +48,7 @@
|
|||
"@types/react-dom": "^19.1.7",
|
||||
"axios": "^1.13.2",
|
||||
"chart.js": "^4.5.1",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
|
|
@ -55,6 +57,7 @@
|
|||
"laravel-vite-plugin": "^1.3.0",
|
||||
"lucide-react": "^0.503.0",
|
||||
"motion": "^12.23.12",
|
||||
"prosemirror-state": "^1.4.4",
|
||||
"react-color": "^2.19.3",
|
||||
"react-day-picker": "^9.11.1",
|
||||
"react-dropzone": "^14.3.8",
|
||||
|
|
@ -85,7 +88,7 @@
|
|||
"@typescript-eslint/parser": "^8.39.0",
|
||||
"@vitejs/plugin-react": "^4.7.0",
|
||||
"autoprefixer": "^10.4.21",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"baseline-browser-mapping": "^2.9.19",
|
||||
"concurrently": "^9.2.0",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
|
|
@ -4022,16 +4025,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@tiptap/core": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.17.1.tgz",
|
||||
"integrity": "sha512-f8hB9MzXqsuXoF9qXEDEH5Fb3VgwhEFMBMfk9EKN88l5adri6oM8mt2XOWVxVVssjpEW0177zXSLPKWzoS/vrw==",
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-3.19.0.tgz",
|
||||
"integrity": "sha512-bpqELwPW+DG8gWiD8iiFtSl4vIBooG5uVJod92Qxn3rA9nFatyXRr4kNbMJmOZ66ezUvmCjXVe/5/G4i5cyzKA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/pm": "^3.17.1"
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-blockquote": {
|
||||
|
|
@ -4281,9 +4284,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-link": {
|
||||
"version": "3.17.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.17.0.tgz",
|
||||
"integrity": "sha512-qGL/s7RxgWL1dY3ZPsPtBYQsfiNpwnqoK5dVQ7NbqjphK1EF/Q4uBRVM3CKMZiRBHdRlSVZewBycHs4uyAKPbA==",
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-3.19.0.tgz",
|
||||
"integrity": "sha512-HEGDJnnCPfr7KWu7Dsq+eRRe/mBCsv6DuI+7fhOCLDJjjKzNgrX2abbo/zG3D/4lCVFaVb+qawgJubgqXR/Smw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"linkifyjs": "^4.3.2"
|
||||
|
|
@ -4293,8 +4296,8 @@
|
|||
"url": "https://github.com/sponsors/ueberdosis"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "^3.17.0",
|
||||
"@tiptap/pm": "^3.17.0"
|
||||
"@tiptap/core": "^3.19.0",
|
||||
"@tiptap/pm": "^3.19.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tiptap/extension-list": {
|
||||
|
|
@ -4538,9 +4541,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@tiptap/pm": {
|
||||
"version": "3.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.17.1.tgz",
|
||||
"integrity": "sha512-UyVLkN8axV/zop6Se2DCBJRu5DM21X0XEQvwEC5P/vk8eC9OcQZ3FLtxeYy2ZjpAZUzBGLw0/BGsmEip/n7olw==",
|
||||
"version": "3.19.0",
|
||||
"resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-3.19.0.tgz",
|
||||
"integrity": "sha512-789zcnM4a8OWzvbD2DL31d0wbSm9BVeO/R7PLQwLIGysDI3qzrcclyZ8yhqOEVuvPitRRwYLq+mY14jz7kY4cw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"prosemirror-changeset": "^2.3.0",
|
||||
|
|
@ -5804,9 +5807,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.8.29",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.29.tgz",
|
||||
"integrity": "sha512-sXdt2elaVnhpDNRDz+1BDx1JQoJRuNk7oVlAlbGiFkLikHCAQiccexF/9e91zVi6RCgqspl04aP+6Cnl9zRLrA==",
|
||||
"version": "2.9.19",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz",
|
||||
"integrity": "sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
|
@ -6087,7 +6090,6 @@
|
|||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/class-variance-authority/-/class-variance-authority-0.7.1.tgz",
|
||||
"integrity": "sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"clsx": "^2.1.1"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue