diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4c1dd5a..c4f0d61 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -9,14 +9,18 @@ class Kernel extends ConsoleKernel { /** * Define the application's command schedule. + * + * @param \Illuminate\Console\Scheduling\Schedule $schedule + * @return void */ protected function schedule(Schedule $schedule): void { - // $schedule->command('inspire')->hourly(); } /** * Register the commands for the application. + * + * @return void */ protected function commands(): void { diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 20aac84..367f61b 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -12,16 +12,14 @@ class Handler extends ExceptionHandler * * @var array, \Psr\Log\LogLevel::*> */ - protected $levels = [ - ]; + protected $levels = []; /** * A list of the exception types that are not reported. * * @var array> */ - protected $dontReport = [ - ]; + protected $dontReport = []; /** * A list of the inputs that are never flashed to the session on validation exceptions. @@ -36,6 +34,8 @@ class Handler extends ExceptionHandler /** * Register the exception handling callbacks for the application. + * + * @return void */ public function register(): void { diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index dfe1bd8..bf38ee7 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -14,7 +14,7 @@ class Kernel extends HttpKernel * @var array */ protected $middleware = [ - // \App\Http\Middleware\TrustHosts::class, + \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index d4ef644..9566d3f 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -9,6 +9,9 @@ class Authenticate extends Middleware { /** * Get the path the user should be redirected to when they are not authenticated. + * + * @param \Illuminate\Http\Request $request + * @return string|null */ protected function redirectTo(Request $request): ?string { diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 12a2280..68f111d 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -3,7 +3,6 @@ namespace App\Http\Middleware; use App\Providers\RouteServiceProvider; -use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Symfony\Component\HttpFoundation\Response; @@ -13,10 +12,15 @@ class RedirectIfAuthenticated /** * Handle an incoming request. * - * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + * @param \Illuminate\Http\Request $request + * @param \Closure(\Illuminate\Http\Request):(\Symfony\Component\HttpFoundation\Response) $next + * @param string ...$guards + * @return \Symfony\Component\HttpFoundation\Response + * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint */ - public function handle(Request $request, Closure $next, string ...$guards): Response + public function handle(Request $request, \Closure $next, string ...$guards): Response { + // phpcs:enable $guards = empty($guards) ? [null] : $guards; foreach ($guards as $guard) { diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php index 093bf64..9d4e514 100644 --- a/app/Http/Middleware/ValidateSignature.php +++ b/app/Http/Middleware/ValidateSignature.php @@ -10,13 +10,13 @@ class ValidateSignature extends Middleware * The names of the query string parameters that should be ignored. * * @var array + * + * 'fbclid', + * 'utm_campaign', + * 'utm_content', + * 'utm_medium', + * 'utm_source', + * 'utm_term', */ - protected $except = [ - // 'fbclid', - // 'utm_campaign', - // 'utm_content', - // 'utm_medium', - // 'utm_source', - // 'utm_term', - ]; + protected $except = []; } diff --git a/app/Http/Requests/Products/StoreProductRequest.php b/app/Http/Requests/Products/StoreProductRequest.php index 497e170..73d0eb2 100644 --- a/app/Http/Requests/Products/StoreProductRequest.php +++ b/app/Http/Requests/Products/StoreProductRequest.php @@ -63,7 +63,10 @@ class StoreProductRequest extends FormRequest 'name' => 'required|string|min:3|max:255', 'brand_id' => 'required|exists:brands,id', 'source' => [new Enum(SourceEnum::class)], - 'fair' => 'nullable|string|min:3|max:255|required_if:source,' . SourceEnum::showConsumer->value . ',' . SourceEnum::showCustomer->value . ',' . SourceEnum::showTrade->value, + 'fair' => 'nullable|string|min:3|max:255|required_if:source,' . + SourceEnum::showConsumer->value . ',' . + SourceEnum::showCustomer->value . ',' . + SourceEnum::showTrade->value, 'shop' => 'nullable|string|min:3|max:255|required_if:source,' . SourceEnum::magazin->value, 'catalogue' => 'nullable|string|min:3|max:255|required_if:source,' . SourceEnum::catalogArgumentary->value, 'gencod' => 'nullable|numeric|min:0', diff --git a/app/Jobs/ExportProduct.php b/app/Jobs/ExportProduct.php index f176b3a..f4f4081 100644 --- a/app/Jobs/ExportProduct.php +++ b/app/Jobs/ExportProduct.php @@ -22,6 +22,7 @@ class ExportProduct implements ShouldQueue /** * Execute the job. * + * @param integer $productId * @return void * @throws \Error If file storage config is wrong. * @throws \RuntimeException If the storage disk export is not local file system. @@ -50,7 +51,10 @@ class ExportProduct implements ShouldQueue throw new \RuntimeException("The ZIP file cannot be created."); } - $dirName = Str::slug(Carbon::parse($product->updated_at)->format('y-m-d') . '-' . $product->user->lastname . '-' . $product->user->id); + $dirName = Str::slug( + Carbon::parse($product->updated_at)->format('y-m-d') . '-' . + $product->user->lastname . '-' . $product->user->id + ); if (!$zip->addEmptyDir($dirName)) { throw new \RuntimeException("The folder cannot be created inside the ZIP."); diff --git a/app/Lib/Helpers/ToolboxHelper.php b/app/Lib/Helpers/ToolboxHelper.php index e280f90..6632f35 100644 --- a/app/Lib/Helpers/ToolboxHelper.php +++ b/app/Lib/Helpers/ToolboxHelper.php @@ -3,12 +3,9 @@ namespace App\Lib\Helpers; use App\Enums\Pagination\ItemsPerPaginationEnum; -use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; -use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Validator; -use Illuminate\Support\Str; use Illuminate\Validation\Rule; use Illuminate\Validation\Rules\Enum; use Illuminate\Validation\ValidationException; @@ -142,75 +139,15 @@ class ToolboxHelper return $text; } - /** - * Generates an array from a dot separated string - * - * @param string $path - * @param mixed $value - * @param string $separator - * @return array - */ - public static function dotStringToNestedArray(string $path, $value, string $separator = '.'): array - { - $arr = $value; - $keys = array_reverse(explode($separator, $path)); - - foreach ($keys as $key) { - $arr = [$key => $arr]; - } - return $arr; - } - - /** - * Generate url using laravel route passing our group query if present - * This is used to keep ou group tracking - * Curd-policies is only used for root users as it cannot keep track of our group - * and validate things - * - * @param array|string $name - * @param mixed $parameters - * @param boolean $absolute - * @return string - * @throws \ErrorException If an object given as parameter is not a Model. - */ - public static function routeWithGroup($name, $parameters = [], bool $absolute = true): string - { - // * Handle if parameter if is an object. - if (\is_object($parameters)) { - $parents = \class_parents($parameters); - if ($parents === false or !\in_array(Model::class, $parents)) { - throw new \ErrorException(\sprintf( - '%s only support object of type %s', - __FUNCTION__, - Model::class - )); - } - /** @var \Illuminate\Database\Eloquent\Model $model */ - $model = $parameters; - $parameters = [Str::singular($model->getTable()) => $model]; - } - // * Handle if parameter isnt and array like slug or else. - if (!is_array($parameters)) { - // * Best effort, result is not garantee. - $parameters = [$parameters]; - } - // * Pass our group. - if ($group = Session::get('activeGroup', request()->group)) { - $parameters = array_merge($parameters, ['group' => $group]); - } - // * Call laravel route helper. - return route($name, $parameters, $absolute); - } - /** * Mutltibyte string replace - * @param mixed $search - * @param mixed $replace - * @param mixed $subject - * @param integer $count + * @param string|array $search + * @param string|array $replace + * @param mixed $subject + * @param integer $count * @return mixed */ - public static function mbReplace($search, $replace, $subject, int &$count = 0) + public static function mbReplace(string|array $search, string|array $replace, mixed $subject, int &$count = 0) { if (!is_array($search) && is_array($replace)) { return false; @@ -255,7 +192,7 @@ class ToolboxHelper public static function assertFieldIsUnique( string $table, string $field, - $value, + mixed $value, ?int $id = null, ?callable $query = null ) { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index f25feb6..1276249 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -11,6 +11,8 @@ class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. + * + * @return void */ public function boot(): void { @@ -25,7 +27,7 @@ class AppServiceProvider extends ServiceProvider return request()->getClientIp(); } else { return request()->server('HTTP_X_FORWARDED_FOR') ?? - request()->getClientIp(); + request()->getClientIp(); } }); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 67404cc..9e12cbd 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -// use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider @@ -12,12 +11,12 @@ class AuthServiceProvider extends ServiceProvider * * @var array */ - protected $policies = [ - // 'App\Models\Model' => 'App\Policies\ModelPolicy', - ]; + protected $policies = []; /** * Register any authentication / authorization services. + * + * @return void */ public function boot(): void { diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 91374ec..5fddcc8 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -21,6 +21,7 @@ class EventServiceProvider extends ServiceProvider /** * Register any events for your application. + * @return void */ public function boot(): void { @@ -28,6 +29,7 @@ class EventServiceProvider extends ServiceProvider /** * Determine if events and listeners should be automatically discovered. + * @return boolean */ public function shouldDiscoverEvents(): bool { diff --git a/app/Traits/Requests/HasDocument.php b/app/Traits/Requests/HasDocument.php index f760f48..63ea180 100644 --- a/app/Traits/Requests/HasDocument.php +++ b/app/Traits/Requests/HasDocument.php @@ -38,7 +38,7 @@ trait HasDocument * @return void * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed */ - private function validateDocument(string $attribute, $value, callable $fail) + private function validateDocument(string $attribute, mixed $value, callable $fail) { if (!($useStorage = Storage::exists($value)) and !File::exists($value)) { $fail(trans(":attribute n'existe pas dans le système de fichier")); diff --git a/app/Traits/Requests/HasPicture.php b/app/Traits/Requests/HasPicture.php index 0e53bb1..ff664c4 100644 --- a/app/Traits/Requests/HasPicture.php +++ b/app/Traits/Requests/HasPicture.php @@ -123,7 +123,7 @@ trait HasPicture * @return void * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed */ - private function validatePicture(string $attribute, $value, callable $fail, object $sizes) + private function validatePicture(string $attribute, mixed $value, callable $fail, object $sizes) { if (!($useStorage = Storage::exists($value)) and !File::exists($value)) { $fail(trans(":attribute n'existe pas dans le système de fichier")); @@ -239,7 +239,7 @@ trait HasPicture */ private function getUploadedFileFullPath(string $value, bool $useStorage): string { - return !$useStorage ? realpath($value) ?: $value : Storage::getAdapter()->applyPathPrefix($value); + return !$useStorage ? (realpath($value) ?: $value) : Storage::path($value); } /** diff --git a/config/app.php b/config/app.php index cf9b17c..11e56fc 100644 --- a/config/app.php +++ b/config/app.php @@ -140,7 +140,7 @@ return [ 'maintenance' => [ 'driver' => 'file', - // 'store' => 'redis', + // 'store' 'redis' ], /* @@ -159,6 +159,7 @@ return [ /* * Laravel Framework Service Providers... */ + Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, @@ -185,11 +186,13 @@ return [ /* * Package Service Providers... */ + Krlove\EloquentModelGenerator\Provider\GeneratorServiceProvider::class, /* * Application Service Providers... */ + App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\EventServiceProvider::class, diff --git a/config/auth.php b/config/auth.php index 81f827d..6f24fef 100644 --- a/config/auth.php +++ b/config/auth.php @@ -64,11 +64,6 @@ return [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], - - // 'users' => [ - // 'driver' => 'database', - // 'table' => 'users', - // ], ], /* diff --git a/config/broadcasting.php b/config/broadcasting.php index f343c55..e9d51fa 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -42,9 +42,8 @@ return [ 'encrypted' => true, 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', ], - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html . + 'client_options' => [], ], 'ably' => [ diff --git a/config/cache.php b/config/cache.php index 432bc06..7d0d7d0 100644 --- a/config/cache.php +++ b/config/cache.php @@ -61,9 +61,7 @@ return [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], + 'options' => [], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), diff --git a/config/database.php b/config/database.php index e384506..d3450a3 100644 --- a/config/database.php +++ b/config/database.php @@ -101,8 +101,8 @@ return [ 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, - // 'encrypt' => env('DB_ENCRYPT', 'yes'), - // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), + 'encrypt' => env('DB_ENCRYPT', 'yes'), + 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), ], ], diff --git a/config/mail.php b/config/mail.php index 196d017..eed7ba5 100644 --- a/config/mail.php +++ b/config/mail.php @@ -51,16 +51,16 @@ return [ 'mailgun' => [ 'transport' => 'mailgun', - // 'client' => [ - // 'timeout' => 5, - // ], + 'client' => [ + 'timeout' => 5, + ], ], 'postmark' => [ 'transport' => 'postmark', - // 'client' => [ - // 'timeout' => 5, - // ], + 'client' => [ + 'timeout' => 5, + ], ], 'sendmail' => [ diff --git a/database/factories/ProductFactory.php b/database/factories/ProductFactory.php index 2a82f97..4fa90cd 100644 --- a/database/factories/ProductFactory.php +++ b/database/factories/ProductFactory.php @@ -34,9 +34,15 @@ final class ProductFactory extends Factory */ public function definition(): array { - $source = \collect(SourceEnum::toArray())->random()->value; - $fair = $shop = $catalogue = null; - if ($source === SourceEnum::showConsumer->value || $source === SourceEnum::showCustomer->value || $source === SourceEnum::showTrade->value) { + $source = \collect(SourceEnum::toArray())->random()->value; + $catalogue = null; + $fair = null; + $shop = null; + if ( + $source === SourceEnum::showConsumer->value || + $source === SourceEnum::showCustomer->value || + $source === SourceEnum::showTrade->value + ) { $fair = fake()->word; } elseif ($source === SourceEnum::magazin->value) { $shop = fake()->word;