fix: ♿ add more details in some php prototypes

This commit is contained in:
Alexis Gousseau 2024-10-04 17:03:04 +02:00
parent 22139c17f7
commit 6ef6a8254d
79 changed files with 280 additions and 362 deletions

View file

@ -16,7 +16,7 @@ class Kernel extends ConsoleKernel
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
$schedule->job(FetchDigitalRecruiterOffers::class)->daily();
$schedule->job(DeleteOldMessages::class)->dailyAt('14:15');
@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__ . '/Commands');

View file

@ -25,7 +25,6 @@ enum ActivityLogsEventEnum: int
self::deleted->name => 'Suppression',
];
/**
* Custom added classes definition
*/

View file

@ -25,7 +25,7 @@ enum BreedingTypeEnum: int
self::breedingHealth->name => 'La santé des volailles',
];
/**
/**
* Get all breeding pages.
*
* @return array

View file

@ -185,7 +185,10 @@ class ProductController extends Controller
public function update(UpdateProductRequest $request, Product $product): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request, $product) {
$product->fill(Arr::except($request->validated(), ['labels', 'productTypes', 'claims', 'nutritionnal_values']));
$product->fill(Arr::except(
$request->validated(),
['labels', 'productTypes', 'claims', 'nutritionnal_values']
));
$product->labels()->sync(collect($request->validated()['labels'] ?? [])->pluck('id'));
$product->productTypes()->sync(collect($request->validated()['productTypes'] ?? [])->pluck('id'));
$product->claims()->sync(collect($request->validated()['claims'] ?? [])->pluck('id'));

View file

@ -242,10 +242,12 @@ class SurveysAnswerController extends Controller
return back()->with('error', trans('crud.messages.order_not_changed'));
}
return DB::transaction(function () use ($request, $className, $model) {
/** @var \App\Models\NewsClub $newsClubModel */
$newsClubModel = request()->route()->parameter('news_club');
/** @var \Illuminate\Database\Eloquent\Model|null */
$tmp = $className::query()
->when(request()->route()->parameter('news_club'), function (Builder $q) {
$q->where('news_club_id', request()->route()->parameter('news_club')->getKey());
->when($newsClubModel, function (Builder $q) use ($newsClubModel) {
$q->where('news_club_id', $newsClubModel->getKey());
})
->where('order', $request->direction ? '<' : '>', $model->getOriginal('order'))
->orderBy('order', $request->direction ? 'DESC' : 'ASC')

View file

@ -104,7 +104,7 @@ class VerificationController extends Controller
}
/**
* Get the post register / login redirect path.
* Get the post register/login redirect path.
*
* @return string
*/
@ -114,7 +114,7 @@ class VerificationController extends Controller
}
/**
* Set Crm Customer active
* Set crm customer active.
*
* @param \App\Models\Customer $customer
* @return void

View file

@ -26,10 +26,7 @@ class BreederController extends Controller
return File::json(base_path('/public/departments.geojson'));
}
);
return response()->json(
[$departmentGeoJson]
);
return response()->json([$departmentGeoJson]);
}
/**
@ -39,7 +36,7 @@ class BreederController extends Controller
*/
public function getBreederCountPerDepartment(): \Illuminate\Http\JsonResponse
{
// TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur
// TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur.
$breederCountPerDepartment = Cache::rememberForever(
'breederCountPerDepartment',
function () {
@ -50,10 +47,7 @@ class BreederController extends Controller
->get()->toArray();
}
);
return response()->json(
$breederCountPerDepartment
);
return response()->json($breederCountPerDepartment);
}
/**
@ -65,7 +59,7 @@ class BreederController extends Controller
public function getDepartmentBreeders(Request $request): \Illuminate\Http\JsonResponse
{
// TODO: checker si le departement existe.
// TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur
// TODO: mettre à jour le cache lors de l'édition/ajout/suppression d'un éleveur.
$breeders = Cache::rememberForever(
sprintf('departmentBreeders%s', $request->DEPARTMENT),
function () use ($request) {
@ -76,10 +70,7 @@ class BreederController extends Controller
->get()->toArray();
}
);
return response()->json(
$breeders
);
return response()->json($breeders);
}
/**

View file

@ -9,7 +9,6 @@ class ExportController extends Controller
/**
* Contact page.
*
* @param \App\Models\StaticPage $staticPageModel
* @return \Illuminate\Contracts\View\View
*/
public function nl(): \Illuminate\Contracts\View\View

View file

@ -18,7 +18,7 @@ class Authenticate extends Middleware
{
$logins = [
'backend' => route('bo.login'),
'club' => route('club.login')
'club' => route('club.login')
];
if (!$request->expectsJson()) {
// * Notify must login
@ -34,7 +34,6 @@ class Authenticate extends Middleware
}
return route('login');
}
return null;
}
}

View file

@ -4,7 +4,6 @@ namespace App\Http\Middleware;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class HtmlSanitizer
{
@ -16,8 +15,11 @@ class HtmlSanitizer
* @param string|array ...$params
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, \Closure $next, string|array ...$params): Response
{
public function handle(
Request $request,
\Closure $next,
string|array ...$params
): \Symfony\Component\HttpFoundation\Response {
$inputs = $request->all();
/** @var callable|null */
$cleanInput = null;

View file

@ -3,25 +3,26 @@
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
* @param string|null ...$guards
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
* @param string|null ...$guards
* @return \Symfony\Component\HttpFoundation\Response
* @throws \RuntimeException If guard is unhandled.
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
*/
public function handle(Request $request, \Closure $next, ...$guards): Response
{
public function handle(
Request $request,
\Closure $next,
string|null ...$guards
): \Symfony\Component\HttpFoundation\Response {
// phpcs:enable phpcs:disable
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (auth($guard)->check()) {
switch ($guard) {
@ -37,7 +38,6 @@ class RedirectIfAuthenticated
}
}
}
return $next($request);
}
}

View file

@ -2,12 +2,10 @@
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Vite;
use Symfony\Component\HttpFoundation\Response;
class SecureHeaders
{
@ -26,14 +24,12 @@ class SecureHeaders
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
*/
public function handle(Request $request, Closure $next): Response
public function handle(Request $request, \Closure $next): \Symfony\Component\HttpFoundation\Response
{
// phpcs:enable
// * For Vite DEV
$host = \parse_url(\config('app.url'), \PHP_URL_HOST);
View::share('nonce', $nonce = Vite::useCspNonce());
@ -105,7 +101,6 @@ class SecureHeaders
config('app.debug') ? "https://{$host}:4443" : '',
]) . ';'
];
$response->headers->set(
'Content-Security-Policy',
implode(' ', $cspPolicies) . $reportUri
@ -115,7 +110,7 @@ class SecureHeaders
}
/**
* Remove unwanted headers
* Remove unwanted headers.
*
* @param array $headerList
* @return void

View file

@ -49,7 +49,7 @@ abstract class CustomerCollectionRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'state' => [

View file

@ -12,7 +12,7 @@ class SaveCustomerCollectionRequest extends CustomerCollectionRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
$idEnumRule = '';
return array_merge(

View file

@ -23,7 +23,7 @@ class SearchCustomerCollectionRequest extends CustomerCollectionRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return array_merge(
parent::rules(),

View file

@ -23,7 +23,7 @@ class StoreCustomerRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return Auth::guard('club')->check();
}
@ -33,7 +33,7 @@ class StoreCustomerRequest extends FormRequest
*
* @return void
*/
public function prepareForValidation()
public function prepareForValidation(): void
{
try {
$this->currentCountry = Country::make(\intval($this->country));
@ -52,7 +52,7 @@ class StoreCustomerRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
$countryList = implode(',', Country::getValidIsoAplha2Codes());
return [
@ -97,7 +97,7 @@ class StoreCustomerRequest extends FormRequest
*
* @return array
*/
public function attributes()
public function attributes(): array
{
return [
'lastname' => trans('validation.attributes.first_name'),

View file

@ -23,7 +23,7 @@ class UpdateCustomerRequest extends StoreCustomerRequest
*
* @return void
*/
public function prepareForValidation()
public function prepareForValidation(): void
{
parent::prepareForValidation();
$this->merge([

View file

@ -13,7 +13,7 @@ class UpdatePasswordRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return auth('club')->check();
}
@ -23,7 +23,7 @@ class UpdatePasswordRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
/** @var \LDC\LDCCRM\Models\Customer $crmCustomer */
$crmCustomer = \auth('club')->user()->api_data;
@ -44,7 +44,7 @@ class UpdatePasswordRequest extends FormRequest
*
* @return array
*/
public function attributes()
public function attributes(): array
{
return [
'old_password' => trans('validation.custom.old_password'),

View file

@ -12,7 +12,7 @@ class BlockCustomerRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return Auth::guard('club')->check();
}
@ -22,7 +22,7 @@ class BlockCustomerRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'username' => 'required|exists:customers,username'

View file

@ -14,7 +14,7 @@ class DeleteMessagesRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return Auth::guard('club')->check();
}
@ -24,7 +24,7 @@ class DeleteMessagesRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'message' => [

View file

@ -16,7 +16,7 @@ class SendMessageRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return Auth::guard('club')->check();
}
@ -26,7 +26,7 @@ class SendMessageRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'message' => 'required|string|max:255|min:5',

View file

@ -13,7 +13,7 @@ class StoreSurveyAnswerRequest extends FormRequest
*
* @return boolean
*/
public function authorize()
public function authorize(): bool
{
return Auth::guard('club')->check();
}
@ -38,7 +38,7 @@ class StoreSurveyAnswerRequest extends FormRequest
*
* @return array
*/
public function rules()
public function rules(): array
{
return [
'news_club_id' => 'required|integer|exists:news_clubs,id',
@ -64,7 +64,7 @@ class StoreSurveyAnswerRequest extends FormRequest
*
* @return array
*/
public function attributes()
public function attributes(): array
{
return [
'news_club_id' => trans_choice('models.classes.news_club', 1),

View file

@ -37,7 +37,6 @@ class FetchDigitalRecruiterOffers
config('services.digital_recruiter.url')
));
}
$this->parseDigitalRecruiterOffers(\collect($response->object()->ads));
}

View file

@ -15,13 +15,13 @@ use App\Lib\Link;
class MenuNode extends \stdClass
{
/**
* Get property
* Get property.
*
* @param string $name
* @return mixed
* @throws \TypeError If prop is undefined.
*/
public function __get(string $name)
public function __get(string $name): mixed
{
if (in_array($name, ['type', 'title', 'link', 'published'])) {
return $this->{$name};
@ -62,7 +62,7 @@ class MenuNode extends \stdClass
* @return void
* @throws \RuntimeException If $type is wrong.
*/
public static function assertTypeIsCorrect(int $type)
public static function assertTypeIsCorrect(int $type): void
{
try {
$type = MenuNodeType::make($type);

View file

@ -10,13 +10,13 @@ use Illuminate\Support\Collection;
class CollectionHelper
{
/**
* Paginate a collection
* Paginate a collection.
*
* @param \Illuminate\Support\Collection $results
* @param integer $pageSize
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator
public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator
{
$page = Paginator::resolveCurrentPage('page');
@ -24,15 +24,18 @@ class CollectionHelper
}
/**
* Paginate a collection
* Paginate a collection.
*
* @param \Illuminate\Support\Collection $results
* @param integer $pageSize
* @param integer $page
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator
{
public static function paginateManually(
Collection $results,
int $pageSize,
int $page = 1
): \Illuminate\Pagination\LengthAwarePaginator {
$total = $results->count();
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
@ -51,14 +54,19 @@ class CollectionHelper
* @param array $options
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
{
protected static function paginator(
Collection $items,
int $total,
int $perPage,
int $currentPage,
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[]
@ -103,9 +103,8 @@ class ExceptionsHelper
return $params;
}
/**
* Anonymize at least Sql queries
* Anonymize at least Sql queries.
*
* @param string $message
* @return string
@ -120,7 +119,7 @@ class ExceptionsHelper
}
/**
* Anonymize stack trace
* Anonymize stack trace.
*
* @param \Throwable $e
* @return string
@ -159,7 +158,7 @@ class ExceptionsHelper
}
/**
* Handle Args
* Handle Args.
*
* @param array $stack
* @return string

View file

@ -22,7 +22,7 @@ use Symfony\Component\Finder\SplFileInfo;
class ToolboxHelper
{
/**
* Censor string
* Censor string.
*
* @param string $string
* @return string
@ -38,8 +38,9 @@ class ToolboxHelper
}
return $censor->censorString($string, true)['clean'];
}
/**
* Run a terminal command and gives the output
* 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.
@ -53,7 +54,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();
@ -69,6 +70,8 @@ class ToolboxHelper
}
/**
* Return array merge recursive distinct.
*
* @param array<int|string, mixed> $array1
* @param array<int|string, mixed> $array2
*
@ -89,13 +92,13 @@ class ToolboxHelper
}
/**
* Validate recaptcha
* Validate recaptcha.
*
* @param \Illuminate\Http\Request $request
* @param boolean $isV3
* @return void
*/
public static function validateRecaptcha(Request $request, bool $isV3 = true)
public static function validateRecaptcha(Request $request, bool $isV3 = true): void
{
Validator::validate($request->all(), [
'g-recaptcha-response' => [
@ -147,7 +150,7 @@ class ToolboxHelper
* Only embed allowed are for MP4 self hosted videos right now
*
* https is force by ckeditor MediaElements which natively supports
* only cloud hosted medias (youtube, spotify etc..)
* only cloud hosted medias (youtube, spotify etc..).
*
* @param string $input
* @return string
@ -159,7 +162,7 @@ class ToolboxHelper
}
/**
* Assert That no Back Office url is present on txt
* Assert That no Back Office url is present on txt.
*
* @param string $field
* @param string $text
@ -202,7 +205,7 @@ class ToolboxHelper
}
/**
* Assert That only external url is present on txt
* Assert That only external url is present on txt.
*
* @param string $field
* @param string $text
@ -245,7 +248,7 @@ class ToolboxHelper
}
/**
* Mutltibyte string replace
* Mutltibyte string replace.
*
* @param array|string $search
* @param array|string $replace
@ -289,7 +292,7 @@ class ToolboxHelper
}
/**
* Asserts that the field is unique
* Asserts that the field is unique.
*
* @param string $table
* @param string $field
@ -305,7 +308,7 @@ class ToolboxHelper
string|int|float|bool|null|array $value,
?int $id = null,
?callable $query = null
) {
): void {
if (!$query) {
Validator::make([$field => $value], [
self::mbReplace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id),
@ -326,7 +329,7 @@ class ToolboxHelper
}
/**
* Get original polyfill with autotranslate behavior
* Get original polyfill with autotranslate behavior.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $attribute
@ -352,7 +355,7 @@ class ToolboxHelper
}
/**
* Dynamic model query
* Dynamic model query.
*
* @param string $defaultLocale
* @param \Illuminate\Contracts\Database\Eloquent\Builder $q
@ -365,7 +368,7 @@ class ToolboxHelper
Builder $q,
string $column,
string $value
): Builder {
): \Illuminate\Contracts\Database\Eloquent\Builder {
$currentLocale = app()->currentLocale();
$locales = collect(config('app.locales'))
->mapWithKeys(fn (string $locale) => [$locale => $locale]);
@ -393,7 +396,7 @@ class ToolboxHelper
}
/**
* Generates an array from a dot separated string
* Generates an array from a dot separated string.
*
* @param string $path
* @param mixed $value
@ -412,7 +415,7 @@ class ToolboxHelper
}
/**
* Convert deeply an object to array
* Convert deeply an object to array.
*
* @param mixed $input
* @return array
@ -434,7 +437,7 @@ class ToolboxHelper
}
/**
* Convert deeply an array to object
* Convert deeply an array to object.
*
* @param mixed $input
* @return object
@ -456,7 +459,7 @@ class ToolboxHelper
}
/**
* Validate picture
* Validate picture.
*
* @param string $attribute
* @param string|null $value
@ -513,7 +516,7 @@ class ToolboxHelper
}
/**
* Get the file full path
* Get the file full path.
*
* @param string $value
* @param boolean $useStorage
@ -527,19 +530,19 @@ class ToolboxHelper
}
/**
* Get the file mimetype
* Get the file mimetype.
*
* @param string $value
* @param boolean $useStorage
* @return string|false
*/
private static function getUploadedFileMimeType(string $value, bool $useStorage)
private static function getUploadedFileMimeType(string $value, bool $useStorage): string|false
{
return !$useStorage ? File::mimeType($value) : Storage::mimeType($value);
}
/**
* Fetch class list from a specific namespace
* Fetch class list from a specific namespace.
*
* @param string $namespace
* @return array<string> An array of classe namespaces
@ -553,7 +556,7 @@ class ToolboxHelper
}
/**
* Get all classes from a specific namespace that implement a specific interface
* Get all classes from a specific namespace that implement a specific interface.
*
* @param string $namespace
* @param string $interface

View file

@ -11,10 +11,10 @@ use Stringable;
*
* @package App\Lib
*/
class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable
class Link implements Jsonable, Arrayable, Stringable
{
/**
* Link
* Link.
*
* @param null|string $url A valid url.
* @param null|string $routeName A valid route name.
@ -77,9 +77,9 @@ class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable
/**
* Get the instance as an array.
*
* @return array<'url'|'routeName',string|null>
* @return array<'url'|'routeName', string|null>
*/
public function toArray()
public function toArray(): array
{
return ['url' => $this->url, 'routeName' => $this->routeName];
}
@ -91,26 +91,14 @@ class Link implements Jsonable, Arrayable, \JsonSerializable, Stringable
* @return string
* @phpcs:disable Squiz.Commenting.FunctionComment.ScalarTypeHintMissing
*/
public function toJson($options = 0)
public function toJson($options = 0): string
{
// phpcs:enable
return \json_encode($this->jsonSerialize(), $options);
}
/**
* Convert the object into something JSON serializable.
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
return \json_encode($this->toArray(), $options);
}
/**
* @return string
*
* @throws \RuntimeException If the link cannot be converted to string.
*/
public function __toString()

View file

@ -6,7 +6,7 @@ use App\Models\Customer;
use Illuminate\Support\Str;
/**
* Some utilities methods
* Some utilities methods.
*/
// phpcs:disable Generic.Files.LineLength.TooLong
class Utils
@ -111,7 +111,7 @@ class Utils
}
/**
* Multibyte strtr
* Multibyte strtr.
*
* @param string $str
* @param string|array $from
@ -131,7 +131,7 @@ class Utils
}
/**
* Generate an unique pseudo
* Generate an unique pseudo.
*
* @param string $firstname
* @param string $lastname

View file

@ -12,7 +12,7 @@ class CreateNotification
* @param \App\Events\NewNotification $event
* @return void
*/
public function handle(NewNotification $event)
public function handle(NewNotification $event): void
{
$event->model->notifiable()->create([
'type' => $event->type,

View file

@ -15,7 +15,7 @@ class PasswordHasReset
* @param \Illuminate\Auth\Events\PasswordReset $event
* @return void
*/
public function handle(PasswordReset $event)
public function handle(PasswordReset $event): void
{
/** @var \App\Models\Customer */
$customer = $event->user;

View file

@ -117,7 +117,6 @@ class ActivityLog extends Model
};
}
/**
* Get a value type as a string
* ! Use this for display purpose only

View file

@ -136,7 +136,7 @@ class BrandAdvantage extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedBrandAdvantagesOrderedByOrder');
self::getPublishedOrdered();

View file

@ -91,7 +91,7 @@ class ConsumptionMoment extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('consumptionMomentsOrderedBySlug');
self::getOrderedBySlug();

View file

@ -100,7 +100,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
// * METHODS
/**
* Asserts using validation that the email is unique
* Asserts using validation that the email is unique.
*
* @param mixed $id
* @param mixed $email
@ -113,7 +113,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Asserts that the field is unique
* Asserts that the field is unique.
*
* @param mixed $id
* @param string $field
@ -134,7 +134,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Get conversations with messages sorted by time
* Get conversations with messages sorted by time.
*
* @return array
*/
@ -218,7 +218,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
*
* @return void
*/
public function sendEmailVerificationNotification()
public function sendEmailVerificationNotification(): void
{
$this->deleteIfDoesNotExistsInCrm();
$this->notify(new VerifyEmail());
@ -230,7 +230,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
* @param mixed $token
* @return void
*/
public function sendPasswordResetNotification(mixed $token)
public function sendPasswordResetNotification(mixed $token): void
{
$this->deleteIfDoesNotExistsInCrm();
/** @var string $token */
@ -296,7 +296,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Get api_data attribute, the crm Data of a customer
* Get api_data attribute, the crm Data of a customer.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
@ -348,7 +348,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
// * CRM CACHE
/**
* Clear cached apiData
* Clear cached apiData.
*
* @return void
*/
@ -360,24 +360,21 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Put customer crm part in cache
* Put customer crm part in cache.
*
* @template T
* @param string $uuid The customer uuid.
* @param string $part_name The part name for the cache path.
* @param \Closure(void):T $part The part to cache.
* @param integer $ttl Time to live in seconds for the cache part.
* @return T
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
* @param string $uuid The customer uuid.
* @param string $part_name The part name for the cache path.
* @param \Closure $part The part to cache.
* @param integer $ttl Time to live in seconds for the cache part.
* @return mixed
*/
public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60)
public static function cacheCrm(string $uuid, string $part_name, \Closure $part, int $ttl = 60 * 60): mixed
{
// phpcs:enable
return Cache::remember("customers.{$uuid}.{$part_name}", $ttl, $part);
}
/**
* Clear customer crm cache part or totally
* Clear customer crm cache part or totally.
*
* @param string $uuid
* @param string $part_name
@ -395,11 +392,11 @@ class Customer extends Authenticatable implements MustVerifyEmail
/**
* This mutate Customer attributes to array
* including only non critical properties and crm values
* (One that can be send to front office without security breach)
* (One that can be send to front office without security breach).
*
* @return array
*/
public function toArray()
public function toArray(): array
{
if ($this->hashcode) {
return collect(array_merge(
@ -427,7 +424,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
// * RELATIONSHIPS
/**
* Get all of the departaimant collections for the Customer
* Get all of the departaimant collections for the Customer.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
@ -437,7 +434,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* The notifications that belong to the Customer
* The notifications that belong to the Customer.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
@ -447,7 +444,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* The read notifications that belong to the Customer
* The read notifications that belong to the Customer.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
@ -457,7 +454,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Get all of the messages for the Customer
* Get all of the messages for the Customer.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
@ -467,7 +464,7 @@ class Customer extends Authenticatable implements MustVerifyEmail
}
/**
* Get all of the sentMessages for the Customer
* Get all of the sentMessages for the Customer.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/

View file

@ -189,7 +189,7 @@ class DemarcheSlide extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedDemarcheSlidesOrderedByOrder');
self::getPublishedOrdered();

View file

@ -13,7 +13,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Departaimants Model
* Has functions to store departaimants on multiple statuses
* Has functions to store departaimants on multiple statuses.
*
* @property \App\Enums\Departaimants\DepartaimantCollectionType $type
* @property integer $customer_id
@ -66,21 +66,21 @@ class DepartaimantsCollection extends Model
];
/**
* Columns prefix
* Columns prefix.
*
* @var string
*/
private static $columnTableNamePrefix = 'col';
/**
* Le prefix d'un table departaimant
* Le prefix d'un table departaimant.
*
* @var integer
*/
private static $tableFields = 4;
/**
* Le nombre de colonnes des departaimants
* Le nombre de colonnes des departaimants.
*
* * La largeur en bits d'un départaimant
* * to be set in construct
@ -130,7 +130,7 @@ class DepartaimantsCollection extends Model
// * RELATIONSHIPS
/**
* Get the customer that owns the DepartaimantsCollection
* Get the customer that owns the DepartaimantsCollection.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
@ -142,7 +142,7 @@ class DepartaimantsCollection extends Model
// * METHODS
/**
* Add a Departaiment to this collection
* Add a Departaiment to this collection.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @return void
@ -153,7 +153,7 @@ class DepartaimantsCollection extends Model
}
/**
* Removes a Departaime from this collection
* Removes a Departaime from this collection.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @return void
@ -164,7 +164,7 @@ class DepartaimantsCollection extends Model
}
/**
* Checks if this collection has a Departaimant
* Checks if this collection has a Departaimant.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @return boolean
@ -175,7 +175,7 @@ class DepartaimantsCollection extends Model
}
/**
* Set the Departaimant to a specific status
* Set the Departaimant to a specific status.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @param \App\Enums\Departaimants\DepartaimantStatus $status
@ -191,7 +191,7 @@ class DepartaimantsCollection extends Model
}
/**
* Test the Departaimant status
* Test the Departaimant status.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @param \App\Enums\Departaimants\DepartaimantStatus $status
@ -212,7 +212,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get all Customer which has their departaimant with a status
* Get all Customer which has their departaimant with a status.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
@ -240,7 +240,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get all Customer which has their departaimant with a status
* Get all Customer which has their departaimant with a status.
*
* @param array $departaimants
* @param \App\Enums\Departaimants\DepartaimantStatus $status
@ -278,7 +278,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get the Departaimant status
* Get the Departaimant status.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @return \App\Enums\Departaimants\DepartaimantStatus
@ -298,7 +298,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get a list of all the departaimants and their status
* Get a list of all the departaimants and their status.
*
* @uses \App\Enums\Departaimants\IDepartaimant
* @uses \App\Enums\Departaimants\DepartaimantStatus
@ -322,7 +322,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get a list of all the departaimants and their status
* Get a list of all the departaimants and their status.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @param \App\Enums\Departaimants\DepartaimantStatus $status
@ -352,7 +352,7 @@ class DepartaimantsCollection extends Model
}
/**
* Set the Departaimant column to 0
* Set the Departaimant column to 0.
*
* @param \App\Enums\Departaimants\IDepartaimant $departaimant
* @return void
@ -367,7 +367,7 @@ class DepartaimantsCollection extends Model
/**
* Donne la 'table' (colonne SQL) dans laquelle se trouve
* le département
* le département.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @param \App\Enums\Departaimants\IDepartaimant $dep
@ -386,7 +386,7 @@ class DepartaimantsCollection extends Model
/**
* Donne la colonne (binaire) dans laquelle se trouve le département
* Dans sa 'table' (colonne SQL)
* Dans sa 'table' (colonne SQL).
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @param \App\Enums\Departaimants\IDepartaimant $dep
@ -407,7 +407,7 @@ class DepartaimantsCollection extends Model
}
/**
* Donne la valeur (masque binaire) d'un département
* Donne la valeur (masque binaire) d'un département.
*
* @param \App\Enums\Departaimants\IDepartaimant $dep
* @return integer
@ -418,7 +418,7 @@ class DepartaimantsCollection extends Model
}
/**
* Genère la liste des departements avec leur masques
* Genère la liste des departements avec leur masques.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @return array
@ -439,7 +439,7 @@ class DepartaimantsCollection extends Model
/**
* Get the with in bit length for a column
* that can be used to store data
* that can be used to store data.
*
* @return float
*/
@ -450,7 +450,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get departaimant enum values
* Get departaimant enum values.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @return array
@ -462,7 +462,7 @@ class DepartaimantsCollection extends Model
}
/**
* Get a departaiment enum from a collection type
* Get a departaiment enum from a collection type.
*
* @param \App\Enums\Departaimants\DepartaimantCollectionType $depColtype
* @return string

View file

@ -93,7 +93,7 @@ class GeneralSetting extends Model
*
* @return mixed
*/
public function getRouteKey()
public function getRouteKey(): mixed
{
/** @var \App\Enums\StaticPageType */
$enum = $this->getAttribute($this->getRouteKeyName());
@ -115,11 +115,11 @@ class GeneralSetting extends Model
// * GETTERS
/**
* Mutator for 'value' attribute
* Mutator for 'value' attribute.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
public function value(): Attribute
public function value(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return Attribute::make(
get: fn($value): array => self::valueFromJson($this->type, $value),
@ -170,7 +170,7 @@ class GeneralSetting extends Model
}
/**
* Unserialize setting value
* Unserialize setting value.
*
* @param \App\Enums\Settings\SettingsType $type
* @param string $json
@ -197,7 +197,7 @@ class GeneralSetting extends Model
* @param \App\Enums\Settings\SettingsType $type
* @return void
*/
private static function resetCache(SettingsType $type)
private static function resetCache(SettingsType $type): void
{
Cache::forget(sprintf('%sGeneralSetting', $type->name));
self::getCachedGeneralSetting($type);
@ -207,9 +207,9 @@ class GeneralSetting extends Model
* Get cached general setting associated to a given type.
*
* @param \App\Enums\Settings\SettingsType $type
* @return \App\Models\StaticPage
* @return mixed
*/
public static function getCachedGeneralSetting(SettingsType $type)
public static function getCachedGeneralSetting(SettingsType $type): mixed
{
return Cache::rememberForever(
sprintf('%sGeneralSetting', $type->name),

View file

@ -117,7 +117,7 @@ class HistoricalMilestone extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedHistoricalMilestonesOrdered');
self::getPublishedOrdered();

View file

@ -84,7 +84,7 @@ class KeyNumber extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('5publishedKeyNumbersOrderedByOrder');
self::get5PublishedOrdered();

View file

@ -177,7 +177,7 @@ class MainSlide extends Model
}
/**
* Adjusts mainSlide status using current status and publish dates
* Adjusts mainSlide status using current status and publish dates.
*
* @param self $mainSlide
* @return void
@ -201,7 +201,7 @@ class MainSlide extends Model
}
/**
* Getter the current status following planification dates planificated_status
* Getter the current status following planification dates planificated_status.
*
* @return boolean
*/
@ -239,7 +239,7 @@ class MainSlide extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedMainSlidesOrderedByOrderWithApproaches');
self::getPublishedOrderedWithApproaches();

View file

@ -127,14 +127,14 @@ class Meat extends Model
}
/**
* Asserts using validation that the label is unique
* Asserts using validation that the label is unique.
*
* @param string|null $label
* @param integer|null $id
* @return void
* @throws \Illuminate\Validation\ValidationException If a meat label already exists.
*/
private static function assertLabelIsUnique(string|null $label, ?int $id = null)
private static function assertLabelIsUnique(string|null $label, ?int $id = null): void
{
$table = (new self())->getTable();
ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id);
@ -157,7 +157,7 @@ class Meat extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedMeatsOrderedByOrder');
self::getPublishedOrdered();

View file

@ -116,7 +116,7 @@ class MenuNodeData extends Model
// * METHODS
/**
* Deny Handling some of the MenuNodeData
* Deny Handling some of the MenuNodeData.
*
* @param self $model
* @return void

View file

@ -32,7 +32,7 @@ class Message extends Model implements INotifiable
// * RELATIONSHIPS
/**
* BelongsTo customer relation
* BelongsTo customer relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
@ -42,7 +42,7 @@ class Message extends Model implements INotifiable
}
/**
* BelongsTo customer relation
* BelongsTo customer relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
@ -52,7 +52,7 @@ class Message extends Model implements INotifiable
}
/**
* MorphOne notification relation
* MorphOne notification relation.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphOne
*/
@ -64,7 +64,7 @@ class Message extends Model implements INotifiable
// * METHODS
/**
* created_at_nice_date attribute
* created_at_nice_date attribute.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
@ -76,7 +76,7 @@ class Message extends Model implements INotifiable
}
/**
* Get MessagesOlderThan attribute
* Get MessagesOlderThan attribute.
*
* @param integer $days
* @return \Illuminate\Contracts\Database\Eloquent\Builder

View file

@ -222,7 +222,7 @@ class News extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedNewsWithCategories');
self::getPublishedWithNewsCategory();

View file

@ -121,7 +121,7 @@ class NewsBreeding extends Model
}
/**
* Adjusts breedingNews status using current status and publish dates
* Adjusts breedingNews status using current status and publish dates.
*
* @param self $model
* @return void
@ -145,7 +145,7 @@ class NewsBreeding extends Model
}
/**
* Asserts using validation that the title is unique
* Asserts using validation that the title is unique.
*
* @param string|null $title
* @param integer|null $id
@ -161,7 +161,7 @@ class NewsBreeding extends Model
/**
* Getter the current status following planification dates planificated_status
* Getter the current status following planification dates planificated_status.
*
* @return boolean
*/
@ -189,7 +189,7 @@ class NewsBreeding extends Model
* @param \App\Enums\StaticPageType $type
* @return void
*/
private static function resetCache(StaticPageType $type)
private static function resetCache(StaticPageType $type): void
{
Cache::forget(sprintf('%sPublishedNewsBreedingOrderedByOrder', $type->name));
self::getPublishedOrderedForType($type);

View file

@ -101,7 +101,7 @@ class NewsCategory extends Model
}
/**
* Asserts using validation that the title is unique
* Asserts using validation that the title is unique.
*
* @param string|null $title
* @param integer|null $id
@ -120,7 +120,7 @@ class NewsCategory extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedNewsCategoriesOrderedByOrder');
self::getPublishedOrdered();

View file

@ -96,7 +96,7 @@ class NewsClub extends Model
}
/**
* Asserts using validation that the title is unique
* Asserts using validation that the title is unique.
*
* @param string|null $title
* @param integer|null $id

View file

@ -85,7 +85,7 @@ class NewsCorporate extends Model
// * METHODS
/**
* Adjusts newsCorporate status using current status and publish dates
* Adjusts newsCorporate status using current status and publish dates.
*
* @param self $newsCorporate
* @return void
@ -109,7 +109,7 @@ class NewsCorporate extends Model
}
/**
* Getter the current status following planification dates planificated_status
* Getter the current status following planification dates planificated_status.
*
* @return boolean
*/
@ -136,7 +136,7 @@ class NewsCorporate extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('9publishedNewsCorporateOrderedByUpdatedAt');
self::get9PublishedOrderedByUpdatedAt();
@ -150,11 +150,7 @@ class NewsCorporate extends Model
public static function get9PublishedOrderedByUpdatedAt(): \Illuminate\Database\Eloquent\Collection
{
return Cache::rememberForever('9publishedNewsCorporateOrderedByUpdatedAt', function () {
return self::query()
->where('published', true)
->orderByDesc('updated_at')
->limit(9)
->get();
return self::query()->where('published', true)->orderByDesc('updated_at')->limit(9)->get();
});
}
}

View file

@ -150,7 +150,7 @@ class Product extends Model implements SeoInterface
* @return void
* @throws \Illuminate\Validation\ValidationException If a range label already exists.
*/
private static function assertLabelIsUnique(string|null $label, ?int $id = null)
private static function assertLabelIsUnique(string|null $label, ?int $id = null): void
{
$table = (new self())->getTable();
ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id);
@ -200,7 +200,7 @@ class Product extends Model implements SeoInterface
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedDiscoveredProducts');
self::getPublishedDiscovered();

View file

@ -79,7 +79,7 @@ class ProductType extends Model
// * METHODS
/**
* Asserts using validation that the label is unique
* Asserts using validation that the label is unique.
*
* @param string|null $label
* @param integer|null $id

View file

@ -132,14 +132,14 @@ class Range extends Model
}
/**
* Asserts using validation that the label is unique
* Asserts using validation that the label is unique.
*
* @param string|null $label
* @param integer|null $id
* @return void
* @throws \Illuminate\Validation\ValidationException If a range label already exists.
*/
private static function assertLabelIsUnique(string|null $label, ?int $id = null)
private static function assertLabelIsUnique(string|null $label, ?int $id = null): void
{
$table = (new self())->getTable();
ToolboxHelper::assertFieldIsUnique($table, 'label', $label, $id);
@ -162,7 +162,7 @@ class Range extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedRangesOrderedByOrder');
self::getPublishedOrdered();

View file

@ -127,14 +127,14 @@ class Recipe extends Model implements SeoInterface
}
/**
* Asserts using validation that the label is unique
* Asserts using validation that the label is unique.
*
* @param string|null $title
* @param integer|null $id
* @return void
* @throws \Illuminate\Validation\ValidationException If a range title already exists.
*/
private static function assertTitleIsUnique(string|null $title, ?int $id = null)
private static function assertTitleIsUnique(string|null $title, ?int $id = null): void
{
$table = (new self())->getTable();
ToolboxHelper::assertFieldIsUnique($table, 'title', $title, $id);
@ -198,7 +198,7 @@ class Recipe extends Model implements SeoInterface
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedFirstHighlightedRecipe');
self::getFirstHighlighted();

View file

@ -96,7 +96,7 @@ class StaticPage extends Model
*
* @return mixed
*/
public function getRouteKey()
public function getRouteKey(): mixed
{
/** @var \App\Enums\StaticPageType */
$enum = $this->getAttribute($this->getRouteKeyName());
@ -137,7 +137,7 @@ class StaticPage extends Model
/**
* Asserts using validation that the title is unique
*
* @param string|null $seo_title
* @param string|null $title
* @param integer|null $id
* @return void
* @throws \Illuminate\Validation\ValidationException If an actu seo_title already exists.
@ -157,7 +157,7 @@ class StaticPage extends Model
* @param \App\Enums\StaticPageType $type
* @return void
*/
private static function resetCache(StaticPageType $type)
private static function resetCache(StaticPageType $type): void
{
Cache::forget(sprintf('%sStaticPage', $type->name));
self::getCachedStaticPage($type);
@ -173,7 +173,7 @@ class StaticPage extends Model
* @param \App\Enums\StaticPageType $type
* @return \App\Models\StaticPage
*/
public static function getCachedStaticPage(StaticPageType $type)
public static function getCachedStaticPage(StaticPageType $type): \App\Models\StaticPage
{
return Cache::rememberForever(
sprintf('%sStaticPage', $type->name),
@ -186,7 +186,7 @@ class StaticPage extends Model
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function getCachedBreedingStaticPages()
public static function getCachedBreedingStaticPages(): \Illuminate\Database\Eloquent\Collection
{
return Cache::rememberForever(
'breedingStaticPages',

View file

@ -133,7 +133,7 @@ class Submeat extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedSubmeatsOrderedByOrder');
self::getPublishedOrdered();

View file

@ -132,7 +132,7 @@ class Subrange extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedSubrangesOrderedByOrder');
self::getPublishedOrdered();

View file

@ -115,7 +115,7 @@ class Testimonial extends Model
* @param integer $max
* @return void
*/
private static function checkPublishedCount(self $model, int $max)
private static function checkPublishedCount(self $model, int $max): void
{
Validator::make(['published' => $model->published], [
'published' => Rule::prohibitedIf(
@ -137,7 +137,7 @@ class Testimonial extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('publishedTestimonialsOrderedByOrder');
self::getPublishedOrdered();

View file

@ -87,7 +87,7 @@ class Video extends Model
*
* @return void
*/
private static function resetCache()
private static function resetCache(): void
{
Cache::forget('9publishedHomeVideosOrderedByOrderWithProducts');
self::get9PublishedHomeVideosOrderedWithProducts();

View file

@ -10,13 +10,10 @@ class DestroyCustomer extends Notification
/**
* Get the notification's delivery channels.
*
* @param object $notifiable
* @return array<int, string>
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function via(object $notifiable): array
public function via(): array
{
// phpcs:enable
return ['mail'];
}
@ -28,15 +25,12 @@ class DestroyCustomer extends Notification
*/
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
{
/** @var string $firstname */
$firstname = $notifiable->username;
return (new MailMessage())
->template('notifications::email-club')
->subject(trans('Supression du compte - :site_name', [
'site_name' => config('app.name')
]))
->greeting(trans('Bonjour :name', ['name' => $firstname]))
->greeting(trans('Bonjour :name', ['name' => $notifiable->username]))
->line(trans(
"Votre compte :site_name a été marqué pour suppression,
il sera définitivement effacé au bout de 1 semaine.

View file

@ -10,26 +10,20 @@ class DestroyedCustomer extends Notification
/**
* Get the notification's delivery channels.
*
* @param object $notifiable
* @return array<int, string>
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function via(object $notifiable): array
public function via(): array
{
// phpcs:enable
return ['mail'];
}
/**
* Build the mail representation of the notification.
*
* @param object $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
public function toMail(): \Illuminate\Notifications\Messages\MailMessage
{
// phpcs:enable
return (new MailMessage())
->template('notifications::email-club')
->subject(trans('Votre compte est suprimé - :site_name', [
@ -40,9 +34,7 @@ class DestroyedCustomer extends Notification
"Votre compte :site_name a été définitivement supprimé ainsi ques les données associés,
si vous aviez effectué une commande elle sera bien sûr toujours honorée. Les commandes associés
a votre compte continueront d'exister mais les données de votre compte ont bien été supprimées.",
[
'site_name' => config('app.name')
]
['site_name' => config('app.name')]
));
}
}

View file

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\URL;
class ResetPassword extends NotificationsResetPassword
{
/**
* ResetPassword
* Reset password.
*
* @param string $token
* @return void

View file

@ -10,13 +10,10 @@ class UpdateEmail extends Notification
/**
* Get the notification's delivery channels.
*
* @param object $notifiable
* @return array<int, string>
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function via(object $notifiable): array
public function via(): array
{
// phpcs:enable
return ['mail'];
}
@ -28,15 +25,12 @@ class UpdateEmail extends Notification
*/
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
{
/** @var string $firstname */
$firstname = $notifiable->username;
return (new MailMessage())
->template('notifications::email-club')
->subject(trans("Mise à jour de l'email - :site_name", [
'site_name' => config('app.name')
]))
->greeting(trans('Bonjour :name', ['name' => $firstname]))
->greeting(trans('Bonjour :name', ['name' => $notifiable->username]))
->line(trans("L'email associé à votre compte :site_name vient d'être modifié.", [
'site_name' => config('app.name')
]));

View file

@ -10,13 +10,10 @@ class UpdatePassword extends Notification
/**
* Get the notification's delivery channels.
*
* @param object $notifiable
* @return array<int, string>
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function via(object $notifiable): array
public function via(): array
{
// phpcs:enable
return ['mail'];
}
@ -28,15 +25,12 @@ class UpdatePassword extends Notification
*/
public function toMail(object $notifiable): \Illuminate\Notifications\Messages\MailMessage
{
/** @var string $firstname */
$firstname = $notifiable->username;
return (new MailMessage())
->template('notifications::email-club')
->subject(trans("Mise à jour du mot de passe - :site_name", [
'site_name' => config('app.name')
]))
->greeting(trans('Bonjour :name', ['name' => $firstname]))
->greeting(trans('Bonjour :name', ['name' => $notifiable->username]))
->line(trans("Le mot de passe associé à votre compte :site_name vient d'être modifié.", [
'site_name' => config('app.name')
]));

View file

@ -11,7 +11,7 @@ use Illuminate\Support\Facades\URL;
class VerifyEmail extends NotificationsVerifyEmail
{
/**
* VerifyEmail
* Verify email.
*
* @return void
*/

View file

@ -11,6 +11,7 @@ class SellItemPolicy
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $authUser
* @return boolean
*/
public function viewAny(User $authUser): bool

View file

@ -13,7 +13,7 @@ class CrmApiServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
App::singleton('crmAPI', function () {
return new CrmApiV4(

View file

@ -50,7 +50,7 @@ class EventServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
Event::listen('Slides\Saml2\Events\SignedIn', function (SignedIn $event) {
$messageId = $event->getAuth()->getLastMessageId();

View file

@ -13,7 +13,7 @@ class MesBrApiServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(): void
{
App::singleton('mesBrAPI', function () {
return new MesBr(

View file

@ -144,7 +144,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
private function cspReportRoute()
private function cspReportRoute(): void
{
// * CSP REPORT URI, Please add /csp-report to VerifyCsrfToken $except middleware
Route::post('/csp-report', function () {

View file

@ -96,6 +96,7 @@ class ViewServiceProvider extends ServiceProvider
});
// * Inject some data for the bo menu.
// @phpcs:disable Generic.Files.LineLength.TooLong
collect([
['name' => 'customerModelsCount', 'value' => Customer::query()->count()],
['name' => 'firstMeat', 'value' => Meat::query()->first()],
@ -104,62 +105,27 @@ class ViewServiceProvider extends ServiceProvider
['name' => 'mainMenuMeatModels', 'value' => Meat::getPublishedOrdered()],
['name' => 'homeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::home)],
['name' => 'storyStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::story)],
[
'name' => 'recruitmentStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment)
],
['name' => 'recruitmentStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recruitment)],
['name' => 'sagaStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::saga)],
[
'name' => 'recipesStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes)
],
[
'name' => 'recipeStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe)
],
[
'name' => 'productsStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::products)
],
['name' => 'recipesStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipes)],
['name' => 'recipeStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::recipe)],
['name' => 'productsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::products)],
['name' => 'legalsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::legals)],
[
'name' => 'confidentialityStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality)
],
[
'name' => 'sellingStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::selling)
],
[
'name' => 'accessibilityStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility)
],
[
'name' => 'productStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::product)
],
[
'name' => 'breedingPoultryStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry)
],
[
'name' => 'breedingJobStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob)
],
[
'name' => 'breedingFoodStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood)
],
[
'name' => 'breedingHealthStaticPageModel',
'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth)
],
['name' => 'confidentialityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::confidentiality)],
['name' => 'sellingStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::selling)],
['name' => 'accessibilityStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::accessibility)],
['name' => 'productStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::product)],
['name' => 'breedingPoultryStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingPoultry)],
['name' => 'breedingJobStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingJob)],
['name' => 'breedingFoodStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingFood)],
['name' => 'breedingHealthStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::breedingHealth)],
['name' => 'newsStaticPageModel', 'value' => StaticPage::getCachedStaticPage(StaticPageType::news)],
])->map(function ($array) {
View::share($array['name'], (function () use ($array) {
return $array['value'] ?: null;
})());
});
// phpcs:enable
} //end if
}
}

View file

@ -69,7 +69,7 @@ class Hex implements ValidationRule
*
* @return string
*/
public function message()
public function message(): string
{
return 'The hex code is not valid';
}

View file

@ -31,7 +31,7 @@ class IsValidVimeoId implements ValidationRule
}
/**
* Validate a value
* Validate a value.
*
* @param mixed $value
* @return boolean

View file

@ -32,7 +32,7 @@ class IsValidYoutubeId implements ValidationRule
}
/**
* Validate a value
* Validate a value.
*
* @param mixed $value
* @return boolean

View file

@ -17,7 +17,7 @@ trait UpdateModelPublished
* @param \Illuminate\Database\Eloquent\Model $model
* @return \Illuminate\Http\RedirectResponse
*/
public function changePublished(Model $model)
public function changePublished(Model $model): \Illuminate\Http\RedirectResponse
{
$model->update(['published' => !$model->getOriginal('published')]);
return redirect()->back()->with('success', trans('crud.messages.publish_status_saved'));

View file

@ -36,7 +36,7 @@ trait IsCachedAsCollection
}
/**
* Remove cached elements
* Remove cached elements.
*
* @return void
*/
@ -63,7 +63,7 @@ trait IsCachedAsCollection
}
/**
* Change query for cached elements
* Change query for cached elements.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
@ -74,7 +74,7 @@ trait IsCachedAsCollection
}
/**
* Change query for cached elements
* Change query for cached elements.
*
* @param \Illuminate\Support\Collection $results
* @return \Illuminate\Support\Collection
@ -85,7 +85,7 @@ trait IsCachedAsCollection
}
/**
* Get the class basename
* Get the class basename.
*
* @return string
*/
@ -95,7 +95,7 @@ trait IsCachedAsCollection
}
/**
* Get the class basename
* Get the class basename.
*
* @return string
*/

View file

@ -27,7 +27,7 @@ trait MiniCrudModel
}
/**
* Apply function on data typed text while on save event
* Apply function on data typed text while on save event.
*
* @return void
*/
@ -47,7 +47,7 @@ trait MiniCrudModel
}
/**
* Apply function on data typed text while on update event
* Apply function on data typed text while on update event.
*
* @return void
*/
@ -57,7 +57,7 @@ trait MiniCrudModel
}
/**
* Apply function on data typed text while on updated event
* Apply function on data typed text while on updated event.
*
* @return void
*/
@ -78,7 +78,7 @@ trait MiniCrudModel
}
/**
* Apply function on data typed text while on deleted event
* Apply function on data typed text while on deleted event.
*
* @return void
*/
@ -95,7 +95,7 @@ trait MiniCrudModel
}
/**
* Set a specific prop
* Set a specific prop.
*
* @param array $data
* @return void
@ -110,7 +110,7 @@ trait MiniCrudModel
}
/**
* Set a specific prop
* Set a specific prop.
*
* @param array $value
* @return void
@ -124,7 +124,7 @@ trait MiniCrudModel
}
/**
* Set a specific prop
* Set a specific prop.
*
* @param string|null $data
* @return array
@ -135,7 +135,7 @@ trait MiniCrudModel
}
/**
* Serialize properties
* Serialize properties.
*
* @param array $data
* @return array

View file

@ -38,7 +38,7 @@ trait HasPicture
private $maxHeight = 1800;
/**
* Image rules
* Image rules.
*
* @param string $name
* @param integer|null $minWidth
@ -85,7 +85,7 @@ trait HasPicture
}
/**
* Images rules
* Images rules.
*
* @param string $name
* @param integer|null $minWidth
@ -108,9 +108,9 @@ trait HasPicture
bool $nullable = false
): array {
$sizes = (object)[
'minWidth' => $minWidth ?? $this->minWidth,
'minWidth' => $minWidth ?? $this->minWidth,
'minHeight' => $minHeight ?? $this->minHeight,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxWidth' => $maxWidth ?? $this->maxWidth,
'maxHeight' => $maxHeight ?? $this->maxHeight,
];
return [
@ -126,7 +126,7 @@ trait HasPicture
}
/**
* Merges products pictures fields with request data
* Merges products pictures fields with request data.
*
* @param string $name
* @return void
@ -153,7 +153,7 @@ trait HasPicture
$this->merge([
$name => $changedPicture
]);
// le else if sert a gerer le cas ou l'image de la bannière produit est nulle
// FIXME: patch because of component return.
} elseif (is_null($picturePath)) {
$this->merge([$name => null]);
return;
@ -161,7 +161,7 @@ trait HasPicture
}
/**
* Merges products pictures fields with request data
* Merges products pictures fields with request data.
*
* @param string $name
* @return void

View file

@ -3,7 +3,6 @@
namespace App\View\Components\Fo\Story;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use App\Models\StaticPage;
use App\Enums\StaticPageType;
@ -23,7 +22,7 @@ class HistoricalMilestoneComponent extends Component
public function __construct()
{
$this->staticPageModel = StaticPage::getCachedStaticPage(StaticPageType::story);
$this->historicalMilestoneModels = HistoricalMilestone::getPublishedOrderedByYear();
$this->historicalMilestoneModels = HistoricalMilestone::getPublishedOrdered();
}
/**
@ -31,10 +30,10 @@ class HistoricalMilestoneComponent extends Component
*
* @return \Illuminate\Contracts\View\View
*/
public function render(): View|Closure|string
public function render(): \Illuminate\Contracts\View\View|Closure|string
{
return view('components.fo.story.historical-milestone-component', [
'staticPageModel' => $this->staticPageModel,
'staticPageModel' => $this->staticPageModel,
'historicalMilestoneModels' => $this->historicalMilestoneModels
]);
}

View file

@ -3,7 +3,6 @@
namespace App\View\Components\Fo\Story;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use App\Models\StaticPage;
use App\Enums\StaticPageType;
@ -32,7 +31,7 @@ class WhoWeAre extends Component
*
* @return \Illuminate\Contracts\View\View
*/
public function render(): View|Closure|string
public function render(): \Illuminate\Contracts\View\View|Closure|string
{
return view('components.fo.story.who-we-are', [
'staticPageModel' => $this->staticPageModel,