phpcs fixes
This commit is contained in:
parent
c88583d727
commit
f43ea7c9ff
21 changed files with 78 additions and 119 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,16 +12,14 @@ class Handler extends ExceptionHandler
|
|||
*
|
||||
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
|
||||
*/
|
||||
protected $levels = [
|
||||
];
|
||||
protected $levels = [];
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array<int, class-string<\Throwable>>
|
||||
*/
|
||||
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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class Kernel extends HttpKernel
|
|||
* @var array<int, class-string|string>
|
||||
*/
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ class ValidateSignature extends Middleware
|
|||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*
|
||||
* '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 = [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
protected $policies = [];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -64,11 +64,6 @@ return [
|
|||
'driver' => 'eloquent',
|
||||
'model' => App\Models\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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' => [
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
],
|
||||
|
||||
],
|
||||
|
|
|
|||
|
|
@ -51,16 +51,16 @@ return [
|
|||
|
||||
'mailgun' => [
|
||||
'transport' => 'mailgun',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
'client' => [
|
||||
'timeout' => 5,
|
||||
],
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
'client' => [
|
||||
'timeout' => 5,
|
||||
],
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue