Merge branch 'trunk'

This commit is contained in:
Noah Lancien 2026-04-28 09:06:18 +02:00
commit 79a709e3f4
95 changed files with 1904 additions and 1038 deletions

3
.husky/commit-msg Normal file
View file

@ -0,0 +1,3 @@
#!/bin/sh
npx --no -- commitlint --config node_modules/@uwil/husky-config/commitlint.config.cjs --edit $1

View file

@ -1,4 +1,4 @@
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:070426-150359
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
COPY --chown=www-data:www-data . /app/srcs
USER root
RUN chmod -R 755 /app/srcs/storage

View file

@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use App\Jobs\CleanOldActivities as CleanOldActivitiesJob;
use Illuminate\Console\Command;
class CleanOldActivities extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'uwil:activity-logs:clean {--force : Delete all activity logs regardless of date.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Clean all logs older than one year. Use --force to delete all logs.';
/**
* Execute the console command.
*
* @return void
*/
public function handle(): void
{
$messageTitle = "<comment>activity logs</comment>";
$this->components->info("Cleaning {$messageTitle}...");
$force = $this->option('force');
if ($force && !$this->confirm('Are you sure you want to delete all activity logs ? This cannot be undone.')) {
$this->components->error("Clean of {$messageTitle} aborted.");
return;
}
(new CleanOldActivitiesJob(force: $force))->handle();
$messageContent = $force ? "All {$messageTitle} deleted" : "Old {$messageTitle} cleaned";
$this->components->success($messageContent);
}
}

View file

@ -0,0 +1,117 @@
<?php
namespace App\Console\Commands;
use App\Enums\Users\RoleEnum;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Str;
/**
* Artisan command to create a backend admin user.
*/
class MakeUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'uwil:make:user';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new backend admin user.';
/**
* Execute the console command.
*
* @return void
*/
public function handle(): void
{
$this->components->info("Creating a new <comment>backend user</comment>...");
$firstName = $this->askValid(
'first_name',
'First name',
'Admin',
['required', 'min:3', 'max:255']
);
$lastName = $this->askValid(
'last_name',
'Last name',
'Saïtama',
['required', 'min:3', 'max:255']
);
$email = $this->askValid(
'email',
'Email',
'equipe.web@ldc.fr',
['required', 'unique:users,email', 'email:rfc,strict,dns,spoof,filter']
);
$role = $this->askRole();
$user = new User([
'first_name' => $firstName,
'last_name' => $lastName,
'email' => $email,
'role' => $role,
'published' => true,
'published_at' => Carbon::now(),
]);
$user->saveOrFail();
$this->components->success("User <comment>{$firstName} {$lastName}</comment> created successfully.");
}
/**
* Ask for a value and validate it, re-prompting on failure.
*
* @param string $field
* @param string $label
* @param string $default
* @param array<int, string> $rules
* @return string
*/
private function askValid(string $field, string $label, string $default, array $rules): string
{
try {
$value = $this->ask(sprintf("Type the wanted user %s", $label), $default);
$validator = Validator::make([$field => $value], [$field => $rules]);
$validator->validate();
return $value;
} catch (ValidationException $e) {
$this->components->error(
collect($e->errors())->flatten()->first()
);
return $this->askValid($field, $label, $default, $rules);
}
}
/**
* Ask for a role and return the corresponding RoleEnum.
*
* @return \App\Enums\Users\RoleEnum
*/
private function askRole(): \App\Enums\Users\RoleEnum
{
$options = collect([
RoleEnum::conceptor,
RoleEnum::admin,
RoleEnum::visitor,
])->mapWithKeys(fn(RoleEnum $role) => [
Str::ucFirst($role->label()) => $role
]);
/** @var string $choice */
$choice = $this->choice('Role', $options->keys()->all(), Str::ucFirst(RoleEnum::visitor->label()));
return $options->get($choice);
}
}

View file

@ -1,207 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Enums\Users\RoleEnum;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Str;
class UserCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'uwil:user:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a backend admin user';
/**
* The first name of the new user.
*
* @var string|null
*/
protected $first_name;
/**
* The last name of the new user.
*
* @var string|null
*/
protected $last_name;
/**
* The email of the new user.
*
* @var string|null
*/
protected $email;
/**
* The role of the new user.
*
* @var string|null
*/
protected $role;
/**
* Execute the console command.
*
* @return integer
*/
public function handle(): int
{
$this->first_name = null;
$this->addFirstName();
$this->last_name = null;
$this->addLastName();
$this->email = null;
$this->addEmail();
$this->role = null;
$this->addRole();
$user = new User([
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->email,
'role' => $this->role,
'published' => true,
'published_at' => Carbon::now(),
]);
$user->saveOrFail();
$this->info('User created 👌');
return 0;
}
/**
* Add a first name to the user.
*
* @return void
*/
private function addFirstName(): void
{
while (is_null($this->first_name)) {
try {
$tmp = $this->ask('Type the wanted user first name', 'Admin');
$validator = Validator::make(['first_name' => $tmp], [
'first_name' => 'required|min:3|max:255'
]);
$validator->validate();
$this->first_name = $tmp;
} catch (ValidationException $e) {
$this->error(sprintf(
'Please provide a valid first name %s',
\implode(',', collect($e->errors())->flatten()->all())
));
continue;
} //end try
}; //end while
}
/**
* Add a last name to the user.
*
* @return void
*/
private function addLastName(): void
{
while (is_null($this->last_name)) {
try {
$tmp = $this->ask('Type the wanted user last name', 'Saïtama');
$validator = Validator::make(['last_name' => $tmp], [
'last_name' => 'required|min:3|max:255'
]);
$validator->validate();
$this->last_name = $tmp;
} catch (ValidationException $e) {
$this->error(sprintf(
'Please provide a valid last_name %s',
\implode(',', collect($e->errors())->flatten()->all())
));
continue;
} //end try
}; //end while
}
/**
* Add an email to the user.
*
* @return void
*/
private function addEmail(): void
{
while (is_null($this->email)) {
try {
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
$validator = Validator::make(['email' => $tmp], [
'email' => 'required|unique:users,email|email:rfc,dns'
]);
$validator->validate();
$this->email = $tmp;
} catch (ValidationException $e) {
$this->error(sprintf(
'Please provide a valid email %s',
\implode(',', collect($e->errors())->flatten()->all())
));
continue;
} //end try
}; //end while
}
/**
* Add a role to the user.
*
* @return void
*/
private function addRole(): void
{
while (is_null($this->role)) {
try {
$tmp = $this->choice(
'Select his role',
[
Str::ucFirst(RoleEnum::conceptor->label()),
Str::ucFirst(RoleEnum::admin->label()),
Str::ucFirst(RoleEnum::visitor->label())
],
Str::ucFirst(RoleEnum::visitor->label()),
);
if ($tmp === Str::ucFirst(RoleEnum::conceptor->label())) {
$tmp = RoleEnum::conceptor;
}
if ($tmp === Str::ucFirst(RoleEnum::admin->label())) {
$tmp = RoleEnum::admin;
}
if ($tmp === Str::ucFirst(RoleEnum::visitor->label())) {
$tmp = RoleEnum::visitor;
}
$validator = Validator::make(['role' => $tmp], [
'role' => 'required'
]);
$validator->validate();
$this->role = $tmp;
} catch (ValidationException $e) {
$this->error(sprintf(
'Please choose from the selection %s',
\implode(',', collect($e->errors())->flatten()->all())
));
continue;
} //end try
}; //end while
}
}

View file

@ -2,6 +2,7 @@
namespace App\Console;
use App\Jobs\CleanOldActivities;
use App\Jobs\UpdatePlanificatedStatus;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ -16,6 +17,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
$schedule->job(CleanOldActivities::class)->daily();
$schedule->job(UpdatePlanificatedStatus::class)->everyFiveMinutes();
}

View file

@ -14,7 +14,7 @@ enum ActivityLogsEventEnum: int
case deleted = 4;
/**
* Optionnal labels definition
* Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/
@ -27,7 +27,7 @@ enum ActivityLogsEventEnum: int
/**
* Custom added classes definition
* Custom added classes definition.
*/
private const BOOTSTRAPCLASS = [
self::created->name => 'success',
@ -37,7 +37,7 @@ enum ActivityLogsEventEnum: int
];
/**
* Get Class
* Get Class.
*
* @return string
*/

View file

@ -518,7 +518,7 @@ enum Country: int
/**
* Get Valid Shipping Countries
*
* @return array
* @return array<int, self>
*/
public static function validShippingCountries(): array
{
@ -544,7 +544,7 @@ enum Country: int
/**
* Get Valid Shipping Countries
*
* @return array
* @return array<int, self>
*/
public static function validBillingCountries(): array
{
@ -568,7 +568,7 @@ enum Country: int
/**
* Get Alpha 2 ISO code of valid shipping countries
*
* @return array
* @return array<int, string>
*/
public static function getValidShippingCountriesIsoAplha2Codes(): array
{
@ -578,7 +578,7 @@ enum Country: int
/**
* Get Alpha 2 ISO code of valid billing countries
*
* @return array
* @return array<int, string>
*/
public static function getValidBillingCountriesIsoAplha2Codes(): array
{
@ -586,7 +586,7 @@ enum Country: int
}
/**
* Custom added ISOCODES definition
* Custom added ISOCODES definition.
*/
private const ISOCODES = [
self::afghanistan->name => 'AFG',

View file

@ -68,7 +68,7 @@ enum SpeciesEnum: int
];
/**
* Get picture alt attribute
* Get picture alt attribute.
*
* @return string
*/
@ -77,7 +77,6 @@ enum SpeciesEnum: int
return self::ALTS[$this->name];
}
/**
* Alt attributes for pictures.
*/
@ -92,7 +91,7 @@ enum SpeciesEnum: int
];
/**
* Get picture alt attribute
* Get picture alt attribute.
*
* @return string
*/

View file

@ -40,7 +40,7 @@ enum StaticPageType: int
/**
* Get the enums for the page which contains sections.
*
* @return array
* @return array<int, self>
*/
public static function containsSection(): array
{

View file

@ -42,7 +42,7 @@ enum PictoEnum: int
];
/**
* Get picture path
* Get picture path.
*
* @return string
*/
@ -64,7 +64,7 @@ enum PictoEnum: int
];
/**
* Get picture alt attribute
* Get picture alt attribute.
*
* @return string
*/
@ -87,7 +87,7 @@ enum PictoEnum: int
];
/**
* Get picture alt attribute
* Get picture alt attribute.
*
* @return string
*/

View file

@ -29,6 +29,9 @@ enum TypeEnum: int
self::hire->name => 'On Embauche',
];
/**
* Optionnal labels definition.
*/
private const COLORS = [
self::breeding->name => 'tertiary',
self::better_life->name => 'quad',
@ -39,7 +42,7 @@ enum TypeEnum: int
];
/**
* Get color name
* Get color name.
*
* @return string
*/

View file

@ -21,7 +21,7 @@ class ActivityLogController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $query */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\ActivityLog> $query */
$query = ActivityLog::query()->with('user');
/** @var string $search Search field */
@ -55,6 +55,7 @@ class ActivityLogController extends Controller
*/
public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Model $targetModelClass */
$targetModelClass = $activity_log->model_class;
$targetModel = $activity_log->model_class::where(
(new $targetModelClass())->getRouteKeyName(),

View file

@ -34,8 +34,9 @@ class AisleController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $aisleModels */
$aisleModels = Aisle::query()->with('network');
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Aisle> $aisleModels */
$aisleModels = Aisle::query()->with('network');
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Network> $networkModels */
$networkModels = Network::query()->where('published', true)->get();
$selectedNetwork = intval($request->network);

View file

@ -32,7 +32,7 @@ class BrandController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $brandModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Brand> $brandModels */
$brandModels = Brand::query()->with('aisle');
/** @var string $search Search field */

View file

@ -36,9 +36,10 @@ class CarouselController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $carouselModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Carousel> $carouselModels */
$carouselModels = Carousel::query()->with('section');
$sectionModels = Section::query()->whereHas('carousels')->get();
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Section> $sectionModels */
$sectionModels = Section::query()->whereHas('carousels')->get();
$selectedSection = intval($request->section);

View file

@ -7,7 +7,7 @@ use App\Http\Controllers\Controller;
class DashboardController extends Controller
{
/**
* Dashboard Page
* Dashboard Page.
*
* @return \Illuminate\Contracts\View\View
*/

View file

@ -28,7 +28,7 @@ class HistoricalMilestoneController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $historicalMilestoneModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\HistoricalMilestone> $historicalMilestoneModels */
$historicalMilestoneModels = HistoricalMilestone::query();
/** @var string $search Search field */

View file

@ -28,7 +28,7 @@ class JobVideoController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $jobVideoModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\JobVideo> $jobVideoModels */
$jobVideoModels = JobVideo::query();
/** @var string $search Search field */

View file

@ -28,7 +28,7 @@ class LogoController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $logoModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Logo> $logoModels */
$logoModels = Logo::query();
/** @var string $search Search field */

View file

@ -33,7 +33,7 @@ class NetworkController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $networkModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Network> $networkModels */
$networkModels = Network::query();
/** @var string $search Search field */

View file

@ -33,7 +33,7 @@ class NewsController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $newsModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\News> $newsModels */
$newsModels = News::query();
/** @var string $search Search field */

View file

@ -30,7 +30,7 @@ class SectionController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $query */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Section> $query */
$query = Section::query()->with('page');
// Filter by related page if requested.
@ -92,11 +92,15 @@ class SectionController extends Controller
public function update(UpdateSectionRequest $request, Section $section): RedirectResponse
{
return DB::transaction(function () use ($request, $section) {
$section->fill(array_replace_recursive(
\json_decode(\json_encode($section->toArray()), true),
$request->validated()
));
$encoded = json_encode($section->toArray());
if ($encoded === false) {
return redirect()->back()->with('error', trans('crud.messages.cannot_be_updated', [
'model' => Str::ucfirst(trans('models.classes.section'))
]));
}
/** @var array<string, mixed> $data */
$data = json_decode($encoded, true);
$section->fill(array_replace_recursive($data, $request->validated()));
if ($section->saveOrFail()) {
return redirect()->route('bo.sections.edit', $section)

View file

@ -32,7 +32,7 @@ class SiteController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Site> $siteModels */
$siteModels = Site::query();
/** @var string $search Search field */
@ -90,7 +90,9 @@ class SiteController extends Controller
$site->fill($request->safe()->except(['logos']));
if ($site->saveOrFail()) {
$site->logos()->attach(collect($request->validated('logos'))->pluck('id'));
/** @var array<int, array<string, mixed>> $logos */
$logos = $request->validated('logos') ?? [];
$site->logos()->attach(collect($logos)->pluck('id'));
return redirect()->route('bo.sites.edit', $site)
->with('success', trans('crud.messages.has_been_created', [
'model' => Str::ucfirst(trans('models.classes.site'))
@ -129,8 +131,10 @@ class SiteController extends Controller
public function update(UpdateSiteRequest $request, Site $site): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request, $site) {
/** @var array<int, array<string, mixed>> $logos */
$logos = $request->validated('logos') ?? [];
$site->logos()->sync(collect($logos)->pluck('id'));
$site->fill($request->safe()->except(['logos']));
$site->logos()->sync(collect($request->validated('logos'))->pluck('id'));
if ($site->saveOrFail()) {
return redirect()->route('bo.sites.edit', $site)

View file

@ -28,7 +28,7 @@ class SlideController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $slideModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Slide> $slideModels */
$slideModels = Slide::query();
/** @var string $search Search field */

View file

@ -27,7 +27,7 @@ class StaticPageController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $query */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\StaticPage> $query */
$query = StaticPage::query();
/** @var string $search Search field */

View file

@ -28,7 +28,7 @@ class StickyController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $stickyModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Sticky> $stickyModels */
$stickyModels = Sticky::query();
/** @var string $search Search field */

View file

@ -33,7 +33,7 @@ class StripController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $stripModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Strip> $stripModels */
$stripModels = Strip::query()->with('news');
/** @var string $search Search field */

View file

@ -28,7 +28,7 @@ class TestimonialController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $testimonialModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\Testimonial> $testimonialModels */
$testimonialModels = Testimonial::query();
/** @var string $search Search field */

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\UploadFileRequest;
use App\Lib\Helpers\FileStorageHelper;
use Illuminate\Database\Eloquent\Model;
class UploadController extends Controller
{
@ -19,9 +20,11 @@ class UploadController extends Controller
{
$modelClass = "App\\Models\\$request->folder";
if (!class_exists($modelClass)) {
if (!class_exists($modelClass) && !is_subclass_of($modelClass, Model::class)) {
return response()->json(['error' => 'Invalid model class'], 404);
}
/** @var \Illuminate\Database\Eloquent\Model $model */
$model = new $modelClass();
/** @var \Illuminate\Http\UploadedFile $image */

View file

@ -31,7 +31,7 @@ class UserController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $userModels */
/** @var \Illuminate\Database\Eloquent\Builder<\App\Models\User> $userModels */
$userModels = User::query();
/** @var string $search Search field */
@ -145,7 +145,7 @@ class UserController extends Controller
{
/** @var array<string,string> */
$previousQueries = [];
\parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
\parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries);
if ($user->deleteOrFail()) {
return redirect()->route('bo.users.index', $previousQueries)
->with('success', trans('crud.messages.has_been_deleted', [

View file

@ -24,13 +24,14 @@ class Controller extends BaseController
* Build Search query on specified fields
* splitting search into words or using whole sentence
*
* @param \Illuminate\Database\Eloquent\Builder $query The eloquent query builder.
* @param string $search The query string.
* @param callable|null $searchQuery The query string.
* @param string ...$fields Either a simple array or a string
* in case of a string the two fields
* would be concatenate to make the search.
* @return \Illuminate\Database\Eloquent\Builder
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query The eloquent query builder.
* @param string $search The searched string.
* @param callable|null $searchQuery The query string.
* @param string ...$fields Either a simple array or a string
* in case of a string the two fields
* would be concatenate to make the search.
* @return \Illuminate\Database\Eloquent\Builder<TModel>
*/
protected function searchQuery(
Builder $query,
@ -61,15 +62,16 @@ class Controller extends BaseController
/**
* Build query search on all fields
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $search
* @param array $fields
* @return \Illuminate\Database\Eloquent\Builder
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
* @param string $search
* @param array<int|string, string|array<int, string>> $fields
* @return \Illuminate\Database\Eloquent\Builder<TModel>
*/
private function searchOnFields(
Builder $query,
string $search,
array $fields
array $fields,
): \Illuminate\Database\Eloquent\Builder {
$table = $query->getModel()->getTable();
foreach ($fields as $field) {
@ -115,13 +117,17 @@ class Controller extends BaseController
/**
* Get the search value (on string or Enum).
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $search
* @param string $field
* @return string|array
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
* @param string $search
* @param string $field
* @return string|array<int, mixed>
*/
protected function getSearchValue(Builder $query, string $search, string $field): string|array
{
protected function getSearchValue(
Builder $query,
string $search,
string $field,
): string|array {
$cast = $query->getModel()->getCasts()[$field] ?? null;
if (
count($query->getModel()->getCasts()) and // Check if the model has casts.
@ -131,8 +137,8 @@ class Controller extends BaseController
/** @var \App\Traits\Enums $cast */
// @phpstan-ignore-next-line
$cases = collect($cast::toArray());
$enum = $cases->filter(function ($item) use ($search) {
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
$enum = $cases->filter(function ($item) use ($search): bool {
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label)) === 1;
});
return $enum->toArray();
} else {
@ -143,12 +149,15 @@ class Controller extends BaseController
/**
* Sort columns with a query.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $ignore
* @return \Illuminate\Database\Eloquent\Builder
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
* @param array<int, string> $ignore
* @return \Illuminate\Database\Eloquent\Builder<TModel>
*/
protected function sortQuery(Builder $query, array $ignore = []): \Illuminate\Database\Eloquent\Builder
{
protected function sortQuery(
Builder $query,
array $ignore = [],
): \Illuminate\Database\Eloquent\Builder {
$rName = request()->route()->getName();
$table = $query->getModel()->getTable();
if (request()->input('sort_col')) {
@ -194,9 +203,10 @@ class Controller extends BaseController
/**
* Customize pagination with cache or config (default).
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Database\Eloquent\Builder<TModel> $query
* @param \App\Enums\Pagination\ItemsPerPaginationEnum|null $pagination
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<TModel>
*/
protected function paginate(
Builder $query,
@ -208,7 +218,7 @@ class Controller extends BaseController
$pagination = ToolboxHelper::getValidatedEnum(
Cache::get($cacheKey, $pagination->value()),
'pagination',
'\App\Enums\Pagination\ItemsPerPaginationEnum',
ItemsPerPaginationEnum::class,
);
if (Cache::get($cacheKey) !== $pagination) {
Cache::put($cacheKey, $pagination);
@ -228,7 +238,7 @@ class Controller extends BaseController
$theme = ToolboxHelper::getValidatedEnum(
$request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
'theme',
'\App\Http\Controllers\BootstrapThemeEnum',
BootstrapThemeEnum::class,
);
if (Cache::get("theme") !== $theme) {
Cache::put("theme", $theme);

View file

@ -83,7 +83,7 @@ class StaticPageController extends Controller
$staticPageModel = StaticPage::query()->where('type', StaticPageType::unveil)->first();
$sectionModels = Section::query()->where('page_id', $staticPageModel->id)->get();
$historicalMilestoneModels = HistoricalMilestone::query()->orderBy('year', 'ASC')->get();
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Site> */
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Site> */
$siteModelList = Site::query()->orderBy('order')->get();
$keySection = $sectionModels->where('section', PageSectionEnum::unveil_pole)->first();
$missionsSection = $sectionModels->where('section', PageSectionEnum::unveil_missions)->first();
@ -98,10 +98,9 @@ class StaticPageController extends Controller
// * Calcul Viewbox leaflet map ().
// Carte page “on se dévoile” : Point central = Laval + rayon = 100 km
/** @var \App\Models\Site|null $lavalSite */
// @phpstan-ignore-next-line
$lavalSite = $siteModelList->first(fn(Site $site) => Str::contains($site->name, 'Laval'));
if ($lavalSite) {
$viewBox = (object)[
$viewBox = (object) [
'lat' => $lavalSite->latitude,
'lng' => $lavalSite->longitude
];
@ -252,8 +251,8 @@ class StaticPageController extends Controller
public function listenForm(ListenFormRequest $request): \Illuminate\Http\RedirectResponse
{
Mail::to(config('mail.contact.' . ObjectEnum::make(intval($request->validated()['object']))->name()))
->send(new SendContactMail((object)$request->validated()));
Mail::to($request->validated()['email'])->send(new SendConfirmationMail((object)$request->validated()));
->send(new SendContactMail((object) $request->validated()));
Mail::to($request->validated()['email'])->send(new SendConfirmationMail((object) $request->validated()));
return redirect()->route('fo.listen.show')
->with('success', trans(
@ -308,7 +307,7 @@ class StaticPageController extends Controller
*/
public function site(Site $site): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Site> */
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\Site> */
$siteModels = Site::query()->orderBy('order')->get();
$siteModelList = $siteModels->keyBy('order');
@ -321,7 +320,7 @@ class StaticPageController extends Controller
$nextSiteModel = $siteModelList->first();
}
$viewBox = (object)[
$viewBox = (object) [
'lat' => $site->latitude,
'lng' => $site->longitude
];

View file

@ -12,7 +12,7 @@ class HtmlSanitizer
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|array ...$params
* @param string|array<int, mixed> ...$params
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(

View file

@ -15,7 +15,7 @@ class SecureHeaders
* Great starting point would be to go check out @Scott_Helme's:
* https://securityheaders.com/
*
* @var array
* @var list<string>
*/
private $unwantedHeaderList = [
'X-Powered-By',
@ -112,9 +112,9 @@ class SecureHeaders
}
/**
* Remove unwanted headers
* Remove unwanted headers.
*
* @param array $headerList
* @param list<string> $headerList
* @return void
*/
private function removeUnwantedHeaders(array $headerList): void

View file

@ -45,7 +45,7 @@ class StoreCarouselRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -91,7 +91,7 @@ class StoreCarouselRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -36,7 +36,7 @@ class StoreHistoricalMilestoneRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -61,7 +61,7 @@ class StoreHistoricalMilestoneRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -22,7 +22,7 @@ class StoreJobVideoRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -36,7 +36,7 @@ class StoreJobVideoRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -32,7 +32,7 @@ class StoreLogoRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -51,7 +51,7 @@ class StoreLogoRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -36,7 +36,7 @@ class StoreNewsRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -67,7 +67,7 @@ class StoreNewsRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -56,7 +56,7 @@ class UpdateSectionRequest extends UpdateMiniCrudRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -27,10 +27,12 @@ class StoreSiteRequest extends FormRequest
*/
protected function prepareForValidation(): void
{
/** @var array<int, mixed> $pictos */
$pictos = $this->input('pictos') ?? [];
$this->merge([
'published' => $this->boolean('published'),
'invert_director_block' => $this->boolean('invert_director_block'),
'pictos' => \collect($this->input('pictos'))->all(),
'pictos' => \collect($pictos)->all(),
]);
$this->mergePicture('logo');
$this->mergePicture('picture_1');
@ -41,7 +43,7 @@ class StoreSiteRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -93,7 +95,7 @@ class StoreSiteRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -39,7 +39,7 @@ class StoreSlideRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -92,7 +92,7 @@ class StoreSlideRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{
@ -114,7 +114,7 @@ class StoreSlideRequest extends FormRequest
/**
* Custom validaton messages.
*
* @return array
* @return array<string, string>
*/
public function messages(): array
{

View file

@ -68,7 +68,7 @@ class UpdateStaticPageRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -22,7 +22,7 @@ class StoreStickyRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -43,7 +43,7 @@ class StoreStickyRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -39,7 +39,7 @@ class StoreStripRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -59,8 +59,8 @@ class StoreStripRequest extends FormRequest
$rules = array_merge(
$rules,
[
'picture_alt' => 'required_with|string|between:3,255',
'picture_title' => 'required_with|string|between:3,255',
'picture_alt' => 'required_with|string|between:3,255',
'picture_title' => 'required_with|string|between:3,255',
],
$this->pictureRules('picture', 100, 65, 100, 65, true),
);
@ -82,7 +82,7 @@ class StoreStripRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -33,7 +33,7 @@ class StoreTestimonialRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -57,7 +57,7 @@ class StoreTestimonialRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -31,7 +31,7 @@ class UpdateChangeOrderRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{

View file

@ -29,8 +29,8 @@ abstract class UpdateMiniCrudRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.MaxExceeded
* @phpcs:disable Generic.Metrics.NestingLevel.TooHigh
*/
public function rules(): array
@ -38,7 +38,8 @@ abstract class UpdateMiniCrudRequest extends FormRequest
// phpcs:enable
$rules = [];
foreach ($this->{$this->modelName}->data as $iptName => $input) {
$input = \json_decode(\json_encode($input), true);
$encoded = \json_encode($input);
$input = \json_decode($encoded !== false ? $encoded : '[]', true);
switch ($input['inputType']) {
case InputType::number->value:
$rules = array_merge($rules, [
@ -71,7 +72,7 @@ abstract class UpdateMiniCrudRequest extends FormRequest
$mergeRules = $this->compileValidate('required|string|min:15', $input);
$mergeRules = collect($mergeRules)
->map(function ($rule) {
if (\strpos($rule, 'max:') !== false) {
if (\is_string($rule) && \strpos($rule, 'max:') !== false) {
$max = \intval(str_replace('max:', '', $rule));
return function ($attribute, $value, $fail) use ($max) {
if (\strlen(\strip_tags($value)) > $max) {
@ -80,7 +81,7 @@ abstract class UpdateMiniCrudRequest extends FormRequest
};
}
return $rule;
});
})->all();
$rules = array_merge($rules, [
"data.$iptName.value" => $mergeRules
]);
@ -99,11 +100,11 @@ abstract class UpdateMiniCrudRequest extends FormRequest
}) : $input['dimensions'];
// * Adapt dimensions
$sizes = (object)[
$sizes = [
'minHeight' => $dim['height'],
'maxHeight' => $dim['height'],
'minWidth' => $dim['width'],
'maxWidth' => $dim['width'],
'minWidth' => $dim['width'],
'maxWidth' => $dim['width'],
];
$rules = array_merge($rules, [
"data.$iptName.value" => [
@ -155,22 +156,23 @@ abstract class UpdateMiniCrudRequest extends FormRequest
break;
} //end switch
} //end foreach
// @phpstan-ignore-next-line
return $rules;
}
/**
* Undocumented function
* Undocumented function.
*
* @param string|array $inputTypeValidate
* @param array $input
* @return array
* @param string|array<int, string> $inputTypeValidate
* @param array<string, mixed> $input
* @return array<int, mixed>
*/
public function compileValidate(string|array $inputTypeValidate, array $input): array
{
if (\is_string($inputTypeValidate)) {
$inputTypeValidate = explode('|', $inputTypeValidate);
}
/** @var array|string */
/** @var array<int|string, mixed>|string $inputValidate */
$inputValidate = \collect($input)->get('validate', $input);
$inputValidate = \is_string($inputValidate) ? explode('|', $inputValidate) : $inputValidate;
foreach ($inputValidate as $validate) {

View file

@ -38,7 +38,7 @@ class UpdateOrderRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{

View file

@ -19,7 +19,7 @@ class UploadFileRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{

View file

@ -35,7 +35,7 @@ class StoreUserRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -51,7 +51,7 @@ class StoreUserRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -32,7 +32,7 @@ class UpdateUserRequest extends StoreUserRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{

View file

@ -30,7 +30,7 @@ class ListenFormRequest extends FormRequest
/**
* Get the validation rules that apply to the request.
*
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
@ -101,7 +101,7 @@ class ListenFormRequest extends FormRequest
/**
* Get custom attributes for validator errors.
*
* @return array
* @return array<string, string>
*/
public function attributes(): array
{

View file

@ -0,0 +1,48 @@
<?php
namespace App\Jobs;
use App\Models\ActivityLog;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
/**
* Permanently deletes entries that have been stored for more than one year.
*/
class CleanOldActivities implements ShouldQueue, ShouldBeUnique
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Create the controller instance.
*
* @param boolean $force
*/
public function __construct(public readonly bool $force = false)
{
}
/**
* Delete entries if it has been stored for more than one year.
*
* @return void
*/
public function handle(): void
{
$query = ActivityLog::query();
if (!$this->force) {
$query->where('created_at', '<', Carbon::now()->subYear());
}
$query->cursor()->each(fn($model) => $model->delete());
}
}

View file

@ -20,37 +20,34 @@ class UpdatePlanificatedStatus
*/
public function handle(): void
{
// Set all models to apply status modifications.
collect([News::class, Strip::class])
->each(function (string $model) {
// Get all published model with an unpublish_at date passed.
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> $modelListToUnPublish */
$modelListToUnPublish = $model::query()
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> */
$modelListToPublish = $model::query()
->whereNotNull('publish_at')
->where('publish_at', '<=', Carbon::now())
->where(function ($query) {
$query->whereNull('unpublish_at')
->orWhere('unpublish_at', '>', Carbon::now());
})
->where('published', false)
->get();
Log::debug(__CLASS__ . " models to publish " . $modelListToPublish->count());
$modelListToPublish->each(function ($currentModel) {
$currentModel->published = true;
$currentModel->saveOrFail();
});
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> */
$modelListToUnpublish = $model::query()
->whereNotNull('unpublish_at')
->where('unpublish_at', '<=', Carbon::now())
->where('published', true)
->get();
Log::debug(__CLASS__ . " model to unpublish " . $modelListToUnPublish->count());
// Unpublish all models with an unpublish_at date passed.
$modelListToUnPublish->each(function (News|Strip $modelToUnpublish) {
$modelToUnpublish->published = false;
$modelToUnpublish->saveOrFail();
});
// Get all unpublished model with a publish_at date passed.
/** @var \Illuminate\Database\Eloquent\Collection<array-key,\App\Models\News|\App\Models\Strip> $modelListToPublish */
$modelListToPublish = $model::query()
->where('publish_at', '<=', Carbon::now())
->whereNotNull('publish_at')
->where('published', false)
->get();
Log::debug(__CLASS__ . " model to publish " . $modelListToPublish->count());
// Publish all models with a publish_at date passed.
$modelListToPublish->each(function (News|Strip $modelToPublish) {
$modelToPublish->published = true;
$modelToPublish->saveOrFail();
Log::debug(__CLASS__ . " models to unpublish " . $modelListToUnpublish->count());
$modelListToUnpublish->each(function ($currentModel) {
$currentModel->published = false;
$currentModel->saveOrFail();
});
});
}

View file

@ -10,26 +10,27 @@ use Illuminate\Support\Collection;
class CollectionHelper
{
/**
* Paginate a collection
* Paginate a collection.
*
* @param \Illuminate\Support\Collection $results
* @param integer $pageSize
* @return \Illuminate\Pagination\LengthAwarePaginator
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Support\Collection<int, TModel> $results
* @param integer $pageSize
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
*/
public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator
{
$page = Paginator::resolveCurrentPage('page');
return self::paginateManually($results, $pageSize, $page);
}
/**
* Paginate a collection
* Paginate a collection.
*
* @param \Illuminate\Support\Collection $results
* @param integer $pageSize
* @param integer $page
* @return \Illuminate\Pagination\LengthAwarePaginator
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Support\Collection<int, TModel> $results
* @param integer $pageSize
* @param integer $page
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
*/
public static function paginateManually(
Collection $results,
@ -39,7 +40,7 @@ class CollectionHelper
$total = $results->count();
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
'path' => Paginator::resolveCurrentPath(),
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
@ -47,12 +48,13 @@ class CollectionHelper
/**
* Create a new length-aware paginator instance.
*
* @param \Illuminate\Support\Collection $items
* @param integer $total
* @param integer $perPage
* @param integer $currentPage
* @param array $options
* @return \Illuminate\Pagination\LengthAwarePaginator
* @template TModel of \Illuminate\Database\Eloquent\Model
* @param \Illuminate\Support\Collection<int, TModel> $items
* @param integer $total
* @param integer $perPage
* @param integer $currentPage
* @param array<mixed> $options
* @return \Illuminate\Pagination\LengthAwarePaginator<TModel>
*/
protected static function paginator(
Collection $items,
@ -62,11 +64,11 @@ class CollectionHelper
array $options
): \Illuminate\Pagination\LengthAwarePaginator {
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
'items' => $items,
'total' => $total,
'perPage' => $perPage,
'items' => $items,
'total' => $total,
'perPage' => $perPage,
'currentPage' => $currentPage,
'options' => $options
'options' => $options
]);
}
}

View file

@ -5,7 +5,7 @@ namespace App\Lib\Helpers;
class ExceptionsHelper
{
/**
* Handle sentry event
* Handle sentry event.
*
* @param \Sentry\Event $event
* @return null|\Sentry\Event
@ -26,7 +26,7 @@ class ExceptionsHelper
}
/**
* Anonimize Sentry Exception bag
* Anonimize Sentry Exception bag.
*
* @param \Sentry\ExceptionDataBag $exceptionDataBag
* @return \Sentry\ExceptionDataBag
@ -42,7 +42,7 @@ class ExceptionsHelper
}
/**
* Anonymise sentry stacktrace
* Anonymise sentry stacktrace.
*
* @param \Sentry\Stacktrace $stackTrace
* @return \Sentry\Stacktrace
@ -70,7 +70,7 @@ class ExceptionsHelper
}
/**
* Get anonymized sentry params
* Get anonymized sentry params.
*
* @param mixed[] $params
* @return string[]
@ -80,7 +80,7 @@ class ExceptionsHelper
foreach ($params as &$param) {
$type = \strtolower(\gettype($param));
if (\is_string($param)) {
$type = \explode(' ', \trim(strtolower($param)))[0] ?? null;
$type = \explode(' ', \trim(strtolower($param)))[0];
}
switch (true) {
case $type === 'lambda':
@ -104,7 +104,7 @@ class ExceptionsHelper
}
/**
* Anonymize at least Sql queries
* Anonymize at least Sql queries.
*
* @param string $message
* @return string
@ -119,14 +119,14 @@ class ExceptionsHelper
}
/**
* Anonymize stack trace
* Anonymize stack trace.
*
* @param \Throwable $e
* @return string
*/
public static function getAnonymizedStackTrace(\Throwable $e): string
{
$projectPath = \realpath(\sprintf('%s/../', \app_path()));
$projectPath = \realpath(\sprintf('%s/../', \app_path())) ?: '';
$traceStack = $e->getTrace();
$traceStr = '';
$maxStackStage = 0;
@ -158,9 +158,9 @@ class ExceptionsHelper
}
/**
* Handle Args
* Handle Args.
*
* @param array $stack
* @param array<string, mixed> $stack
* @return string
*/
public static function handleArgs(array $stack): string

View file

@ -25,8 +25,6 @@ use Illuminate\Support\Str;
* The final path will be storage/modelfiles/posts/10/04/19/5f/black-cat-under-red-car-286071690833400.png
*
* ! No limits of file per folder will be handled.
*
* @author Munsch Jérémy <jeremy.munsch@ldc.fr>
*/
class FileStorageHelper
{
@ -40,7 +38,7 @@ class FileStorageHelper
{
/** @var \Illuminate\Filesystem\FilesystemAdapter */
$disk = Storage::disk('uploads');
$path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
return $disk->path($path);
}
@ -57,7 +55,7 @@ class FileStorageHelper
if (\strpos($path, 'storage') !== 0) {
return;
}
$path = ToolboxHelper::mbReplace('storage/', '', $path);
$path = ToolboxHelper::mbReplaceString('storage/', '', $path);
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
@ -81,7 +79,7 @@ class FileStorageHelper
if (\strpos($originalPath, 'storage') !== 0) {
return;
}
$originalPath = ToolboxHelper::mbReplace('storage/', '', $originalPath);
$originalPath = ToolboxHelper::mbReplaceString('storage/', '', $originalPath);
if (Storage::disk('public')->exists($originalPath)) {
Storage::disk('public')->delete($originalPath);
}
@ -106,7 +104,7 @@ class FileStorageHelper
$file,
bool $slugify = false,
string|null $filename = null,
bool $private = false
bool $private = false,
): string {
// phpcs:enable
$tableName = $model->getTable();
@ -173,9 +171,9 @@ class FileStorageHelper
/** @var \Illuminate\Filesystem\FilesystemAdapter */
$disk = Storage::disk('uploads');
$fileInfo = new \SplFileInfo($disk->path(
ToolboxHelper::mbReplace('/uploads/', '', \urldecode($path))
ToolboxHelper::mbReplaceString('/uploads/', '', \urldecode($path))
));
$htmlString = ToolboxHelper::mbReplace(
$htmlString = ToolboxHelper::mbReplaceString(
$path,
'/' . self::storeFile($model, $fileInfo, true),
$htmlString
@ -216,7 +214,7 @@ class FileStorageHelper
$filesToKeep = \collect(self::onlyUploadedFilesWithFileStorageHelper($newFiles));
$filesToRemove = $oldFiles->diff($filesToKeep);
$filesToRemove->each(function (string $publicStorageFilePath) {
$path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
@ -233,7 +231,7 @@ class FileStorageHelper
{
$filesToRemove = \collect(self::onlyUploadedFilesWithFileStorageHelper(self::findFilesInHtml($htmlString)));
$filesToRemove->each(function (string $publicStorageFilePath) {
$path = ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
$path = ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($publicStorageFilePath), '/'));
if (Storage::disk('public')->exists($path)) {
Storage::disk('public')->delete($path);
}
@ -244,7 +242,7 @@ class FileStorageHelper
* Find all occurence of files in html
*
* @param string $html
* @return array
* @return array<mixed>
*/
public static function findFilesInHtml(string $html): array
{
@ -259,20 +257,20 @@ class FileStorageHelper
* Filter array to get only uploaded files that exists
* on disk 'public' (using helper storage strategy)
*
* @param array $urls
* @return array
* @param array<int, string> $urls
* @return array<mixed>
*/
public static function onlyUploadedFilesWithFileStorageHelper(array $urls): array
{
return \collect($urls)->unique()
// * Filter to get only /uploads and using app url or empty
->filter(function (string $url) {
$path = \parse_url($url, \PHP_URL_PATH);
$path = (string) \parse_url($url, \PHP_URL_PATH);
return \strpos(\ltrim($path, '/'), 'storage/modelfiles') === 0;
})->filter(function (string $url) {
$path = \parse_url($url, \PHP_URL_PATH);
$path = (string) \parse_url($url, \PHP_URL_PATH);
return Storage::disk('public')
->exists(ToolboxHelper::mbReplace('storage/', '', \ltrim(\urldecode($path), '/')));
->exists(ToolboxHelper::mbReplaceString('storage/', '', \ltrim(\urldecode($path), '/')));
})->all();
}
@ -280,22 +278,22 @@ class FileStorageHelper
* Filter array to get only uploaded files that exists
* on disk 'uploads'
*
* @param array $urls
* @return array
* @param array<int, string> $urls
* @return array<mixed>
*/
private static function onlyUploadedFilesWithFileManager(array $urls): array
{
return \collect($urls)->unique()
// * Filter to get only /uploads and using app url or empty
->filter(function (string $url) {
$host = \parse_url($url, \PHP_URL_HOST);
$path = \parse_url($url, \PHP_URL_PATH);
return ($host === \parse_url(config('app.url'), PHP_URL_HOST) or \is_null($host)) and
$host = (string) \parse_url($url, \PHP_URL_HOST);
$path = (string) \parse_url($url, \PHP_URL_PATH);
return ($host === (string) \parse_url(config('app.url'), PHP_URL_HOST) or $host === '') and
\strpos(\ltrim($path, '/'), 'uploads') === 0;
})->filter(function (string $url) {
$path = \parse_url($url, \PHP_URL_PATH);
$path = (string) \parse_url($url, \PHP_URL_PATH);
return Storage::disk('uploads')
->exists(ToolboxHelper::mbReplace('uploads/', '', \ltrim(\urldecode($path), '/')));
->exists(ToolboxHelper::mbReplaceString('uploads/', '', \ltrim(\urldecode($path), '/')));
})->all();
}
@ -459,7 +457,7 @@ class FileStorageHelper
'/\.{2,}/'
], '.', $filename);
// Lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 .
$filename = mb_strtolower($filename, mb_detect_encoding($filename));
$filename = mb_strtolower($filename, mb_detect_encoding($filename) ?: null);
// * ".file-name.-" becomes "file-name"
$filename = trim($filename, '.-');
return $filename;
@ -468,7 +466,7 @@ class FileStorageHelper
/**
* Remove all model files for the given Model.
*
* @param Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @return void
*/
public static function removeModelFiles(Model $model): void

View file

@ -3,7 +3,7 @@
namespace App\Lib\Helpers;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@ -24,8 +24,8 @@ class ToolboxHelper
/**
* Run a terminal command and gives the output.
*
* @param array|string $command The command to execute on terminal.
* @param boolean $throw Wether to throw en esception on failure or not.
* @param array<string>|string $command The command to execute on terminal.
* @param boolean $throw Wether to throw en esception on failure or not.
* @return string|false Return false on failure only if $throw is false.
* @phpcs:disable Squiz.Commenting.FunctionComment.EmptyThrows
* @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
@ -36,7 +36,7 @@ class ToolboxHelper
* @throws \LogicException
* @throws \RuntimeException If the command fails.
*/
public static function runConsoleCommand(array|string $command, bool $throw = true): string | false
public static function runConsoleCommand(array|string $command, bool $throw = true): string|false
{
// phpcs:enable
$process = \Illuminate\Support\Facades\Process::command($command)->run();
@ -54,7 +54,6 @@ class ToolboxHelper
/**
* @param array<int|string, mixed> $array1
* @param array<int|string, mixed> $array2
*
* @return array<int|string, mixed>
*/
public static function arrayMergeRecursiveDistinct(array &$array1, array &$array2): array
@ -67,7 +66,6 @@ class ToolboxHelper
$merged[$key] = $value;
}
}
return $merged;
}
@ -230,11 +228,12 @@ class ToolboxHelper
/**
* Mutltibyte string replace.
*
* @param array|string $search
* @param array|string $replace
* @param array|string $subject
* @param integer $count
* @return array|string|false
* @param array<string>|string $search
* @param array<string>|string $replace
* @param array<string>|string $subject
* @param integer $count
* @return array<string>|string|false
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
*/
public static function mbReplace(
array|string $search,
@ -248,37 +247,58 @@ class ToolboxHelper
if (is_array($subject)) {
// Call mb_replace for each single string in $subject .
foreach ($subject as &$string) {
$string = &self::mbReplace($search, $replace, $string, $count);
$string = &self::mbReplace($search, $replace, $string, $count) ?: '';
}
return $subject;
} elseif (is_array($search)) {
if (!is_array($replace)) {
foreach ($search as &$string) {
$subject = self::mbReplace($string, $replace, $subject, $count);
$subject = self::mbReplace($string, $replace, $subject, $count) ?: '';
}
} else {
$n = max(count($search), count($replace));
while ($n--) {
$subject = self::mbReplace(current($search), current($replace), $subject, $count);
$currentSearch = current($search);
$currentReplace = current($replace);
if ($currentSearch === false || $currentReplace === false) {
break;
}
$result = self::mbReplace($currentSearch, $currentReplace, $subject, $count);
$subject = is_string($result) ? $result : '';
next($search);
next($replace);
}
}
} else {
$parts = mb_split(preg_quote($search), $subject);
$count = count($parts) - 1;
$subject = implode($replace, $parts);
$parts = mb_split(preg_quote($search), $subject) ?: [];
$count = (int) count($parts) - 1;
$subject = implode(is_array($replace) ? '' : $replace, $parts);
} //end if
return $subject;
}
/**
* Asserts that the field is unique.
* Multibyte string replace (string only version).
*
* @param string $table
* @param string $field
* @param string|integer|float|boolean|null|array $value
* @param integer|null $id
* @param callable|null $query
* @param string $search
* @param string $replace
* @param string $subject
* @return string
*/
public static function mbReplaceString(string $search, string $replace, string $subject): string
{
$parts = mb_split(preg_quote($search), $subject) ?: [];
return implode($replace, $parts);
}
/**
* Asserts that the field is unique
*
* @param string $table
* @param string $field
* @param string|integer|float|boolean|null|array<mixed> $value
* @param integer|null $id
* @param callable|null $query
* @return void
* @throws \Illuminate\Validation\ValidationException If the field is not unique.
*/
@ -291,20 +311,24 @@ class ToolboxHelper
): void {
if (!$query) {
Validator::make([$field => $value], [
/** @phpstan-ignore-next-line */
self::mbReplace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id),
], [
self::mbReplace('.', '\.', "{$field}.unique")
=> trans('crud.libs.toolbox.assertFieldIsUnique', ['attribute' => $field, 'value' => $value])
/** @phpstan-ignore-next-line */
self::mbReplace('.', '\.', "{$field}.unique") => trans('crud.libs.toolbox.assertFieldIsUnique', [
'attribute' => $field,
'value' => is_array($value) ? implode(', ', array_map('strval', $value)) : (string) $value,
])
])->validate();
return;
}
Validator::make([$field => $value], [
$field => Rule::unique($table)->where($query)->ignore($id),
$field => Rule::unique($table)->where(\Closure::fromCallable($query))->ignore($id),
], [
$field . '.unique' => trans(
'crud.libs.toolbox.assertFieldIsUnique',
['attribute' => $field, 'value' => $value]
)
$field . '.unique' => trans('crud.libs.toolbox.assertFieldIsUnique', [
'attribute' => $field,
'value' => is_array($value) ? implode(', ', array_map('strval', $value)) : (string) $value,
])
])->validate();
}
@ -337,20 +361,20 @@ class ToolboxHelper
/**
* Dynamic model query.
*
* @param string $defaultLocale
* @param \Illuminate\Database\Eloquent\Builder $q
* @param string $column
* @param string $value
* @return \Illuminate\Database\Eloquent\Builder
* @param string $defaultLocale
* @param \Illuminate\Contracts\Database\Eloquent\Builder $q
* @param string $column
* @param string $value
* @return \Illuminate\Contracts\Database\Eloquent\Builder
*/
public static function queryColumnWithLocales(
string $defaultLocale,
Builder $q,
string $column,
string $value
): \Illuminate\Database\Eloquent\Builder {
): \Illuminate\Contracts\Database\Eloquent\Builder {
$currentLocale = app()->currentLocale();
$locales = collect(config('app.locales'))
$locales = collect((array) config('app.locales', []))
->mapWithKeys(fn (string $locale) => [$locale => $locale]);
if (!$locales->has($defaultLocale)) {
// * Remove default locale.
@ -378,15 +402,16 @@ class ToolboxHelper
/**
* Generates an array from a dot separated string.
*
* @param string $path
* @param mixed $value
* @param string $separator
* @return array
* @param string $path
* @param mixed $value
* @param string|null $separator
* @return array<mixed>
*/
public static function dotStringToNestedArray(string $path, mixed $value, string $separator = '.'): array
public static function dotStringToNestedArray(string $path, mixed $value, string|null $separator = null): array
{
$arr = $value;
$keys = array_reverse(explode($separator, $path));
$arr = $value;
$separator = $separator ?: '.';
$keys = array_reverse(explode($separator, $path));
foreach ($keys as $key) {
$arr = [$key => $arr];
@ -398,7 +423,7 @@ class ToolboxHelper
* Convert deeply an object to array.
*
* @param mixed $input
* @return array
* @return array<mixed>
* @throws \RuntimeException If $input var is a scalar value.
*/
public static function objectToArray(mixed $input): array
@ -407,7 +432,7 @@ class ToolboxHelper
if (!(is_object($input) or is_array($input))) {
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
}
$ret = (array)$input;
$ret = (array) $input;
foreach ($ret as &$item) {
// Recursively process EACH element only if not scalar.
$item = (is_object($item) or is_array($item)) ?
@ -429,25 +454,25 @@ class ToolboxHelper
if (!(is_object($input) or is_array($input))) {
throw new \RuntimeException('Cannot handle $input of type ' . \gettype($input));
}
$ret = (object)$input;
$ret = (array) $input;
foreach ($ret as &$item) {
// Recursively process EACH element only if not scalar.
$item = (is_object($item) or is_array($item)) ?
self::arrayToObject($item) : $item;
}
return $ret;
return (object) $ret;
}
/**
* Validate picture.
*
* @param string $attribute
* @param string|null $value
* @param callable $fail
* @param object $sizes
* @param string $attribute
* @param string|null $value
* @param callable $fail
* @param array{minWidth: int, maxWidth: int, minHeight: int, maxHeight: int} $sizes
* @return void
*/
public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes): void
public static function validatePicture(string $attribute, string|null $value, callable $fail, array $sizes): void
{
if (!($useStorage = Storage::exists($value)) and !File::exists($value)) {
$fail(trans(':attribute n\'existe pas dans le système de fichier', [
@ -474,22 +499,22 @@ class ToolboxHelper
$height = intval($dimensions[1]);
$xMessage = trans(
":attribute la largeur doit être comprise entre {$sizes->minWidth}px et {$sizes->maxWidth}px"
":attribute la largeur doit être comprise entre {$sizes['minWidth']}px et {$sizes['maxWidth']}px"
);
if ($sizes->minWidth === $sizes->maxWidth) {
$xMessage = trans(":attribute la largeur doit être de {$sizes->minWidth}px");
if ($sizes['minWidth'] === $sizes['maxWidth']) {
$xMessage = trans(":attribute la largeur doit être de {$sizes['minWidth']}px");
}
$yMessage = trans(
":attribute la hauteur doit être comprise entre {$sizes->minHeight}px et {$sizes->maxHeight}px"
":attribute la hauteur doit être comprise entre {$sizes['minHeight']}px et {$sizes['maxHeight']}px"
);
if ($sizes->minHeight === $sizes->maxHeight) {
$yMessage = trans(":attribute la hauteur doit être de {$sizes->minHeight}px");
if ($sizes['minHeight'] === $sizes['maxHeight']) {
$yMessage = trans(":attribute la hauteur doit être de {$sizes['minHeight']}px");
}
if (($width < $sizes->minWidth) or ($width > $sizes->maxWidth)) {
if (($width < $sizes['minWidth']) or ($width > $sizes['maxWidth'])) {
$fail($xMessage);
}
if (($height < $sizes->minHeight) or ($height > $sizes->maxHeight)) {
if (($height < $sizes['minHeight']) or ($height > $sizes['maxHeight'])) {
$fail($yMessage);
}
} //end if
@ -546,7 +571,7 @@ class ToolboxHelper
{
return Arr::where(
static::getClassesUsingNamespace($namespace),
fn (string $class_namespace) => \collect(class_implements($class_namespace, true))->filter()
fn (string $class_namespace) => \collect(class_implements($class_namespace, true) ?: [])->filter()
->contains(fn (string $class_interface) => $class_interface === $interface)
);
}
@ -554,9 +579,9 @@ class ToolboxHelper
/**
* Get validated pagination from request.
*
* @param integer $default
* @param string $field
* @param string $enumPath
* @param integer $default
* @param string $field
* @param class-string<\UnitEnum> $enumPath
* @return integer
*/
public static function getValidatedEnum(int $default, string $field, string $enumPath): int

View file

@ -46,10 +46,10 @@ class SendConfirmationMail extends Mailable
*/
private function sanitizeStringInputs(): void
{
$this->data = (object)Arr::map((array)$this->data, function ($el) {
$this->data = (object) Arr::map((array) $this->data, function ($el) {
if (is_string($el)) {
$el = \htmlspecialchars(\strip_tags(Blade::render(
(string)Markdown::parse($el)
(string) Markdown::parse($el)
)));
$el = Str::of($el)->replaceMatches(
'/[^\p{L}0-9\n\s\@\.\:\-\_\?\!\;\(\)\+\-\/\\\=]+/us',

View file

@ -49,10 +49,10 @@ class SendContactMail extends Mailable
*/
private function sanitizeStringInputs(): void
{
$this->data = (object)Arr::map((array)$this->data, function ($el) {
$this->data = (object) Arr::map((array) $this->data, function ($el) {
if (is_string($el)) {
$el = \htmlspecialchars(\strip_tags(Blade::render(
(string)Markdown::parse($el)
(string) Markdown::parse($el)
)));
$el = Str::of($el)->replaceMatches(
'/[^\p{L}0-9\n\s\@\.\:\-\_\?\!\;\(\)\+\-\/\\\=]+/us',

View file

@ -3,25 +3,20 @@
namespace App\Models;
use App\Enums\ActivityLogs\ActivityLogsEventEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
/**
* @property string $model Target model.
* @property string $model_id Id of the target model.
* @property \App\Enums\ActivityLogs\ActivityLogsEventEnum $event Event of this activity (ActivityLogsEventEnum).
* @property array $data Changes.
* @property \Illuminate\Support\Carbon $created_at Created date.
* @property array<string, mixed> $data Changes.
* @property-read \Illuminate\Support\Carbon $created_at Created date.
*
* @property-read \App\Models\User $user User BelongsTo relation.
*/
class ActivityLog extends Model
{
use HasFactory;
use Notifiable;
/**
* Indicates if the model should be timestamped.
*
@ -32,7 +27,7 @@ class ActivityLog extends Model
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'is_anonymous',
@ -81,7 +76,8 @@ class ActivityLog extends Model
$activity->model_id = $model->getKey();
$activity->event = $eventEnum;
$activity->data = static::getChangedColumns($activity, $model, $eventEnum);
$activity->created_at = now();
// @phpstan-ignore-next-line
$activity->created_at = now();
$activity->saveOrFail();
}
@ -91,17 +87,19 @@ class ActivityLog extends Model
* @param self $activity
* @param \Illuminate\Database\Eloquent\Model $model
* @param \App\Enums\ActivityLogs\ActivityLogsEventEnum $eventEnum
* @return array
* @return array<string, string>
*/
public static function getChangedColumns(self $activity, Model $model, ActivityLogsEventEnum $eventEnum): array
{
$modelClassName = $activity->model_class;
$modelTarget = new $modelClassName();
/** Get type of each fields of the target model */
/** @var \Illuminate\Database\Eloquent\Model|null $targetModel */
$targetModel = $activity->model_class::where(
(new $modelClassName())->getRouteKeyName(),
$targetModel = ($modelTarget instanceof \Illuminate\Database\Eloquent\Model) ? $activity->model_class::where(
$modelTarget->getRouteKeyName(),
$activity->model_id
)->first();
)->first() : null;
if (\is_null($targetModel)) {
return [];
@ -133,6 +131,7 @@ class ActivityLog extends Model
// phpcs:enable
$type = \gettype($value);
switch ($type) {
// phpcs:ignore PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
case 'string':
return match (true) {
Str::length(\strip_tags($value)) !== Str::length($value) => 'html',
@ -163,12 +162,12 @@ class ActivityLog extends Model
} //end switch
}
// * RELATIONS
// * RELATIONS.
/**
* User BelongsTo relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User,$this>
*/
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{

View file

@ -5,20 +5,18 @@ namespace App\Models;
use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use App\Traits\Models\Orderable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Validation\ValidationException;
class Aisle extends Model
{
use ActivityLog;
use HasFactory;
use Orderable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'name',
@ -67,7 +65,7 @@ class Aisle extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -120,12 +118,12 @@ class Aisle extends Model
return 'network_id';
}
// * RELATIONS
// * RELATIONS.
/**
* The network that belongs to the logo.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Network,$this>
*/
public function network(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
@ -135,7 +133,7 @@ class Aisle extends Model
/**
* Associated brands.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Brand,$this>
*/
public function brands(): \Illuminate\Database\Eloquent\Relations\HasMany
{

View file

@ -4,19 +4,17 @@ namespace App\Models;
use App\Lib\Helpers\FileStorageHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Validation\ValidationException;
class Brand extends Model
{
use ActivityLog;
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'name',
@ -62,7 +60,7 @@ class Brand extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -72,10 +70,10 @@ class Brand extends Model
*/
private static function manageFields(self $model): void
{
// * ASSERTIONS
// * ASSERTIONS.
self::assertLimitPublishedModels($model);
// * TRANSFORMATIONS
// * TRANSFORMATIONS.
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
}
@ -107,12 +105,12 @@ class Brand extends Model
}
}
// * RELATIONS
// * RELATIONS.
/**
* Associated aisle.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Aisle,$this>
*/
public function aisle(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{

View file

@ -6,28 +6,26 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use App\Traits\Models\Orderable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property-read int $id Id.
* @property string $title Title.
* @property array $media Medias of the carousel.
* @property-read \Carbon\Carbon $created_at Created date.
* @property-read \Carbon\Carbon $updated_at Updated date.
* @property-read int $id Id.
* @property string $title Title.
* @property array $media Medias of the carousel.
* @property-read \Carbon\Carbon $created_at Created date.
* @property-read \Carbon\Carbon $updated_at Updated date.
*
* @property-read \App\Models\ActivityLog $activityLogs Activities logs One-to-many relationship.
*/
class Carousel extends Model
{
use ActivityLog;
use HasFactory;
use Orderable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'section_id',
@ -43,7 +41,7 @@ class Carousel extends Model
* @var array<string, string>
*/
protected $casts = [
'media' => 'array',
'media' => 'array',
'published' => 'boolean',
];
@ -78,7 +76,7 @@ class Carousel extends Model
});
}
// * METHODS
// * METHODS.
/**
* Group ordering by section_id.
@ -90,13 +88,12 @@ class Carousel extends Model
return 'section_id';
}
// * RELATIONSHIPS
// * RELATIONSHIPS.
/**
* Get the sections that owns the Carousel
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Section,$this>
*/
public function section(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{

View file

@ -26,12 +26,13 @@ use Illuminate\Database\Eloquent\Model;
class HistoricalMilestone extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\HistoricalMilestoneFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'title',
@ -78,7 +79,7 @@ class HistoricalMilestone extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.

View file

@ -18,12 +18,13 @@ use Illuminate\Database\Eloquent\Model;
class JobVideo extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\JobVideoFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'title',

View file

@ -21,12 +21,13 @@ use Illuminate\Database\Eloquent\Model;
class Logo extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\LogoFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'label',
@ -57,7 +58,7 @@ class Logo extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -70,12 +71,12 @@ class Logo extends Model
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
}
// * RELATIONS
// * RELATIONS.
/**
* The sites that belong to the logo.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\Site,$this>
*/
public function sites(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{

View file

@ -5,7 +5,6 @@ namespace App\Models;
use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
@ -13,12 +12,11 @@ use Illuminate\Validation\ValidationException;
class Network extends Model
{
use ActivityLog;
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'seo_title',
@ -69,7 +67,7 @@ class Network extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -79,12 +77,12 @@ class Network extends Model
*/
private static function manageFields(self $model): void
{
// * ASSERTIONS
// * ASSERTIONS.
self::assertLimitPublishedModels($model);
self::assertFieldIsUnique('name', $model->name, $model->id);
self::assertFieldIsUnique('slug', Str::slug($model->name), $model->id);
// * TRANSFORMATIONS
// * TRANSFORMATIONS.
self::setSlug($model, $model->name);
$model->picture = FileStorageHelper::storeFile($model, $model->picture, true);
}
@ -151,12 +149,12 @@ class Network extends Model
}
}
// * RELATIONS
// * RELATIONS.
/**
* The aisles that belong to the logo.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Aisle,$this>
*/
public function aisles(): \Illuminate\Database\Eloquent\Relations\HasMany
{

View file

@ -6,11 +6,9 @@ use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use App\Traits\Models\PlanificatedStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\SitemapGenerator\Lib\SitemapHelper;
/**
@ -41,13 +39,12 @@ use Uwil\SitemapGenerator\Lib\SitemapHelper;
class News extends Model implements Sitemapable
{
use ActivityLog;
use HasFactory;
use PlanificatedStatus;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'seo_title',
@ -105,7 +102,7 @@ class News extends Model implements Sitemapable
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -172,11 +169,11 @@ class News extends Model implements Sitemapable
}
/**
* toSitemapTag method
* To sitemap tag method.
*
* @return Url|string|array
* @return \Spatie\Sitemap\Tags\Url|string|array<int|string, mixed>
*/
public function toSitemapTag(): Url | string | array
public function toSitemapTag(): \Spatie\Sitemap\Tags\Url | string | array
{
$model = $this;
$route = 'fo.news.show';

View file

@ -29,13 +29,14 @@ use App\Enums\StaticPageType;
class Section extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\SectionFactory> */
use HasFactory;
use MiniCrudModel;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'section',
@ -88,20 +89,19 @@ class Section extends Model
}
// * METHODS.
// * EMPTY BLOCS.
/**
* Empty bloc for picture.
*
* @param array $data
* @param string $img
* @param string $imgAlt
* @param string $imgTitle
* @param integer $width
* @param integer $height
* @param boolean $required
* @param string $name
* @return array
* @param array<string, mixed> $data
* @param string $img
* @param string $imgAlt
* @param string $imgTitle
* @param integer $width
* @param integer $height
* @param boolean $required
* @param string $name
* @return array<string, mixed>
*/
public static function emptyPictureBloc(
array $data,
@ -129,11 +129,11 @@ class Section extends Model
/**
* Empty bloc for link.
*
* @param array $data
* @param string $url
* @param boolean $required
* @param string $name
* @return array
* @param array<string, mixed> $data
* @param string $url
* @param boolean $required
* @param string $name
* @return array<string, mixed>
*/
public static function emptyLinkBloc(
array $data,
@ -154,9 +154,9 @@ class Section extends Model
/**
* Empty bloc for boolean new tab link.
*
* @param array $data
* @param string $name
* @return array
* @param array<string, mixed> $data
* @param string $name
* @return array<string, mixed>
*/
public static function emptyLinkNewTabBloc(
array $data,
@ -173,12 +173,11 @@ class Section extends Model
/**
* Empty bloc for key numbers.
*
* @param array $data
* @param string $name
* @param integer $value
* @param boolean $required
*
* @return array
* @param array<string, mixed> $data
* @param string $name
* @param integer $value
* @param boolean $required
* @return array<string, mixed>
*/
public static function emptyKeyNumberBloc(
array $data,
@ -199,10 +198,10 @@ class Section extends Model
/**
* Empty bloc for the button boolean.
*
* @param array $data
* @param string $name
* @param boolean $value
* @return array
* @param array<string, mixed> $data
* @param string $name
* @param boolean $value
* @return array<string, mixed>
*/
public static function emptyButtonBooleanBloc(
array $data,
@ -220,10 +219,10 @@ class Section extends Model
/**
* Empty bloc for a boolean.
*
* @param array $data
* @param string $name
* @param boolean $value
* @return array
* @param array<string, mixed> $data
* @param string $name
* @param boolean $value
* @return array<string, mixed>
*/
public static function emptyBooleanBloc(
array $data,
@ -241,11 +240,11 @@ class Section extends Model
/**
* Empty bloc for the h3 title.
*
* @param array $data
* @param string $name
* @param string $value
* @param boolean $required
* @return array
* @param array<string, mixed> $data
* @param string $name
* @param string $value
* @param boolean $required
* @return array<string, mixed>
*/
public static function emptyStringBloc(
array $data,
@ -266,12 +265,12 @@ class Section extends Model
/**
* Empty bloc for the WYSIWYG content.
*
* @param array $data
* @param array<string, mixed> $data
* @param string $name
* @param string $value
* @param \App\Enums\CkEditorConfigName $config
* @param boolean $required
* @return array
* @return array<string, mixed>
*/
public static function emptyWysiwygBloc(
array $data,
@ -292,7 +291,7 @@ class Section extends Model
}
/**
* Add part piece
* Add part piece.
*
* @return void
*/
@ -305,15 +304,22 @@ class Section extends Model
$this->countPartPieces() + 1
);
$linesToSkip = 1;
$data = collect($this->data);
/** @var array<string, mixed> $rawData */
$rawData = $this->data;
$data = collect($rawData);
$linesToSkip = 1;
$groupedPieces = $data->skip($linesToSkip)->splitIn($data->count() / ($pieceTemplateLinesCount ?: 1))
->concat([$pieceToAdd])
->sort(function ($aCollect, $bCollect) {
if ($this->section->equals(PageSectionEnum::produce_rhd)) {
/** @var array<string, mixed> $aFirst */
$aFirst = collect($aCollect)->first();
/** @var array<string, mixed> $bFirst */
$bFirst = collect($bCollect)->first();
return strcmp(
strrev(collect(collect($aCollect)->first())->first()),
strrev(collect(collect($bCollect)->first())->first())
strrev((string) collect($aFirst)->first()),
strrev((string) collect($bFirst)->first())
);
}
return 0;
@ -323,7 +329,7 @@ class Section extends Model
}
/**
* Remove part piece
* Remove part piece.
*
* @param integer $index
* @return integer Elements count removed.
@ -346,7 +352,7 @@ class Section extends Model
}
/**
* Count part pieces
* Count part pieces.
*
* @return integer
*/
@ -367,9 +373,9 @@ class Section extends Model
}
/**
* Get part pieces
* Get part pieces.
*
* @return array
* @return array<string, mixed>
*/
private function getPartPieces(): array
{
@ -378,28 +384,31 @@ class Section extends Model
}
/**
* Addable part piece block
* Addable part piece block.
*
* @param \App\Enums\Sections\PageSectionEnum $sectionEnum
* @param integer $index
* @return array
* @return array<string, mixed>|null
*/
public static function getAddablePartPieceBlock(PageSectionEnum $sectionEnum, int $index = 1): array|null
{
$data = null;
$pieceTemplate = self::getAddablePartPieceBlockTemplate($sectionEnum);
if (!is_null($pieceTemplate)) {
$data = json_decode(Str::of(json_encode($pieceTemplate))->replace('__index', strval($index)), true);
/** @var array $data */
$encoded = json_encode($pieceTemplate);
if ($encoded !== false) {
/** @var array<string, mixed> $data */
$data = json_decode(Str::of($encoded)->replace('__index', strval($index)), true);
}
}
return $data;
}
/**
* Addable part piece block
* Addable part piece block.
*
* @param \App\Enums\Sections\PageSectionEnum $sectionEnum
* @return array
* @return array<int, string>|null
*/
public static function getAddablePartPieceBlockIndexes(PageSectionEnum $sectionEnum): array|null
{
@ -411,8 +420,10 @@ class Section extends Model
}
/**
* Addable part piece block template.
*
* @param \App\Enums\Sections\PageSectionEnum $sectionEnum
* @return array|null
* @return array<string, mixed>|null
*/
private static function getAddablePartPieceBlockTemplate(PageSectionEnum $sectionEnum): array|null
{
@ -449,7 +460,7 @@ class Section extends Model
* Returns the list of sections for a page type.
*
* @param \App\Enums\StaticPageType $type
* @return \Illuminate\Database\Eloquent\Collection
* @return \Illuminate\Database\Eloquent\Collection<int, self>
*/
public static function getSections(StaticPageType $type): \Illuminate\Database\Eloquent\Collection
{
@ -460,7 +471,7 @@ class Section extends Model
}
/**
* Get the active section for a type page
* Get the active section for a type page.
*
* @param \App\Enums\StaticPageType $type
* @return boolean
@ -475,12 +486,12 @@ class Section extends Model
);
}
// * RELATIONS
// * RELATIONS.
/**
* Get the page that owns the section.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\StaticPage,$this>
*/
public function page(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
@ -490,7 +501,7 @@ class Section extends Model
/**
* Get the sections that own the carousel.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Carousel,$this>
*/
public function carousels(): \Illuminate\Database\Eloquent\Relations\HasMany
{

View file

@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\SitemapGenerator\Lib\SitemapHelper;
/**
@ -56,12 +55,13 @@ use Uwil\SitemapGenerator\Lib\SitemapHelper;
class Site extends Model implements Sitemapable
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\SiteFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'seo_title',
@ -142,7 +142,7 @@ class Site extends Model implements Sitemapable
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -202,28 +202,28 @@ class Site extends Model implements Sitemapable
ToolboxHelper::assertFieldIsUnique($table, $nameField, $valueField, $id);
}
// * RELATIONS
/**
* The logos that belong to the site.
* To sitemap tag method.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
* @return \Spatie\Sitemap\Tags\Url|string|array<int|string, mixed>
*/
public function logos(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Logo::class);
}
/**
* toSitemapTag method
*
* @return Url|string|array
*/
public function toSitemapTag(): Url | string | array
public function toSitemapTag(): \Spatie\Sitemap\Tags\Url | string | array
{
$model = $this;
$route = 'fo.sites.show';
$params = ['site' => $model];
return SitemapHelper::generateUrl($route, $params, $model);
}
// * RELATIONS.
/**
* The logos that belong to the site.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<\App\Models\Logo,$this>
*/
public function logos(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{
return $this->belongsToMany(Logo::class);
}
}

View file

@ -29,6 +29,7 @@ use Illuminate\Validation\ValidationException;
class Slide extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\SlideFactory> */
use HasFactory;
/** @var integer Minimum number of published slides */
@ -40,7 +41,7 @@ class Slide extends Model
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'type',
@ -106,7 +107,7 @@ class Slide extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.

View file

@ -6,7 +6,6 @@ use App\Enums\StaticPageType;
use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
@ -29,12 +28,11 @@ use Illuminate\Support\Str;
class StaticPage extends Model
{
use ActivityLog;
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'seo_title',
@ -73,7 +71,7 @@ class StaticPage extends Model
});
}
// * ROUTABLE
// * METHODS.
/**
* Get the value of the model's route key.
@ -99,8 +97,6 @@ class StaticPage extends Model
return 'type';
}
// * METHODS
/**
* Manage model fields.
*
@ -162,12 +158,12 @@ class StaticPage extends Model
return $query;
}
// * RELATIONS
// * RELATIONS.
/**
*
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Section,$this>
*/
public function sections(): \Illuminate\Database\Eloquent\Relations\HasMany
{

View file

@ -6,7 +6,6 @@ use App\Enums\StaticPageType;
use App\Enums\Users\RoleEnum;
use App\Traits\Models\ActivityLog;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
@ -22,12 +21,11 @@ use Illuminate\Database\Eloquent\Model;
class Sticky extends Model
{
use ActivityLog;
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'type',

View file

@ -26,13 +26,14 @@ use Illuminate\Database\Eloquent\Model;
class Strip extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\StripFactory> */
use HasFactory;
use PlanificatedStatus;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'picto',
@ -79,7 +80,7 @@ class Strip extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.
@ -95,12 +96,12 @@ class Strip extends Model
}
}
// * RELATIONS
// * RELATIONS.
/**
* Get the news that owns the strip.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\News,$this>
*/
public function news(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{

View file

@ -24,12 +24,13 @@ use Illuminate\Database\Eloquent\Model;
class Testimonial extends Model
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\TestimonialFactory> */
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'name',
@ -71,7 +72,7 @@ class Testimonial extends Model
});
}
// * METHODS
// * METHODS.
/**
* Manage model fields.

View file

@ -24,13 +24,14 @@ use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use ActivityLog;
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory;
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'first_name',
@ -45,7 +46,7 @@ class User extends Authenticatable
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
* @var list<string>
*/
protected $hidden = [
'remember_token',
@ -57,10 +58,10 @@ class User extends Authenticatable
* @var array<string, string>
*/
protected $casts = [
'role' => RoleEnum::class,
'last_connection' => 'date',
'published' => 'boolean',
'published_at' => 'datetime',
'role' => RoleEnum::class,
'last_connection' => 'date',
'published' => 'boolean',
'published_at' => 'datetime',
];
/**

View file

@ -3,6 +3,7 @@
namespace App\Traits\Controllers;
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Session;
@ -29,11 +30,11 @@ trait ChangesModelOrder
throw new \RuntimeException("The {$className} class doesn't exist.");
}
if (!\is_object($model)) {
if (!($model instanceof Model)) {
throw new \RuntimeException("The second last param isn't an object.");
}
if (get_class($model) !== (string)Str::of($className)->replaceStart('\\', '')) {
if (get_class($model) !== (string) Str::of($className)->replaceStart('\\', '')) {
throw new \RuntimeException("The {$className} doesn't match second last binded param.");
}

View file

@ -4,9 +4,12 @@ namespace App\Traits\Enums;
use Illuminate\Support\Str;
/**
* Provides rich functionality to PHP backed enums.
*/
trait BaseEnum
{
// * GENERIC METHODS
// * GENERIC METHODS.
/**
* Get enum value.
@ -38,12 +41,14 @@ trait BaseEnum
return $this->name;
}
// * STATIC FETCH METHODS
// * STATIC FETCH METHODS.
/**
* Get enum labels.
*
* @return array<string>
* @return array<string, string>
* @throws \Error If missing definition label.
* @phpstan-ignore missingType.iterableValue
*/
public static function toLabels(): array
{
@ -65,7 +70,8 @@ trait BaseEnum
/**
* Get enum values.
*
* @return array<integer|string>
* @return array<string, integer|string>
* @phpstan-ignore missingType.iterableValue
*/
public static function toValues(): array
{
@ -79,7 +85,8 @@ trait BaseEnum
/**
* Get enums.
*
* @return array
* @return list<static>
* @phpstan-ignore missingType.iterableValue
*/
public static function all(): array
{
@ -89,7 +96,8 @@ trait BaseEnum
/**
* Get enums.
*
* @return array<self>
* @return array<string, object>
* @phpstan-ignore missingType.iterableValue
*/
public static function toArray(): array
{
@ -98,7 +106,7 @@ trait BaseEnum
self::setCache('enums', \collect(self::cases())
->mapWithKeys(function ($enum) use ($definitions) {
$baseArray = [
'name' => $enum->name,
'name' => $enum->name,
'label' => $enum->label(),
'value' => $enum->value,
];
@ -109,7 +117,7 @@ trait BaseEnum
}
$baseArray[$index] = $elements[$enum->name];
}
return [$enum->name => (object)$baseArray];
return [$enum->name => (object) $baseArray];
})->all());
}
return self::getCache('enums');
@ -120,21 +128,30 @@ trait BaseEnum
*
* @param self|integer|string $value
* @param string $field
* @return self|null
* @return static|null
*/
public static function make(self|int|string $value, string $field = 'value'): self|null
{
if ($field === "label") {
$enumLabels = array_change_key_case(array_flip(self::toLabels()), CASE_LOWER);
$value = (isset($enumLabels[strtolower($value)])) ? $enumLabels[strtolower($value)] : false;
$field = 'name';
$enumLabels = array_change_key_case(
array_flip(array_map(fn($value): string => Str::slug($value), self::toLabels())),
CASE_LOWER
);
$searchValue = $value instanceof self ? (string) $value->value : (string) $value;
$slugged = Str::slug($searchValue);
$value = $enumLabels[$slugged] ?? false;
if ($value === false) {
return null;
}
$field = 'name';
}
return !\is_object($value) ?
\collect(self::cases())->keyBy($field)->get($value) : $value;
/** @phpstan-ignore-next-line */
return !\is_object($value) ? \collect(self::cases())->keyBy($field)->get($value) : $value;
}
/**
* Test if 2 enum are equals.
* Test if 2 enums are equals.
*
* @param object ...$others
* @return boolean
@ -144,12 +161,11 @@ trait BaseEnum
{
foreach ($others as $other) {
if (!\in_array(BaseEnum::class, \class_uses_recursive($other))) {
throw new \Error(__METHOD__ .
' requires $enum to use ' . BaseEnum::class);
throw new \Error(__METHOD__ . ' requires $enum to use ' . BaseEnum::class);
}
if (
get_class($this) === get_class($other)
&& $this->value === $other->value
&& $this->value === $other->value // @phpstan-ignore-line
) {
return true;
}
@ -167,14 +183,14 @@ trait BaseEnum
return $this->value;
}
// * CACHE
// * CACHE.
/**
* Get cache array.
*
* @param string $index
* @return array
* @return array<mixed>
* @phpstan-ignore missingType.iterableValue
*/
private static function getCache(string $index): array
{
@ -188,9 +204,10 @@ trait BaseEnum
/**
* Set cache array.
*
* @param string $index
* @param array $items
* @param string $index
* @param array<mixed> $items
* @return void
* @phpstan-ignore missingType.iterableValue
*/
private static function setCache(string $index, array $items): void
{
@ -220,12 +237,13 @@ trait BaseEnum
}
}
// * PRIVATE
// * PRIVATE.
/**
* Fetch the LABELS constant if exists.
*
* @return array|null
* @return array<string, string>|null
* @phpstan-ignore missingType.iterableValue
*/
private static function getLabelsConstant(): array|null
{
@ -241,21 +259,23 @@ trait BaseEnum
/**
* Get custom constants.
*
* @return array
* @return array<string, array<mixed>>
* @phpstan-ignore missingType.iterableValue
*/
private static function getCustomDefinitions(): array
{
// ? Has custom props in cache ?
if (!isset($GLOBALS[self::class]) or \is_null($GLOBALS[self::class]['customProps'])) {
$names = \collect(self::cases())->keyBy('name');
$GLOBALS[self::class]['customProps'] = \collect((new \ReflectionClass(self::class))->getConstants())
->filter(function (mixed $constant, string $key) use ($names) {
->filter(function (mixed $constant, string $key) use ($names): bool {
if ($key === 'LABELS' or !\is_array($constant)) {
return false;
}
return \collect($constant)->keys()
->filter(fn (string $name) => $names->has($name))->count();
$count = \collect($constant)->keys()
->filter(fn (string $name) => $names->has($name))
->count();
return $count > 0;
})->all();
}
return $GLOBALS[self::class]['customProps'];

View file

@ -2,8 +2,8 @@
namespace App\Traits\Models;
use App\Models\ActivityLog as ModelsActivityLog;
use App\Observers\ModelObserver;
use App\Models\ActivityLog as ActivityLogModel;
/**
* If there is a static function in a trait (named boot[TraitName]),
@ -27,10 +27,10 @@ trait ActivityLog
/**
* Activities logs One-to-many relationship.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\ActivityLog, covariant static>
*/
public function activityLogs(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ModelsActivityLog::class);
return $this->hasMany(ActivityLogModel::class, 'model_id');
}
}

View file

@ -11,7 +11,7 @@ trait MiniCrudModel
/**
* Fill the model with an array of attributes.
*
* @param array $attributes
* @param array<string, mixed> $attributes
* @return $this
*
* @throws \Illuminate\Database\Eloquent\MassAssignmentException If fill prop is not allowed.
@ -34,7 +34,7 @@ trait MiniCrudModel
*/
public function minicrudCreating(): void
{
/** @var array<string,array> */
/** @var array<int, array<string, mixed>> */
$data = $this->data;
foreach ($data as &$input) {
switch ($input['inputType']) {
@ -64,8 +64,9 @@ trait MiniCrudModel
*/
public function minicrudUpdated(): void
{
/** @var array $input */
foreach ($this->data as $index => $input) {
/** @var array<int, array<string, mixed>> $data */
$data = $this->data;
foreach ($data as $index => $input) {
switch ($input['inputType']) {
case InputType::text->value:
$original = ToolboxHelper::getOriginal($this, 'data');
@ -92,8 +93,9 @@ trait MiniCrudModel
*/
public function minicrudDeleted(): void
{
/** @var array $input */
foreach ($this->data as $index => $input) {
/** @var array<int, array<string, mixed>> $data */
$data = $this->data;
foreach ($data as $index => $input) {
switch ($input['inputType']) {
case InputType::text->value:
FileStorageHelper::removeModelFilesOfHtml($input['value']);
@ -112,7 +114,7 @@ trait MiniCrudModel
/**
* Set a specific prop.
*
* @param array $data
* @param array<string, mixed> $data
* @return void
*/
private function setData(array $data): void
@ -127,7 +129,7 @@ trait MiniCrudModel
/**
* Set a specific prop.
*
* @param array $value
* @param array<int|string, mixed> $value
* @return void
*/
protected function setDataAttribute(array $value): void
@ -142,7 +144,7 @@ trait MiniCrudModel
* Set a specific prop.
*
* @param string|null $data
* @return array
* @return array<int|string, mixed>
*/
protected function getDataAttribute(string|null $data): array
{
@ -152,8 +154,8 @@ trait MiniCrudModel
/**
* Serialize properties.
*
* @param array $data
* @return array
* @param array<int|string, array<string, mixed>> $data
* @return array<int|string, array<string, mixed>>
* @throws \ErrorException If input type is no handled.
* @throws \Illuminate\Validation\ValidationException If url is a bo url.
* @phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber

View file

@ -49,7 +49,7 @@ trait HasPicture
* @param integer|null $size
* @param string|null $requiredWith
* @param string|null $requiredWithout
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function pictureRules(
string $name = 'picture',
@ -62,10 +62,10 @@ trait HasPicture
?string $requiredWith = null,
?string $requiredWithout = null,
): array {
$dimensions = (object)[
'minWidth' => $minWidth ?? $this->minWidth,
$dimensions = [
'minWidth' => $minWidth ?? $this->minWidth,
'minHeight' => $minHeight ?? $this->minHeight,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxHeight' => $maxHeight ?? $this->maxHeight
];
return [
@ -92,7 +92,7 @@ trait HasPicture
* @param integer $limitMin
* @param integer $limitMax
* @param boolean $nullable
* @return array
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function picturesRules(
string $name = 'pictures',
@ -104,10 +104,10 @@ trait HasPicture
int $limitMax = 5,
bool $nullable = false
): array {
$sizes = (object)[
'minWidth' => $minWidth ?? $this->minWidth,
$sizes = [
'minWidth' => $minWidth ?? $this->minWidth,
'minHeight' => $minHeight ?? $this->minHeight,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxHeight' => $maxHeight ?? $this->maxHeight,
];
return [

1
commitlint.config.cjs Normal file
View file

@ -0,0 +1 @@
module.exports = require('@uwil/husky-config/commitlint.config.cjs');

View file

@ -13,7 +13,6 @@
"license": "MIT",
"require": {
"php": "^8.5",
"24slides/laravel-saml2": "^2.4",
"axlon/laravel-postal-code-validation": "^3.5",
"diglactic/laravel-breadcrumbs": "^9.0",
"guzzlehttp/guzzle": "^7.2",
@ -38,6 +37,7 @@
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^10.0",
"scaler-tech/laravel-saml2": "^2.7",
"slevomat/coding-standard": "^8.10",
"spatie/laravel-ignition": "^2.0",
"thedoctor0/laravel-factory-generator": "^1.2"

602
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -41,7 +41,7 @@ return [
|
*/
'debug' => (bool)env('APP_DEBUG', false),
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------

View file

@ -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' => [\App\Lib\Helpers\ExceptionsHelper::class, 'sentryEventHandler'],
];

731
package-lock.json generated
View file

@ -21,6 +21,7 @@
"@types/toastify-js": "^1.12.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.36.2",
"@uwil/husky-config": "^1.0.1",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-vue": "^4.6.2",
"@vue/compiler-sfc": "latest",
@ -382,6 +383,407 @@
"node": ">=6.9.0"
}
},
"node_modules/@commitlint/cli": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-20.5.0.tgz",
"integrity": "sha512-yNkyN/tuKTJS3wdVfsZ2tXDM4G4Gi7z+jW54Cki8N8tZqwKBltbIvUUrSbT4hz1bhW/h0CdR+5sCSpXD+wMKaQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/format": "^20.5.0",
"@commitlint/lint": "^20.5.0",
"@commitlint/load": "^20.5.0",
"@commitlint/read": "^20.5.0",
"@commitlint/types": "^20.5.0",
"tinyexec": "^1.0.0",
"yargs": "^17.0.0"
},
"bin": {
"commitlint": "cli.js"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/config-conventional": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/config-conventional/-/config-conventional-20.5.0.tgz",
"integrity": "sha512-t3Ni88rFw1XMa4nZHgOKJ8fIAT9M2j5TnKyTqJzsxea7FUetlNdYFus9dz+MhIRZmc16P0PPyEfh6X2d/qw8SA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"conventional-changelog-conventionalcommits": "^9.2.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/config-validator": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/config-validator/-/config-validator-20.5.0.tgz",
"integrity": "sha512-T/Uh6iJUzyx7j35GmHWdIiGRQB+ouZDk0pwAaYq4SXgB54KZhFdJ0vYmxiW6AMYICTIWuyMxDBl1jK74oFp/Gw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"ajv": "^8.11.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/config-validator/node_modules/ajv": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz",
"integrity": "sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==",
"dev": true,
"license": "MIT",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"node_modules/@commitlint/config-validator/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
"dev": true,
"license": "MIT"
},
"node_modules/@commitlint/ensure": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/ensure/-/ensure-20.5.0.tgz",
"integrity": "sha512-IpHqAUesBeW1EDDdjzJeaOxU9tnogLAyXLRBn03SHlj1SGENn2JGZqSWGkFvBJkJzfXAuCNtsoYzax+ZPS+puw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"lodash.camelcase": "^4.3.0",
"lodash.kebabcase": "^4.1.1",
"lodash.snakecase": "^4.1.1",
"lodash.startcase": "^4.4.0",
"lodash.upperfirst": "^4.3.1"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/execute-rule": {
"version": "20.0.0",
"resolved": "https://registry.npmjs.org/@commitlint/execute-rule/-/execute-rule-20.0.0.tgz",
"integrity": "sha512-xyCoOShoPuPL44gVa+5EdZsBVao/pNzpQhkzq3RdtlFdKZtjWcLlUFQHSWBuhk5utKYykeJPSz2i8ABHQA+ZZw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/format": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/format/-/format-20.5.0.tgz",
"integrity": "sha512-TI9EwFU/qZWSK7a5qyXMpKPPv3qta7FO4tKW+Wt2al7sgMbLWTsAcDpX1cU8k16TRdsiiet9aOw0zpvRXNJu7Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/is-ignored": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/is-ignored/-/is-ignored-20.5.0.tgz",
"integrity": "sha512-JWLarAsurHJhPozbuAH6GbP4p/hdOCoqS9zJMfqwswne+/GPs5V0+rrsfOkP68Y8PSLphwtFXV0EzJ+GTXTTGg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"semver": "^7.6.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/is-ignored/node_modules/semver": {
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@commitlint/lint": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/lint/-/lint-20.5.0.tgz",
"integrity": "sha512-jiM3hNUdu04jFBf1VgPdjtIPvbuVfDTBAc6L98AWcoLjF5sYqkulBHBzlVWll4rMF1T5zeQFB6r//a+s+BBKlA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/is-ignored": "^20.5.0",
"@commitlint/parse": "^20.5.0",
"@commitlint/rules": "^20.5.0",
"@commitlint/types": "^20.5.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/load": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/load/-/load-20.5.0.tgz",
"integrity": "sha512-sLhhYTL/KxeOTZjjabKDhwidGZan84XKK1+XFkwDYL/4883kIajcz/dZFAhBJmZPtL8+nBx6bnkzA95YxPeDPw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/config-validator": "^20.5.0",
"@commitlint/execute-rule": "^20.0.0",
"@commitlint/resolve-extends": "^20.5.0",
"@commitlint/types": "^20.5.0",
"cosmiconfig": "^9.0.1",
"cosmiconfig-typescript-loader": "^6.1.0",
"is-plain-obj": "^4.1.0",
"lodash.mergewith": "^4.6.2",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/load/node_modules/cosmiconfig": {
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.1.tgz",
"integrity": "sha512-hr4ihw+DBqcvrsEDioRO31Z17x71pUYoNe/4h6Z0wB72p7MU7/9gH8Q3s12NFhHPfYBBOV3qyfUxmr/Yn3shnQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"env-paths": "^2.2.1",
"import-fresh": "^3.3.0",
"js-yaml": "^4.1.0",
"parse-json": "^5.2.0"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/sponsors/d-fischer"
},
"peerDependencies": {
"typescript": ">=4.9.5"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@commitlint/load/node_modules/cosmiconfig-typescript-loader": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/cosmiconfig-typescript-loader/-/cosmiconfig-typescript-loader-6.3.0.tgz",
"integrity": "sha512-Akr82WH1Wfqatyiqpj8HDkO2o2KmJRu1FhKfSNJP3K4IdXwHfEyL7MOb62i1AGQVLtIQM+iCE9CGOtrfhR+mmA==",
"dev": true,
"license": "MIT",
"dependencies": {
"jiti": "2.6.1"
},
"engines": {
"node": ">=v18"
},
"peerDependencies": {
"@types/node": "*",
"cosmiconfig": ">=9",
"typescript": ">=5"
}
},
"node_modules/@commitlint/load/node_modules/is-plain-obj": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz",
"integrity": "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@commitlint/message": {
"version": "20.4.3",
"resolved": "https://registry.npmjs.org/@commitlint/message/-/message-20.4.3.tgz",
"integrity": "sha512-6akwCYrzcrFcTYz9GyUaWlhisY4lmQ3KvrnabmhoeAV8nRH4dXJAh4+EUQ3uArtxxKQkvxJS78hNX2EU3USgxQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/parse": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/parse/-/parse-20.5.0.tgz",
"integrity": "sha512-SeKWHBMk7YOTnnEWUhx+d1a9vHsjjuo6Uo1xRfPNfeY4bdYFasCH1dDpAv13Lyn+dDPOels+jP6D2GRZqzc5fA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/types": "^20.5.0",
"conventional-changelog-angular": "^8.2.0",
"conventional-commits-parser": "^6.3.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/read": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/read/-/read-20.5.0.tgz",
"integrity": "sha512-JDEIJ2+GnWpK8QqwfmW7O42h0aycJEWNqcdkJnyzLD11nf9dW2dWLTVEa8Wtlo4IZFGLPATjR5neA5QlOvIH1w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/top-level": "^20.4.3",
"@commitlint/types": "^20.5.0",
"git-raw-commits": "^5.0.0",
"minimist": "^1.2.8",
"tinyexec": "^1.0.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/resolve-extends": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/resolve-extends/-/resolve-extends-20.5.0.tgz",
"integrity": "sha512-3SHPWUW2v0tyspCTcfSsYml0gses92l6TlogwzvM2cbxDgmhSRc+fldDjvGkCXJrjSM87BBaWYTPWwwyASZRrg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/config-validator": "^20.5.0",
"@commitlint/types": "^20.5.0",
"global-directory": "^4.0.1",
"import-meta-resolve": "^4.0.0",
"lodash.mergewith": "^4.6.2",
"resolve-from": "^5.0.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/resolve-extends/node_modules/resolve-from": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
"integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/@commitlint/rules": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/rules/-/rules-20.5.0.tgz",
"integrity": "sha512-5NdQXQEdnDPT5pK8O39ZA7HohzPRHEsDGU23cyVCNPQy4WegAbAwrQk3nIu7p2sl3dutPk8RZd91yKTrMTnRkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@commitlint/ensure": "^20.5.0",
"@commitlint/message": "^20.4.3",
"@commitlint/to-lines": "^20.0.0",
"@commitlint/types": "^20.5.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/to-lines": {
"version": "20.0.0",
"resolved": "https://registry.npmjs.org/@commitlint/to-lines/-/to-lines-20.0.0.tgz",
"integrity": "sha512-2l9gmwiCRqZNWgV+pX1X7z4yP0b3ex/86UmUFgoRt672Ez6cAM2lOQeHFRUTuE6sPpi8XBCGnd8Kh3bMoyHwJw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/top-level": {
"version": "20.4.3",
"resolved": "https://registry.npmjs.org/@commitlint/top-level/-/top-level-20.4.3.tgz",
"integrity": "sha512-qD9xfP6dFg5jQ3NMrOhG0/w5y3bBUsVGyJvXxdWEwBm8hyx4WOk3kKXw28T5czBYvyeCVJgJJ6aoJZUWDpaacQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"escalade": "^3.2.0"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@commitlint/types": {
"version": "20.5.0",
"resolved": "https://registry.npmjs.org/@commitlint/types/-/types-20.5.0.tgz",
"integrity": "sha512-ZJoS8oSq2CAZEpc/YI9SulLrdiIyXeHb/OGqGrkUP6Q7YV+0ouNAa7GjqRdXeQPncHQIDz/jbCTlHScvYvO/gA==",
"dev": true,
"license": "MIT",
"dependencies": {
"conventional-commits-parser": "^6.3.0",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=v18"
}
},
"node_modules/@conventional-changelog/git-client": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/@conventional-changelog/git-client/-/git-client-2.7.0.tgz",
"integrity": "sha512-j7A8/LBEQ+3rugMzPXoKYzyUPpw/0CBQCyvtTR7Lmu4olG4yRC/Tfkq79Mr3yuPs0SUitlO2HwGP3gitMJnRFw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@simple-libs/child-process-utils": "^1.0.0",
"@simple-libs/stream-utils": "^1.2.0",
"semver": "^7.5.2"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"conventional-commits-filter": "^5.0.0",
"conventional-commits-parser": "^6.4.0"
},
"peerDependenciesMeta": {
"conventional-commits-filter": {
"optional": true
},
"conventional-commits-parser": {
"optional": true
}
}
},
"node_modules/@conventional-changelog/git-client/node_modules/semver": {
"version": "7.7.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
"integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
"dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/@csstools/css-parser-algorithms": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-2.5.0.tgz",
@ -1168,6 +1570,35 @@
"node": ">= 8.0.0"
}
},
"node_modules/@simple-libs/child-process-utils": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@simple-libs/child-process-utils/-/child-process-utils-1.0.2.tgz",
"integrity": "sha512-/4R8QKnd/8agJynkNdJmNw2MBxuFTRcNFnE5Sg/G+jkSsV8/UBgULMzhizWWW42p8L5H7flImV2ATi79Ove2Tw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@simple-libs/stream-utils": "^1.2.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://ko-fi.com/dangreen"
}
},
"node_modules/@simple-libs/stream-utils": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@simple-libs/stream-utils/-/stream-utils-1.2.0.tgz",
"integrity": "sha512-KxXvfapcixpz6rVEB6HPjOUZT22yN6v0vI0urQSk1L8MlEWPDFCZkhw2xmkyoTGYeFw7tWTZd7e3lVzRZRN/EA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://ko-fi.com/dangreen"
}
},
"node_modules/@sipec/vue3-tags-input": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@sipec/vue3-tags-input/-/vue3-tags-input-3.0.4.tgz",
@ -1618,6 +2049,21 @@
"integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==",
"dev": true
},
"node_modules/@uwil/husky-config": {
"version": "1.0.1",
"resolved": "https://lab.s-web.fr/api/v4/projects/259/packages/npm/@uwil/husky-config/-/@uwil/husky-config-1.0.1.tgz",
"integrity": "sha1-VGchal1LcEFXNFsQZxh5pn4495Q=",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"@commitlint/cli": "^20.5.0",
"@commitlint/config-conventional": "^20.5.0",
"husky": "^9.1.7"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/@vitejs/plugin-basic-ssl": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.1.0.tgz",
@ -2434,6 +2880,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/array-ify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz",
"integrity": "sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==",
"dev": true,
"license": "MIT"
},
"node_modules/array-includes": {
"version": "3.1.7",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.7.tgz",
@ -2947,9 +3400,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001587",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz",
"integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==",
"version": "1.0.30001790",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001790.tgz",
"integrity": "sha512-bOoxfJPyYo+ds6W0YfptaCWbFnJYjh2Y1Eow5lRv+vI2u8ganPZqNm1JwNh0t2ELQCqIWg4B3dWEusgAmsoyOw==",
"dev": true,
"funding": [
{
@ -2964,7 +3417,8 @@
"type": "github",
"url": "https://github.com/sponsors/ai"
}
]
],
"license": "CC-BY-4.0"
},
"node_modules/chalk": {
"version": "2.4.2",
@ -3111,12 +3565,79 @@
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true
},
"node_modules/compare-func": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz",
"integrity": "sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==",
"dev": true,
"license": "MIT",
"dependencies": {
"array-ify": "^1.0.0",
"dot-prop": "^5.1.0"
}
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true
},
"node_modules/conventional-changelog-angular": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-8.3.1.tgz",
"integrity": "sha512-6gfI3otXK5Ph5DfCOI1dblr+kN3FAm5a97hYoQkqNZxOaYa5WKfXH+AnpsmS+iUH2mgVC2Cg2Qw9m5OKcmNrIg==",
"dev": true,
"license": "ISC",
"dependencies": {
"compare-func": "^2.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/conventional-changelog-conventionalcommits": {
"version": "9.3.1",
"resolved": "https://registry.npmjs.org/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-9.3.1.tgz",
"integrity": "sha512-dTYtpIacRpcZgrvBYvBfArMmK2xvIpv2TaxM0/ZI5CBtNUzvF2x0t15HsbRABWprS6UPmvj+PzHVjSx4qAVKyw==",
"dev": true,
"license": "ISC",
"dependencies": {
"compare-func": "^2.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/conventional-commits-parser": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-6.4.0.tgz",
"integrity": "sha512-tvRg7FIBNlyPzjdG8wWRlPHQJJHI7DylhtRGeU9Lq+JuoPh5BKpPRX83ZdLrvXuOSu5Eo/e7SzOQhU4Hd2Miuw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@simple-libs/stream-utils": "^1.2.0",
"meow": "^13.0.0"
},
"bin": {
"conventional-commits-parser": "dist/cli/index.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/conventional-commits-parser/node_modules/meow": {
"version": "13.2.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz",
"integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
@ -3368,6 +3889,19 @@
"node": ">=6.0.0"
}
},
"node_modules/dot-prop": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz",
"integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-obj": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/electron-to-chromium": {
"version": "1.4.665",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.665.tgz",
@ -3600,10 +4134,11 @@
}
},
"node_modules/escalade": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
"integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
@ -4210,6 +4745,23 @@
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==",
"dev": true
},
"node_modules/fast-uri": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
"integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/fastify"
},
{
"type": "opencollective",
"url": "https://opencollective.com/fastify"
}
],
"license": "BSD-3-Clause"
},
"node_modules/fastest-levenshtein": {
"version": "1.0.16",
"resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
@ -4553,6 +5105,36 @@
"node": ">= 10.0.0"
}
},
"node_modules/git-raw-commits": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-5.0.1.tgz",
"integrity": "sha512-Y+csSm2GD/PCSh6Isd/WiMjNAydu0VBiG9J7EdQsNA5P9uXvLayqjmTsNlK5Gs9IhblFZqOU0yid5Il5JPoLiQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@conventional-changelog/git-client": "^2.6.0",
"meow": "^13.0.0"
},
"bin": {
"git-raw-commits": "src/cli.js"
},
"engines": {
"node": ">=18"
}
},
"node_modules/git-raw-commits/node_modules/meow": {
"version": "13.2.0",
"resolved": "https://registry.npmjs.org/meow/-/meow-13.2.0.tgz",
"integrity": "sha512-pxQJQzB6djGPXh08dacEloMFopsOqGVRKFPYvPOt9XDZ1HasbgDZA74CJGreSU4G3Ak7EFJGoiH2auq+yXISgA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
@ -4591,6 +5173,32 @@
"integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==",
"dev": true
},
"node_modules/global-directory": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/global-directory/-/global-directory-4.0.1.tgz",
"integrity": "sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ini": "4.1.1"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/global-directory/node_modules/ini": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ini/-/ini-4.1.1.tgz",
"integrity": "sha512-QQnnxNyfvmHFIsj7gkPcYymR8Jdw/o7mp5ZFihxn6h8Ci6fh3Dx4E1gPjpQEpIuPo9XVNY/ZUwh4BPMjGyL01g==",
"dev": true,
"license": "ISC",
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
}
},
"node_modules/global-modules": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz",
@ -4883,6 +5491,22 @@
"node": ">= 14"
}
},
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
"integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
"dev": true,
"license": "MIT",
"bin": {
"husky": "bin.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
@ -4943,6 +5567,17 @@
"node": ">=8"
}
},
"node_modules/import-meta-resolve": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-4.2.0.tgz",
"integrity": "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg==",
"dev": true,
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/imurmurhash": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
@ -5186,6 +5821,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-obj": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz",
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
@ -5358,6 +6003,16 @@
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/jiti": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz",
"integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==",
"dev": true,
"license": "MIT",
"bin": {
"jiti": "lib/jiti-cli.mjs"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@ -5555,18 +6210,60 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.kebabcase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz",
"integrity": "sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
"node_modules/lodash.mergewith": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz",
"integrity": "sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.snakecase": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.startcase": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz",
"integrity": "sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==",
"dev": true,
"license": "MIT"
},
"node_modules/lodash.truncate": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz",
"integrity": "sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==",
"dev": true
},
"node_modules/lodash.upperfirst": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
"integrity": "sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==",
"dev": true,
"license": "MIT"
},
"node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
@ -5732,7 +6429,6 @@
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"peer": true,
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@ -6189,10 +6885,11 @@
"dev": true
},
"node_modules/picocolors": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
"dev": true
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"dev": true,
"license": "ISC"
},
"node_modules/picomatch": {
"version": "2.3.1",
@ -8111,6 +8808,16 @@
"integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==",
"dev": true
},
"node_modules/tinyexec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.1.tgz",
"integrity": "sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",

View file

@ -29,6 +29,7 @@
"@types/toastify-js": "^1.12.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.36.2",
"@uwil/husky-config": "^1.0.1",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-vue": "^4.6.2",
"@vue/compiler-sfc": "latest",

View file

@ -21,26 +21,28 @@
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Commenting.DocComment.SpacingBeforeTags"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.Commenting.Fixme"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref="Generic.Files.LineEndings"/>
<rule ref="Generic.Files.LineLength"/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.MultipleStatementAlignment"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
<rule ref="Generic.Metrics.CyclomaticComplexity"/>
<rule ref="Generic.Metrics.NestingLevel"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.NamingConventions.CamelCapsFunctionName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.PHP.NoSilencedErrors"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
<rule ref="PEAR.Classes.ClassDeclaration"/>
<rule ref="PEAR.Commenting.InlineComment"/>
@ -103,10 +105,14 @@
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<rule ref="Squiz.Commenting.FunctionComment">
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment" />
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint" />
</rule>
<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>
<rule ref="Squiz.Commenting.InlineComment">
<exclude name="Squiz.Commenting.InlineComment.DocBlock" />
<exclude name="Squiz.Commenting.InlineComment.NotCapital" />
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.InlineComment.NoSpaceBefore" />
</rule>
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<exclude name="Squiz.Commenting.LongConditionClosingComment.SpacingBefore" />
@ -119,5 +125,4 @@
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*/database/migrations/*</exclude-pattern>
</rule>
</ruleset>

View file

@ -6,5 +6,4 @@ parameters:
paths:
- app/
# Level 9 is the highest level
level: 5
level: 7

View file

@ -14,8 +14,77 @@
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Redirect /index.php/anything to /anything
RewriteCond %{THE_REQUEST} /index\.php/([^\s?]*) [NC]
RewriteRule ^index\.php/(.*)$ /$1 [L,R=301,NC]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# CSS / JS
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
# WOFF / WOFF2 / Fonts
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
# Favicon
ExpiresByType image/x-icon "access plus 1 year"
</IfModule>
<FilesMatch "\.(jpe?g|png|gif|webp|css|js|woff|woff2|ico)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS text/html text/css text/plain text/xml text/javascript application/javascript application/x-javascript
AddType text/plain .br
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
<IfModule mod_mime.c>
AddType application/javascript .js
AddType font/woff2 .woff2
AddType application/font-woff2 .woff2
AddType application/font-woff .woff
AddType font/woff .woff
AddType image/svg+xml .svg
</IfModule>
<FilesMatch "\.(css|js|jpg|jpeg|gif|png|ico|svg|woff|woff2)$">
FileETag None
Header unset ETag
Header unset Set-Cookie
</FilesMatch>

View file

@ -206,10 +206,6 @@ export default defineComponent({
// @ts-ignore
this.oms.addMarker(marker);
site.marker = marker;
marker.on("dblclick", () => {
window.location.href = `/sites/${site.slug}`;
});
});
},
updateMarkers() {