From b1e56a8eae75054b0d3dcacc6283895841cbb98c Mon Sep 17 00:00:00 2001 From: Alexis Gousseau Date: Tue, 26 May 2026 13:12:45 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=9A=A8=20resolve=20linters=20erro?= =?UTF-8?q?rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/MakeUser.php | 3 +- app/Http/Controllers/Back/BrandController.php | 32 ++-- .../Back/InvoiceCompanyController.php | 31 ++-- .../Back/InvoicePackageController.php | 31 ++-- .../Controllers/Back/NoticeController.php | 28 +-- app/Http/Controllers/Back/SiteController.php | 42 +++-- app/Http/Controllers/Back/UserController.php | 10 +- .../Requests/Auth/ForgotPasswordRequest.php | 1 + app/Http/Requests/Auth/LoginRequest.php | 1 + .../Requests/Auth/ResetPasswordRequest.php | 1 + .../Back/Brands/StoreBrandRequest.php | 1 + .../StoreInvoiceCompanyRequest.php | 1 + .../UpdateInvoiceCompanyRequest.php | 1 + .../StoreInvoicePackageRequest.php | 1 + .../UpdateInvoicePackageRequest.php | 1 + .../Back/Notices/StoreNoticeRequest.php | 1 + .../Back/Notices/UpdateNoticeRequest.php | 1 + .../Requests/Back/Sites/StoreSiteRequest.php | 8 +- .../Users/Concerns/HasUserRequestRules.php | 3 +- app/Mails/Auth/ResetPassword.php | 4 +- app/Models/Brand.php | 15 +- app/Models/GitlabIssue.php | 7 +- app/Models/GitlabIssueLabel.php | 2 + app/Models/GitlabLabel.php | 6 +- app/Models/GitlabMilestone.php | 7 +- app/Models/GitlabProject.php | 7 +- app/Models/GitlabUser.php | 4 +- app/Models/InvoiceCompany.php | 1 + app/Models/InvoicePackage.php | 2 + app/Models/Notice.php | 2 + app/Models/Site.php | 32 ++-- app/Models/User.php | 47 ++--- app/Providers/AppServiceProvider.php | 3 - bootstrap/app.php | 20 +- composer.json | 12 +- composer.lock | 172 +++++++++++++++++- config/app.php | 2 +- config/database.php | 10 +- database/factories/BrandFactory.php | 3 + database/factories/GitlabIssueFactory.php | 3 + .../factories/GitlabIssueLabelFactory.php | 3 + database/factories/GitlabLabelFactory.php | 3 + database/factories/GitlabMilestoneFactory.php | 3 + database/factories/GitlabProjectFactory.php | 3 + database/factories/InvoiceCompanyFactory.php | 3 + database/factories/InvoicePackageFactory.php | 3 + database/factories/NoticeFactory.php | 5 +- database/factories/SiteFactory.php | 3 + ...2026_04_30_123018_create_notices_table.php | 2 +- ...0_145058_create_invoice_packages_table.php | 2 +- ..._154432_create_invoice_companies_table.php | 2 +- ...30_155423_create_gitlab_projects_table.php | 2 +- .../2026_04_30_160235_create_sites_table.php | 2 +- ...026_05_18_141028_create_sitables_table.php | 2 +- .../2026_05_19_144844_create_brands_table.php | 2 +- ...05_21_101233_create_gitlab_users_table.php | 2 +- ...5_26_093500_create_gitlab_labels_table.php | 2 +- ...5_26_100638_create_gitlab_issues_table.php | 2 +- ..._104912_create_gitlab_milestones_table.php | 2 +- ...10633_create_gitlab_issue_labels_table.php | 2 +- phpcs.xml | 3 +- phpstan.neon | 3 + pint.json | 77 ++++++++ rector.php | 56 ++++++ .../ts/back/Components/Filters/EnumFilter.tsx | 4 +- .../Filters/MultiSelectRelationFilter.tsx | 4 +- .../back/Components/Filters/SwitchFilter.tsx | 4 +- .../Layout/Sidebar/Links/Brands.tsx | 10 +- .../Layout/Sidebar/Links/InvoiceCompanies.tsx | 10 +- .../Layout/Sidebar/Links/InvoicePackages.tsx | 10 +- .../Layout/Sidebar/Links/Notices.tsx | 10 +- .../Components/Layout/Sidebar/Links/Sites.tsx | 10 +- .../back/Components/Table/DataTableSearch.tsx | 6 +- .../ts/back/Pages/ActivityLogs/Index.tsx | 10 +- resources/ts/back/Pages/ActivityLogs/Show.tsx | 6 +- resources/ts/back/Pages/Auth/Login.tsx | 2 +- resources/ts/back/Pages/Brands/Form.tsx | 8 +- resources/ts/back/Pages/Sites/Form.tsx | 8 +- resources/ts/back/Pages/Users/Form.tsx | 25 +-- resources/ts/back/Pages/Users/Index.tsx | 4 +- resources/ts/back/hooks/use-crud-submit.tsx | 4 +- resources/ts/back/lib/filters.tsx | 2 +- resources/ts/back/types/global.d.ts | 6 +- resources/ts/back/types/project.d.ts | 16 +- resources/ts/components/ui/dialog.tsx | 13 +- resources/ts/components/ui/sheet.tsx | 21 ++- routes/back/users.php | 2 +- routes/breadcrumbs/brands.php | 12 +- routes/breadcrumbs/invoice-companies.php | 12 +- routes/breadcrumbs/invoice-packages.php | 12 +- routes/breadcrumbs/notices.php | 12 +- routes/breadcrumbs/sites.php | 12 +- 92 files changed, 715 insertions(+), 288 deletions(-) create mode 100644 pint.json create mode 100644 rector.php diff --git a/app/Console/Commands/MakeUser.php b/app/Console/Commands/MakeUser.php index ac39798..c55e199 100644 --- a/app/Console/Commands/MakeUser.php +++ b/app/Console/Commands/MakeUser.php @@ -114,7 +114,8 @@ class MakeUser extends Command $defaultRole = UserRoleRegistry::get('client'); $options = collect($roles)->mapWithKeys( - fn(object $role) => [Str::ucFirst($role->label) => $role]); + fn(object $role) => [Str::ucFirst($role->label) => $role] + ); $choice = $this->choice( 'Role', diff --git a/app/Http/Controllers/Back/BrandController.php b/app/Http/Controllers/Back/BrandController.php index 2c7f34e..a12bd19 100644 --- a/app/Http/Controllers/Back/BrandController.php +++ b/app/Http/Controllers/Back/BrandController.php @@ -24,7 +24,7 @@ class BrandController extends BackendController * * @var \Illuminate\Support\Collection */ - private \Illuminate\Support\Collection $siteModels; + private readonly \Illuminate\Support\Collection $siteModels; /** * Create the controller instance. @@ -124,12 +124,12 @@ class BrandController extends BackendController if ($brand->saveOrFail()) { $brand->sites()->syncWithoutDetaching(Arr::get($validatedData, 'sites')); - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $brand) + return to_route("{$this->routeName}{$this->modelName}.edit", $brand) ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -154,7 +154,7 @@ class BrandController extends BackendController * Update the specified resource. * * @param \App\Http\Requests\Back\Brands\UpdateBrandRequest $request - * @param \App\Models\Brand $brand + * @param \App\Models\Brand $brand * @return \Illuminate\Http\RedirectResponse */ public function update( @@ -167,12 +167,12 @@ class BrandController extends BackendController if ($brand->saveOrFail()) { $brand->sites()->sync(Arr::get($validatedData, 'sites')); - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $brand) + return to_route("{$this->routeName}{$this->modelName}.edit", $brand) ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $brand) + return to_route("{$this->routeName}{$this->modelName}.edit", $brand) ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -187,7 +187,7 @@ class BrandController extends BackendController */ public function duplicate(Brand $brand): \Inertia\Response { - $brand->loadMissing(Brand::$cacheRelations ?? []); + $brand->loadMissing(Brand::getCacheRelations()); $replica = $brand->replicate(); collect($brand->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); return $this->create($replica); @@ -204,14 +204,14 @@ class BrandController extends BackendController $brand = Brand::withTrashed()->findOrFail($brand); /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($brand->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -227,14 +227,14 @@ class BrandController extends BackendController { /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($brand->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.index", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -253,14 +253,14 @@ class BrandController extends BackendController } /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($brand->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); diff --git a/app/Http/Controllers/Back/InvoiceCompanyController.php b/app/Http/Controllers/Back/InvoiceCompanyController.php index f4471a1..3a84278 100644 --- a/app/Http/Controllers/Back/InvoiceCompanyController.php +++ b/app/Http/Controllers/Back/InvoiceCompanyController.php @@ -108,12 +108,12 @@ class InvoiceCompanyController extends BackendController $invoice_company->fill($request->validated()); if ($invoice_company->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_company) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_company) ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -148,12 +148,12 @@ class InvoiceCompanyController extends BackendController $invoice_company->fill($request->validated()); if ($invoice_company->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_company) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_company) ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_company) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_company) ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -168,9 +168,10 @@ class InvoiceCompanyController extends BackendController */ public function duplicate(InvoiceCompany $invoice_company): \Inertia\Response { - $invoice_company->loadMissing(InvoiceCompany::$cacheRelations ?? []); + $invoice_company->loadMissing(InvoiceCompany::getCacheRelations()); $replica = $invoice_company->replicate(); - collect($invoice_company->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); + collect($invoice_company->getRelations()) + ->each(fn($value, $relation) => $replica->setRelation($relation, $value)); return $this->create($replica); } @@ -185,14 +186,14 @@ class InvoiceCompanyController extends BackendController $invoice_company = InvoiceCompany::withTrashed()->findOrFail($invoice_company); /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_company->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -208,14 +209,14 @@ class InvoiceCompanyController extends BackendController { /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_company->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.index", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -234,14 +235,14 @@ class InvoiceCompanyController extends BackendController } /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_company->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); diff --git a/app/Http/Controllers/Back/InvoicePackageController.php b/app/Http/Controllers/Back/InvoicePackageController.php index f81dfbd..3d8b441 100644 --- a/app/Http/Controllers/Back/InvoicePackageController.php +++ b/app/Http/Controllers/Back/InvoicePackageController.php @@ -108,12 +108,12 @@ class InvoicePackageController extends BackendController $invoice_package->fill($request->validated()); if ($invoice_package->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_package) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_package) ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -148,12 +148,12 @@ class InvoicePackageController extends BackendController $invoice_package->fill($request->validated()); if ($invoice_package->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_package) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_package) ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $invoice_package) + return to_route("{$this->routeName}{$this->modelName}.edit", $invoice_package) ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -168,9 +168,10 @@ class InvoicePackageController extends BackendController */ public function duplicate(InvoicePackage $invoice_package): \Inertia\Response { - $invoice_package->loadMissing(InvoicePackage::$cacheRelations ?? []); + $invoice_package->loadMissing(InvoicePackage::getCacheRelations()); $replica = $invoice_package->replicate(); - collect($invoice_package->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); + collect($invoice_package->getRelations()) + ->each(fn($value, $relation) => $replica->setRelation($relation, $value)); return $this->create($replica); } @@ -185,14 +186,14 @@ class InvoicePackageController extends BackendController $invoice_package = InvoicePackage::withTrashed()->findOrFail($invoice_package); /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_package->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -208,14 +209,14 @@ class InvoicePackageController extends BackendController { /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_package->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.index", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -234,14 +235,14 @@ class InvoicePackageController extends BackendController } /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($invoice_package->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); diff --git a/app/Http/Controllers/Back/NoticeController.php b/app/Http/Controllers/Back/NoticeController.php index bc99894..be950ab 100644 --- a/app/Http/Controllers/Back/NoticeController.php +++ b/app/Http/Controllers/Back/NoticeController.php @@ -108,12 +108,12 @@ class NoticeController extends BackendController $notice->fill($request->validated()); if ($notice->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $notice) + return to_route("{$this->routeName}{$this->modelName}.edit", $notice) ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -148,12 +148,12 @@ class NoticeController extends BackendController $notice->fill($request->validated()); if ($notice->saveOrFail()) { - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $notice) + return to_route("{$this->routeName}{$this->modelName}.edit", $notice) ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $notice) + return to_route("{$this->routeName}{$this->modelName}.edit", $notice) ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -168,7 +168,7 @@ class NoticeController extends BackendController */ public function duplicate(Notice $notice): \Inertia\Response { - $notice->loadMissing(Notice::$cacheRelations ?? []); + $notice->loadMissing(Notice::getCacheRelations()); $replica = $notice->replicate(); collect($notice->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); return $this->create($replica); @@ -185,14 +185,14 @@ class NoticeController extends BackendController $notice = Notice::withTrashed()->findOrFail($notice); /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($notice->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -208,14 +208,14 @@ class NoticeController extends BackendController { /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($notice->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.index", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -234,14 +234,14 @@ class NoticeController extends BackendController } /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($notice->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); diff --git a/app/Http/Controllers/Back/SiteController.php b/app/Http/Controllers/Back/SiteController.php index 1ea758f..9867914 100644 --- a/app/Http/Controllers/Back/SiteController.php +++ b/app/Http/Controllers/Back/SiteController.php @@ -23,16 +23,16 @@ class SiteController extends BackendController /** * Project managers collection. * - * @var \Illuminate\Support\Collection + * @var \Illuminate\Support\Collection */ - private \Illuminate\Support\Collection $userModelsProjectManager; + private readonly \Illuminate\Support\Collection $userModelsProjectManager; /** * Project managers collection. * - * @var \Illuminate\Support\Collection + * @var \Illuminate\Support\Collection */ - private \Illuminate\Support\Collection $userModelsClient; + private readonly \Illuminate\Support\Collection $userModelsClient; /** * Create the controller instance. @@ -41,8 +41,10 @@ class SiteController extends BackendController { parent::__construct(); $this->authorizeResource(Site::class); - $this->modelName = Site::modelName(); - $this->modelPage = Site::modelPage(); + $this->modelName = Site::modelName(); + $this->modelPage = Site::modelPage(); + + /** @var \Illuminate\Support\Collection $userModels */ $userModels = User::getModelsCached() ->where("published", true) ->where('deleted_at', null) @@ -154,12 +156,12 @@ class SiteController extends BackendController if ($site->saveOrFail()) { $site->users()->syncWithoutDetaching(Arr::get($validatedData, 'users')); - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $site) + return to_route("{$this->routeName}{$this->modelName}.edit", $site) ->with('success', trans('uwil-backend::crud.messages.has_been_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_created', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -202,12 +204,12 @@ class SiteController extends BackendController if ($site->saveOrFail()) { $site->users()->sync(Arr::get($validatedData, 'users')); - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $site) + return to_route("{$this->routeName}{$this->modelName}.edit", $site) ->with('success', trans('uwil-backend::crud.messages.has_been_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->route("{$this->routeName}{$this->modelName}.edit", $site) + return to_route("{$this->routeName}{$this->modelName}.edit", $site) ->with('error', trans('uwil-backend::crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -222,7 +224,7 @@ class SiteController extends BackendController */ public function duplicate(Site $site): \Inertia\Response { - $site->loadMissing(Site::$cacheRelations ?? []); + $site->loadMissing(Site::getCacheRelations()); $replica = $site->replicate(); collect($site->getRelations())->each(fn($value, $relation) => $replica->setRelation($relation, $value)); return $this->create($replica); @@ -239,14 +241,14 @@ class SiteController extends BackendController $site = Site::withTrashed()->findOrFail($site); /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($site->restore()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_restored', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -262,14 +264,14 @@ class SiteController extends BackendController { /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($site->delete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.index", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.index", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); @@ -288,14 +290,14 @@ class SiteController extends BackendController } /** @var array */ $previousQueries = []; - \parse_str(\parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); + \parse_str((string) \parse_url(url()->previous(), \PHP_URL_QUERY), $previousQueries); if ($site->forceDelete()) { - return redirect()->route("{$this->routeName}{$this->modelName}.trash", $previousQueries) + return to_route("{$this->routeName}{$this->modelName}.trash", $previousQueries) ->with('success', trans('uwil-backend::crud.messages.has_been_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); } - return redirect()->back() + return back() ->with('error', trans('uwil-backend::crud.messages.cannot_be_deleted', [ 'model' => Str::ucfirst(trans_choice("models.classes.$this->modelName", 1)), ])); diff --git a/app/Http/Controllers/Back/UserController.php b/app/Http/Controllers/Back/UserController.php index 93111ee..1ab8715 100644 --- a/app/Http/Controllers/Back/UserController.php +++ b/app/Http/Controllers/Back/UserController.php @@ -11,6 +11,8 @@ use Uwil\LaravelBackend\Controllers\UserController as BackendUserController; */ class UserController extends BackendUserController { + // phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter + /** * Update the specified resource. * @@ -18,11 +20,12 @@ class UserController extends BackendUserController * @param mixed $callback * @return \Illuminate\Http\RedirectResponse */ + #[\Override] public function store( Request $request, mixed $callback = null, ): \Illuminate\Http\RedirectResponse { - return parent::store($request, function ($request, $user) { + return parent::store($request, function ($request, $user): void { $validatedData = $request->validated(); $user->sites()->syncWithoutDetaching(Arr::get($validatedData, 'sites')); if (Arr::get($validatedData, 'gitlab_id')) { @@ -41,12 +44,13 @@ class UserController extends BackendUserController * @param mixed $callback * @return \Illuminate\Http\RedirectResponse */ + #[\Override] public function update( Request $request, mixed $user, mixed $callback = null, ): \Illuminate\Http\RedirectResponse { - return parent::update($request, $user, function ($request, $user) { + return parent::update($request, $user, function ($request, $user): void { $validatedData = $request->validated(); $user->sites()->sync(Arr::get($validatedData, 'sites')); if (Arr::get($validatedData, 'gitlab_id')) { @@ -59,4 +63,6 @@ class UserController extends BackendUserController } }); } + + // phpcs:enable } diff --git a/app/Http/Requests/Auth/ForgotPasswordRequest.php b/app/Http/Requests/Auth/ForgotPasswordRequest.php index 3475921..be55615 100644 --- a/app/Http/Requests/Auth/ForgotPasswordRequest.php +++ b/app/Http/Requests/Auth/ForgotPasswordRequest.php @@ -26,6 +26,7 @@ class ForgotPasswordRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Auth/LoginRequest.php b/app/Http/Requests/Auth/LoginRequest.php index 1e844cd..5a7fadf 100644 --- a/app/Http/Requests/Auth/LoginRequest.php +++ b/app/Http/Requests/Auth/LoginRequest.php @@ -44,6 +44,7 @@ class LoginRequest extends BackendLoginRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Auth/ResetPasswordRequest.php b/app/Http/Requests/Auth/ResetPasswordRequest.php index 005a2d9..8e07f5c 100644 --- a/app/Http/Requests/Auth/ResetPasswordRequest.php +++ b/app/Http/Requests/Auth/ResetPasswordRequest.php @@ -36,6 +36,7 @@ class ResetPasswordRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/Brands/StoreBrandRequest.php b/app/Http/Requests/Back/Brands/StoreBrandRequest.php index 2107e9f..c64a28a 100644 --- a/app/Http/Requests/Back/Brands/StoreBrandRequest.php +++ b/app/Http/Requests/Back/Brands/StoreBrandRequest.php @@ -40,6 +40,7 @@ class StoreBrandRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/InvoiceCompanies/StoreInvoiceCompanyRequest.php b/app/Http/Requests/Back/InvoiceCompanies/StoreInvoiceCompanyRequest.php index caeed75..d65a303 100644 --- a/app/Http/Requests/Back/InvoiceCompanies/StoreInvoiceCompanyRequest.php +++ b/app/Http/Requests/Back/InvoiceCompanies/StoreInvoiceCompanyRequest.php @@ -38,6 +38,7 @@ class StoreInvoiceCompanyRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/InvoiceCompanies/UpdateInvoiceCompanyRequest.php b/app/Http/Requests/Back/InvoiceCompanies/UpdateInvoiceCompanyRequest.php index af417cd..8efb54f 100644 --- a/app/Http/Requests/Back/InvoiceCompanies/UpdateInvoiceCompanyRequest.php +++ b/app/Http/Requests/Back/InvoiceCompanies/UpdateInvoiceCompanyRequest.php @@ -14,6 +14,7 @@ class UpdateInvoiceCompanyRequest extends StoreInvoiceCompanyRequest * * @return boolean */ + #[\Override] public function authorize(): bool { return Gate::check('update', $this->route('invoice_company')); diff --git a/app/Http/Requests/Back/InvoicePackages/StoreInvoicePackageRequest.php b/app/Http/Requests/Back/InvoicePackages/StoreInvoicePackageRequest.php index c546d09..fa2eb8e 100644 --- a/app/Http/Requests/Back/InvoicePackages/StoreInvoicePackageRequest.php +++ b/app/Http/Requests/Back/InvoicePackages/StoreInvoicePackageRequest.php @@ -40,6 +40,7 @@ class StoreInvoicePackageRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/InvoicePackages/UpdateInvoicePackageRequest.php b/app/Http/Requests/Back/InvoicePackages/UpdateInvoicePackageRequest.php index 0f4b13e..c4d8105 100644 --- a/app/Http/Requests/Back/InvoicePackages/UpdateInvoicePackageRequest.php +++ b/app/Http/Requests/Back/InvoicePackages/UpdateInvoicePackageRequest.php @@ -14,6 +14,7 @@ class UpdateInvoicePackageRequest extends StoreInvoicePackageRequest * * @return boolean */ + #[\Override] public function authorize(): bool { return Gate::check('update', $this->route('invoice_package')); diff --git a/app/Http/Requests/Back/Notices/StoreNoticeRequest.php b/app/Http/Requests/Back/Notices/StoreNoticeRequest.php index a8d59bc..dac4d71 100644 --- a/app/Http/Requests/Back/Notices/StoreNoticeRequest.php +++ b/app/Http/Requests/Back/Notices/StoreNoticeRequest.php @@ -43,6 +43,7 @@ class StoreNoticeRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/Notices/UpdateNoticeRequest.php b/app/Http/Requests/Back/Notices/UpdateNoticeRequest.php index 8cd40a5..c54c141 100644 --- a/app/Http/Requests/Back/Notices/UpdateNoticeRequest.php +++ b/app/Http/Requests/Back/Notices/UpdateNoticeRequest.php @@ -14,6 +14,7 @@ class UpdateNoticeRequest extends StoreNoticeRequest * * @return boolean */ + #[\Override] public function authorize(): bool { return Gate::check('update', $this->route('notice')); diff --git a/app/Http/Requests/Back/Sites/StoreSiteRequest.php b/app/Http/Requests/Back/Sites/StoreSiteRequest.php index 51ee9ce..d05f182 100644 --- a/app/Http/Requests/Back/Sites/StoreSiteRequest.php +++ b/app/Http/Requests/Back/Sites/StoreSiteRequest.php @@ -26,16 +26,17 @@ class StoreSiteRequest extends FormRequest * * @return void */ + #[\Override] protected function prepareForValidation(): void { $this->merge([ 'project_manager_id' => is_array($this->project_manager_id) - ? intval($this->project_manager_id[0]) ?? null + ? intval($this->project_manager_id[0]) : $this->project_manager_id, 'gitlab_project_id' => is_array($this->gitlab_project_id) - ? intval($this->gitlab_project_id[0]) ?? null + ? intval($this->gitlab_project_id[0]) : $this->gitlab_project_id, - 'users' => is_array($this->users) ? array_map('intval', $this->users) : $this->users, + 'users' => is_array($this->users) ? array_map(intval(...), $this->users) : $this->users, ]); } @@ -62,6 +63,7 @@ class StoreSiteRequest extends FormRequest * * @return array */ + #[\Override] public function attributes(): array { return [ diff --git a/app/Http/Requests/Back/Users/Concerns/HasUserRequestRules.php b/app/Http/Requests/Back/Users/Concerns/HasUserRequestRules.php index 9a9fac3..c917db9 100644 --- a/app/Http/Requests/Back/Users/Concerns/HasUserRequestRules.php +++ b/app/Http/Requests/Back/Users/Concerns/HasUserRequestRules.php @@ -1,4 +1,5 @@ trans_choice('models.classes.sites', \INF), ]; } -} \ No newline at end of file +} diff --git a/app/Mails/Auth/ResetPassword.php b/app/Mails/Auth/ResetPassword.php index 060142c..55c6a9b 100644 --- a/app/Mails/Auth/ResetPassword.php +++ b/app/Mails/Auth/ResetPassword.php @@ -12,7 +12,7 @@ class ResetPassword extends Mailable /** * @var \App\Models\User $user */ - private User $user; + private readonly User $user; /** * Create a new message instance. @@ -33,7 +33,7 @@ class ResetPassword extends Mailable public function envelope(): \Illuminate\Mail\Mailables\Envelope { return new Envelope( - to: $this->user->getEmailForPasswordReset(), + to: [$this->user->getEmailForPasswordReset()], subject: sprintf( '%s - %s', trans('auth.email_title_reset_complete'), diff --git a/app/Models/Brand.php b/app/Models/Brand.php index 7152ce5..20a793a 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -32,6 +32,7 @@ class Brand extends Model * * @var list */ + #[\Override] protected $fillable = [ 'name', ]; @@ -46,20 +47,20 @@ class Brand extends Model ]; /** - * Relations should be included in the cache. + * Get relations to include in the cache. * - * @var list + * @return list */ - public static $cacheRelations = [ - 'sites', - ]; + public static function getCacheRelations(): array + { + return ['sites']; + } // * RELATIONS. - /** * Get sites associated to the brand. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site> + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'> */ public function sites(): \Illuminate\Database\Eloquent\Relations\MorphToMany { diff --git a/app/Models/GitlabIssue.php b/app/Models/GitlabIssue.php index 7f8b368..fcdc088 100644 --- a/app/Models/GitlabIssue.php +++ b/app/Models/GitlabIssue.php @@ -40,6 +40,7 @@ class GitlabIssue extends Model implements TranslatableModel * * @var list */ + #[\Override] protected $fillable = [ "title", "url", @@ -70,6 +71,7 @@ class GitlabIssue extends Model implements TranslatableModel * * @var array */ + #[\Override] protected $casts = [ 'is_closed' => 'boolean', ]; @@ -79,12 +81,13 @@ class GitlabIssue extends Model implements TranslatableModel * * @return void */ + #[\Override] protected static function booted(): void { - static::creating(function (self $model) { + static::creating(function (self $model): void { self::manageFields($model); }); - static::updating(function (self $model) { + static::updating(function (self $model): void { self::manageFields($model); }); } diff --git a/app/Models/GitlabIssueLabel.php b/app/Models/GitlabIssueLabel.php index c4dfe4d..bf290b3 100644 --- a/app/Models/GitlabIssueLabel.php +++ b/app/Models/GitlabIssueLabel.php @@ -24,6 +24,7 @@ class GitlabIssueLabel extends Model * * @var string|null */ + #[\Override] protected $table = 'gitlab_issues_labels'; /** @@ -31,6 +32,7 @@ class GitlabIssueLabel extends Model * * @var list */ + #[\Override] protected $fillable = [ 'issue_id', 'label_id', diff --git a/app/Models/GitlabLabel.php b/app/Models/GitlabLabel.php index 77bc446..f016948 100644 --- a/app/Models/GitlabLabel.php +++ b/app/Models/GitlabLabel.php @@ -29,6 +29,7 @@ class GitlabLabel extends Model implements TranslatableModel * * @var list */ + #[\Override] protected $fillable = [ 'name', 'gitlab_id', @@ -48,12 +49,13 @@ class GitlabLabel extends Model implements TranslatableModel * * @return void */ + #[\Override] protected static function booted(): void { - static::creating(function (self $model) { + static::creating(function (self $model): void { self::manageFields($model); }); - static::updating(function (self $model) { + static::updating(function (self $model): void { self::manageFields($model); }); } diff --git a/app/Models/GitlabMilestone.php b/app/Models/GitlabMilestone.php index d57ffd1..52c037a 100644 --- a/app/Models/GitlabMilestone.php +++ b/app/Models/GitlabMilestone.php @@ -37,6 +37,7 @@ class GitlabMilestone extends Model implements TranslatableModel * * @var list */ + #[\Override] protected $fillable = [ "title", "url", @@ -64,6 +65,7 @@ class GitlabMilestone extends Model implements TranslatableModel * * @var array */ + #[\Override] protected $casts = [ 'is_closed' => 'boolean', ]; @@ -73,12 +75,13 @@ class GitlabMilestone extends Model implements TranslatableModel * * @return void */ + #[\Override] protected static function booted(): void { - static::creating(function (self $model) { + static::creating(function (self $model): void { self::manageFields($model); }); - static::updating(function (self $model) { + static::updating(function (self $model): void { self::manageFields($model); }); } diff --git a/app/Models/GitlabProject.php b/app/Models/GitlabProject.php index 7146b9a..a146a3d 100644 --- a/app/Models/GitlabProject.php +++ b/app/Models/GitlabProject.php @@ -31,6 +31,7 @@ class GitlabProject extends Model implements TranslatableModel * * @var list */ + #[\Override] protected $fillable = [ 'name', 'url', @@ -52,6 +53,7 @@ class GitlabProject extends Model implements TranslatableModel * * @var array */ + #[\Override] protected $casts = [ 'is_archived' => 'boolean', ]; @@ -61,12 +63,13 @@ class GitlabProject extends Model implements TranslatableModel * * @return void */ + #[\Override] protected static function booted(): void { - static::creating(function (self $model) { + static::creating(function (self $model): void { self::manageFields($model); }); - static::updating(function (self $model) { + static::updating(function (self $model): void { self::manageFields($model); }); } diff --git a/app/Models/GitlabUser.php b/app/Models/GitlabUser.php index 876e911..6f0207b 100644 --- a/app/Models/GitlabUser.php +++ b/app/Models/GitlabUser.php @@ -30,10 +30,10 @@ class GitlabUser extends Model /** * Get user of the gitlab id. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User,\App\Models\GitlabUser> + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User,$this> */ public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo { return $this->belongsTo(User::class); } -} \ No newline at end of file +} diff --git a/app/Models/InvoiceCompany.php b/app/Models/InvoiceCompany.php index c1520d1..8481a8e 100644 --- a/app/Models/InvoiceCompany.php +++ b/app/Models/InvoiceCompany.php @@ -32,6 +32,7 @@ class InvoiceCompany extends Model * * @var list */ + #[\Override] protected $fillable = [ 'name', ]; diff --git a/app/Models/InvoicePackage.php b/app/Models/InvoicePackage.php index 33129bc..e02d0cb 100644 --- a/app/Models/InvoicePackage.php +++ b/app/Models/InvoicePackage.php @@ -34,6 +34,7 @@ class InvoicePackage extends Model * * @var list */ + #[\Override] protected $fillable = [ 'name', 'amount', @@ -45,6 +46,7 @@ class InvoicePackage extends Model * * @var array */ + #[\Override] protected $casts = [ 'published' => 'boolean', ]; diff --git a/app/Models/Notice.php b/app/Models/Notice.php index 27184a0..9480e74 100644 --- a/app/Models/Notice.php +++ b/app/Models/Notice.php @@ -35,6 +35,7 @@ class Notice extends Model * * @var list */ + #[\Override] protected $fillable = [ 'title', 'message', @@ -46,6 +47,7 @@ class Notice extends Model * * @var array */ + #[\Override] protected $casts = [ 'type' => NoticeTypeEnum::class, ]; diff --git a/app/Models/Site.php b/app/Models/Site.php index d0fa2f5..1fec88e 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -36,6 +36,7 @@ class Site extends Model * * @var list */ + #[\Override] protected $fillable = [ 'name', 'url_re7', @@ -53,17 +54,6 @@ class Site extends Model 'name', ]; - /** - * Relations should be included in the cache. - * - * @var list - */ - public static $cacheRelations = [ - 'projectManager', - 'gitlabProject', - 'users', - ]; - /** * Perform any actions required after the model boots. * @@ -72,7 +62,7 @@ class Site extends Model #[\Override] protected static function booted(): void { - $assertUrls = function (self $model) { + $assertUrls = function (self $model): void { if ($model->url_re7) { ToolboxHelper::assertNoInternalUrls('url_re7', $model->url_re7); } @@ -85,12 +75,22 @@ class Site extends Model static::updating($assertUrls); } + /** + * Get relations to include in the cache. + * + * @return list + */ + public static function getCacheRelations(): array + { + return ['projectManager', 'gitlabProject', 'users']; + } + // * RELATIONS. /** * Get users associated to the site. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\User> + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\User,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'> */ public function users(): \Illuminate\Database\Eloquent\Relations\MorphToMany { @@ -106,7 +106,7 @@ class Site extends Model /** * Get brands associated to the site. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Brand> + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Brand,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'> */ public function brands(): \Illuminate\Database\Eloquent\Relations\MorphToMany { @@ -122,7 +122,7 @@ class Site extends Model /** * Get project manager of the site. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User,\App\Models\Site> + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\User,$this> */ public function projectManager(): \Illuminate\Database\Eloquent\Relations\BelongsTo { @@ -132,7 +132,7 @@ class Site extends Model /** * Get project manager of the site. * - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\GitlabProject,\App\Models\Site> + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\GitlabProject,$this> */ public function gitlabProject(): \Illuminate\Database\Eloquent\Relations\BelongsTo { diff --git a/app/Models/User.php b/app/Models/User.php index 75e8cd9..e73db34 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -12,24 +12,16 @@ use Uwil\LaravelBackend\Models\User as BackendUser; /** * Extends the package User model with some additionnal data. * - * @property-read \App\Models\UserPassword|null $userPassword User's associated password. - * @property-read \App\Models\GitlabUser|null $gitlabUser User's associated gitlab id. - * @property-read \App\Models\Site|null $sites User's associated sites. + * @property-read \App\Models\UserPassword|null $userPassword + * User's associated password. + * @property-read \App\Models\GitlabUser|null $gitlabUser + * User's associated gitlab id. + * @property-read \Illuminate\Database\Eloquent\Collection $sites + * User's associated sites. * @see \Uwil\LaravelBackend\Models\User For all other properties and methods. */ class User extends BackendUser { - /** - * Relations should be included in the cache. - * - * @var list - */ - #[\Override] - public static $cacheRelations = [ - 'gitlabUser', - 'sites', - ]; - /** * Except some fields to the user model fill. * @@ -42,12 +34,23 @@ class User extends BackendUser ]; /** - * Relations should be share to views. + * Get relations to include in the cache. * - * @return array + * @return list */ #[\Override] - public static function propsRelations(): array + public static function getCacheRelations(): array + { + return ['gitlabUser', 'sites']; + } + + /** + * Relations should be share to views. + * + * @return array + */ + #[\Override] + public static function getPropsRelations(): array { return [ 'gitlabUser', @@ -72,12 +75,12 @@ class User extends BackendUser * * @param string $token * @return void + * @phpcs:disable */ - // phpstan-ignore-next-line - // phpcs:ignore #[\Override] public function sendPasswordResetNotification($token): void { + // @phpcs:enable $url = sprintf( "%s?email=%s", url(route(config('uwil-backend.routes.name') . 'reset-password', ['token' => $token], false)), @@ -92,7 +95,7 @@ class User extends BackendUser /** * Get the user's associated password. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\UserPassword,\App\Models\User> + * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\UserPassword,$this> */ public function userPassword(): \Illuminate\Database\Eloquent\Relations\HasOne { @@ -102,7 +105,7 @@ class User extends BackendUser /** * Get the user's associated gitlab id. * - * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\GitlabUser,\App\Models\User> + * @return \Illuminate\Database\Eloquent\Relations\HasOne<\App\Models\GitlabUser,$this> */ public function gitlabUser(): \Illuminate\Database\Eloquent\Relations\HasOne { @@ -112,7 +115,7 @@ class User extends BackendUser /** * Get sites associated to the user. * - * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site> + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany<\App\Models\Site,$this,\Illuminate\Database\Eloquent\Relations\MorphPivot,'pivot'> */ public function sites(): \Illuminate\Database\Eloquent\Relations\MorphToMany { diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index b700654..dac10d5 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,9 +4,6 @@ namespace App\Providers; use App\Enums\NoticeTypeEnum; use App\Models\Brand; -use App\Models\GitlabIssue; -use App\Models\GitlabLabel; -use App\Models\GitlabProject; use App\Models\InvoiceCompany; use App\Models\InvoicePackage; use App\Models\Notice; diff --git a/bootstrap/app.php b/bootstrap/app.php index d5bb2a9..b5875ea 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,18 +14,14 @@ return Application::configure(basePath: dirname(__DIR__)) ->withRouting( health: '/up', web: __DIR__ . '/../routes/auth.php', - then: function () { + then: function (): void { Route::middleware(['web', 'throttle:5,2']) - ->post('/csp-report', function () { + ->post('/csp-report', function (): void { $isCspRequest = request()->header('Content-Type') === 'application/csp-report'; - if (!$isCspRequest or !request()->json('csp-report') or !is_array(request()->json('csp-report'))) { - abort(401); - } + abort_if(!$isCspRequest or !request()->json('csp-report') or !is_array(request()->json('csp-report')), 401); // * Flatten if needed. $cspReport = collect(request()->json('csp-report')) - ->flatMap(function ($v, $k) { - return [$k => is_array($v) ? collect($v)->flatten()->implode(', ') : $v]; - })->all(); + ->flatMap(fn($v, $k) => [$k => is_array($v) ? collect($v)->flatten()->implode(', ') : $v])->all(); // * Filter array keys. $cspReport = collect(array_intersect_key($cspReport, [ 'blocked-uri' => '', @@ -42,7 +38,7 @@ return Application::configure(basePath: dirname(__DIR__)) })->name('cspReportUri'); } ) - ->withMiddleware(function (Middleware $middleware) { + ->withMiddleware(function (Middleware $middleware): void { $middleware->web(append: [ \Uwil\LaravelI18n\Middlewares\ForceLocale::class, \Uwil\LaravelCommon\Middlewares\HandleInertiaRequests::class, @@ -61,7 +57,7 @@ return Application::configure(basePath: dirname(__DIR__)) 'guest' => \Uwil\LaravelBackend\Middlewares\RedirectIfAuthenticated::class, ]); }) - ->withExceptions(function (Exceptions $exceptions) { + ->withExceptions(function (Exceptions $exceptions): void { $exceptions->render(function (HttpException $e, Request $request) { $status = $e->getStatusCode(); return InertiaHelper::errorRender($request, $status); @@ -69,9 +65,9 @@ return Application::configure(basePath: dirname(__DIR__)) /** * Automatic exception capture with Sentry. */ - $exceptions->report(function (Throwable $e) { + $exceptions->report(function (Throwable $e): void { if (app()->bound('sentry')) { - app('sentry')->captureException($e); + resolve('sentry')->captureException($e); } }); /** diff --git a/composer.json b/composer.json index 2993ec7..f74cc5f 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,12 @@ "uwil/laravel-common": "^6.0" }, "require-dev": { + "driftingly/rector-laravel": "^2.4", "fakerphp/faker": "^1.23", "larastan/larastan": "^3.4", "laravel/breeze": "^2.3.0", "laravel/pail": "^1.2.5", - "laravel/pint": "^1.27", + "laravel/pint": "^1.29", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.6", "phpunit/phpunit": "^12.5.12", @@ -110,6 +111,15 @@ ], "pre-package-uninstall": [ "Illuminate\\Foundation\\ComposerScripts::prePackageUninstall" + ], + "phpcs": [ + "./vendor/bin/phpcs" + ], + "phpstan": [ + "./vendor/bin/phpstan" + ], + "rector": [ + "./vendor/bin/rector" ] }, "extra": { diff --git a/composer.lock b/composer.lock index 2f31974..2e97f75 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c7008e1b25e55e3dd4f28ec944534e12", + "content-hash": "82b81a0508a8c9794eef9c3cade56489", "packages": [ { "name": "brick/math", @@ -7567,7 +7567,7 @@ "dist": { "type": "path", "url": "packages/laravel-activity-logs", - "reference": "988e15d19ea29ad3f9b077057330f226dc963d29" + "reference": "6179ca66e6b5a2391114b3775ac13df3888b074f" }, "require": { "illuminate/support": "~13", @@ -7635,7 +7635,7 @@ "dist": { "type": "path", "url": "packages/laravel-backend", - "reference": "cabc9caa919d4fdcb509558f631416fbdafcc7d2" + "reference": "d398fb4df7c3ff2665daf3a09d61002c3cdb05af" }, "require": { "diglactic/laravel-breadcrumbs": "^10.0", @@ -7714,7 +7714,7 @@ "dist": { "type": "path", "url": "packages/laravel-common", - "reference": "db3afe457554ee103cac4a92cf601dc6a39780b1" + "reference": "0f14d0137c86569421b672712634a3ea69216764" }, "require": { "diglactic/laravel-breadcrumbs": "^10.0", @@ -7794,7 +7794,7 @@ "dist": { "type": "path", "url": "packages/laravel-i18n", - "reference": "1d14e78522ec29cf95897fbeb1bd0ffd5279c93a" + "reference": "288486ca3c34c4f84b7b18e02558a07dfb82f26d" }, "require": { "illuminate/support": "~13", @@ -8113,6 +8113,42 @@ ], "time": "2025-11-11T04:32:07+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "5342df61b0a77e5a408744e5686d80a51a07a48d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/5342df61b0a77e5a408744e5686d80a51a07a48d", + "reference": "5342df61b0a77e5a408744e5686d80a51a07a48d", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "rector/rector": "^2.2.7", + "webmozart/assert": "^1.11 || ^2.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/2.4.0" + }, + "time": "2026-05-22T18:34:15+00:00" + }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -9530,6 +9566,66 @@ ], "time": "2026-04-18T06:12:49+00:00" }, + { + "name": "rector/rector", + "version": "2.4.4", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "4661c582a20f03df585d2e3fdc4af1b83d67a091" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/4661c582a20f03df585d2e3fdc4af1b83d67a091", + "reference": "4661c582a20f03df585d2e3fdc4af1b83d67a091", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.48" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "homepage": "https://getrector.com/", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.4.4" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2026-05-20T19:30:21+00:00" + }, { "name": "sebastian/cli-parser", "version": "4.2.0", @@ -10672,6 +10768,72 @@ } ], "time": "2025-12-08T11:19:18+00:00" + }, + { + "name": "webmozart/assert", + "version": "2.4.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "9007ea6f45ecf352a9422b36644e4bfc039b9155" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/9007ea6f45ecf352a9422b36644e4bfc039b9155", + "reference": "9007ea6f45ecf352a9422b36644e4bfc039b9155", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-date": "*", + "ext-filter": "*", + "php": "^8.2" + }, + "suggest": { + "ext-intl": "", + "ext-simplexml": "", + "ext-spl": "" + }, + "type": "library", + "extra": { + "psalm": { + "pluginClass": "Webmozart\\Assert\\PsalmPlugin" + }, + "branch-alias": { + "dev-master": "2.0-dev", + "dev-feature/2-0": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + }, + { + "name": "Woody Gilk", + "email": "woody.gilk@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/2.4.0" + }, + "time": "2026-05-20T13:07:01+00:00" } ], "aliases": [], diff --git a/config/app.php b/config/app.php index cda0231..7bd635b 100644 --- a/config/app.php +++ b/config/app.php @@ -101,7 +101,7 @@ return [ 'previous_keys' => [ ...array_filter( - explode(',', env('APP_PREVIOUS_KEYS', '')) + explode(',', (string) env('APP_PREVIOUS_KEYS', '')) ), ], diff --git a/config/database.php b/config/database.php index 8342fc8..a94712c 100644 --- a/config/database.php +++ b/config/database.php @@ -59,10 +59,7 @@ return [ 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ - (PHP_VERSION_ID >= 80500 - ? \Pdo\Mysql::ATTR_SSL_CA - : \PDO::MYSQL_ATTR_SSL_CA - ) => env('MYSQL_ATTR_SSL_CA'), + \Pdo\Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], @@ -82,10 +79,7 @@ return [ 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ - (PHP_VERSION_ID >= 80500 - ? \Pdo\Mysql::ATTR_SSL_CA - : \PDO::MYSQL_ATTR_SSL_CA - ) => env('MYSQL_ATTR_SSL_CA'), + \Pdo\Mysql::ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], diff --git a/database/factories/BrandFactory.php b/database/factories/BrandFactory.php index bf17cf2..e0c9689 100644 --- a/database/factories/BrandFactory.php +++ b/database/factories/BrandFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating Brand model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Brand> */ class BrandFactory extends Factory { @@ -15,6 +17,7 @@ class BrandFactory extends Factory * * @var class-string<\App\Models\Brand> */ + #[\Override] protected $model = Brand::class; /** diff --git a/database/factories/GitlabIssueFactory.php b/database/factories/GitlabIssueFactory.php index 5aa4bfd..644e543 100644 --- a/database/factories/GitlabIssueFactory.php +++ b/database/factories/GitlabIssueFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating GitlabIssue model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GitlabIssue> */ class GitlabIssueFactory extends Factory { @@ -15,6 +17,7 @@ class GitlabIssueFactory extends Factory * * @var class-string<\App\Models\GitlabIssue> */ + #[\Override] protected $model = GitlabIssue::class; /** diff --git a/database/factories/GitlabIssueLabelFactory.php b/database/factories/GitlabIssueLabelFactory.php index f86b7ad..541210e 100644 --- a/database/factories/GitlabIssueLabelFactory.php +++ b/database/factories/GitlabIssueLabelFactory.php @@ -9,6 +9,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating GitlabIssueLabel model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GitlabIssueLabel> */ class GitlabIssueLabelFactory extends Factory { @@ -17,6 +19,7 @@ class GitlabIssueLabelFactory extends Factory * * @var class-string<\App\Models\GitlabIssueLabel> */ + #[\Override] protected $model = GitlabIssueLabel::class; /** diff --git a/database/factories/GitlabLabelFactory.php b/database/factories/GitlabLabelFactory.php index 75d63e2..538d808 100644 --- a/database/factories/GitlabLabelFactory.php +++ b/database/factories/GitlabLabelFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating GitlabLabel model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GitlabLabel> */ class GitlabLabelFactory extends Factory { @@ -15,6 +17,7 @@ class GitlabLabelFactory extends Factory * * @var class-string<\App\Models\GitlabLabel> */ + #[\Override] protected $model = GitlabLabel::class; /** diff --git a/database/factories/GitlabMilestoneFactory.php b/database/factories/GitlabMilestoneFactory.php index 2073caa..9987cad 100644 --- a/database/factories/GitlabMilestoneFactory.php +++ b/database/factories/GitlabMilestoneFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating GitlabMilestone model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GitlabMilestone> */ class GitlabMilestoneFactory extends Factory { @@ -15,6 +17,7 @@ class GitlabMilestoneFactory extends Factory * * @var class-string<\App\Models\GitlabMilestone> */ + #[\Override] protected $model = GitlabMilestone::class; /** diff --git a/database/factories/GitlabProjectFactory.php b/database/factories/GitlabProjectFactory.php index 61ed011..7e432e4 100644 --- a/database/factories/GitlabProjectFactory.php +++ b/database/factories/GitlabProjectFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating GitlabProject model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\GitlabProject> */ class GitlabProjectFactory extends Factory { @@ -15,6 +17,7 @@ class GitlabProjectFactory extends Factory * * @var class-string<\App\Models\GitlabProject> */ + #[\Override] protected $model = GitlabProject::class; /** diff --git a/database/factories/InvoiceCompanyFactory.php b/database/factories/InvoiceCompanyFactory.php index cbeff38..35dc176 100644 --- a/database/factories/InvoiceCompanyFactory.php +++ b/database/factories/InvoiceCompanyFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating InvoiceCompany model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\InvoiceCompany> */ class InvoiceCompanyFactory extends Factory { @@ -15,6 +17,7 @@ class InvoiceCompanyFactory extends Factory * * @var class-string<\App\Models\InvoiceCompany> */ + #[\Override] protected $model = InvoiceCompany::class; /** diff --git a/database/factories/InvoicePackageFactory.php b/database/factories/InvoicePackageFactory.php index 8ffc5ae..fe409f1 100644 --- a/database/factories/InvoicePackageFactory.php +++ b/database/factories/InvoicePackageFactory.php @@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating InvoicePackage model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\InvoicePackage> */ class InvoicePackageFactory extends Factory { @@ -15,6 +17,7 @@ class InvoicePackageFactory extends Factory * * @var class-string<\App\Models\InvoicePackage> */ + #[\Override] protected $model = InvoicePackage::class; /** diff --git a/database/factories/NoticeFactory.php b/database/factories/NoticeFactory.php index 19eb9b3..2c28300 100644 --- a/database/factories/NoticeFactory.php +++ b/database/factories/NoticeFactory.php @@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Factories\Factory; /** * Factory for generating Notice model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Notice> */ class NoticeFactory extends Factory { @@ -16,6 +18,7 @@ class NoticeFactory extends Factory * * @var class-string<\App\Models\Notice> */ + #[\Override] protected $model = Notice::class; /** @@ -27,7 +30,7 @@ class NoticeFactory extends Factory { return [ "title" => fake()->words(3, true), - "message" => sprintf("

%s

", fake()->text(\rand(20, 40))), + "message" => sprintf("

%s

", fake()->text(random_int(20, 40))), "type" => fake()->randomElement(NoticeTypeEnum::cases()), ]; } diff --git a/database/factories/SiteFactory.php b/database/factories/SiteFactory.php index 025c3ad..4302e18 100644 --- a/database/factories/SiteFactory.php +++ b/database/factories/SiteFactory.php @@ -10,6 +10,8 @@ use Uwil\LaravelBackend\Support\UserRoleRegistry; /** * Factory for generating Site model instances with randomized data. + * + * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Site> */ class SiteFactory extends Factory { @@ -18,6 +20,7 @@ class SiteFactory extends Factory * * @var class-string<\App\Models\Site> */ + #[\Override] protected $model = Site::class; /** diff --git a/database/migrations/2026_04_30_123018_create_notices_table.php b/database/migrations/2026_04_30_123018_create_notices_table.php index 98b2d5a..880b419 100644 --- a/database/migrations/2026_04_30_123018_create_notices_table.php +++ b/database/migrations/2026_04_30_123018_create_notices_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('notices', function (Blueprint $table) { + Schema::create('notices', function (Blueprint $table): void { $table->id()->comment('Id of the notice.'); $table->string('title')->comment('Title of the notice.'); $table->text('message')->comment('Message of the notice.'); diff --git a/database/migrations/2026_04_30_145058_create_invoice_packages_table.php b/database/migrations/2026_04_30_145058_create_invoice_packages_table.php index 808de9d..81f0c70 100644 --- a/database/migrations/2026_04_30_145058_create_invoice_packages_table.php +++ b/database/migrations/2026_04_30_145058_create_invoice_packages_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('invoice_packages', function (Blueprint $table) { + Schema::create('invoice_packages', function (Blueprint $table): void { $table->id()->comment('Id of the invoice package.'); $table->string('name')->comment('Name of the invoice package.'); $table->double('amount')->comment('Amount of the invoice package.'); diff --git a/database/migrations/2026_04_30_154432_create_invoice_companies_table.php b/database/migrations/2026_04_30_154432_create_invoice_companies_table.php index 6c81bb8..ead823d 100644 --- a/database/migrations/2026_04_30_154432_create_invoice_companies_table.php +++ b/database/migrations/2026_04_30_154432_create_invoice_companies_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('invoice_companies', function (Blueprint $table) { + Schema::create('invoice_companies', function (Blueprint $table): void { $table->id()->comment('Id of the invoice company.'); $table->string('name')->comment('Name of the invoice company.'); $table->timestamp('created_at')->nullable()->comment('Date the invoice company was created.'); diff --git a/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php b/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php index 70bdda1..098e4e7 100644 --- a/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php +++ b/database/migrations/2026_04_30_155423_create_gitlab_projects_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_projects', function (Blueprint $table) { + Schema::create('gitlab_projects', function (Blueprint $table): void { $table->id()->comment('Primary key of the gitlab project relation.'); $table->string('name')->comment('Name of the gitlab project.'); $table->string('url')->unique()->comment('Url of the gitlab project.'); diff --git a/database/migrations/2026_04_30_160235_create_sites_table.php b/database/migrations/2026_04_30_160235_create_sites_table.php index c065866..9c448b6 100644 --- a/database/migrations/2026_04_30_160235_create_sites_table.php +++ b/database/migrations/2026_04_30_160235_create_sites_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('sites', function (Blueprint $table) { + Schema::create('sites', function (Blueprint $table): void { $table->id()->comment('Id of the site.'); $table->string('name')->unique()->comment('Name of the site.'); $table->string('url_re7')->unique()->nullable()->comment('Re7 url of the site.'); diff --git a/database/migrations/2026_05_18_141028_create_sitables_table.php b/database/migrations/2026_05_18_141028_create_sitables_table.php index 5bb7d56..beffd28 100644 --- a/database/migrations/2026_05_18_141028_create_sitables_table.php +++ b/database/migrations/2026_05_18_141028_create_sitables_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('sitables', function (Blueprint $table) { + Schema::create('sitables', function (Blueprint $table): void { $table->id()->comment('Primary key of the site relation.'); $table->unsignedBigInteger('site_id')->comment('Primary key of the site.'); $table->unsignedBigInteger('sitable_id')->comment('Primary key of the associated model.'); diff --git a/database/migrations/2026_05_19_144844_create_brands_table.php b/database/migrations/2026_05_19_144844_create_brands_table.php index 7e883c3..86b0868 100644 --- a/database/migrations/2026_05_19_144844_create_brands_table.php +++ b/database/migrations/2026_05_19_144844_create_brands_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('brands', function (Blueprint $table) { + Schema::create('brands', function (Blueprint $table): void { $table->id()->comment('Id of the brand.'); $table->string('name')->unique()->comment('Name of the brand.'); $table->timestamp('created_at')->nullable()->comment('Date the brand was created.'); diff --git a/database/migrations/2026_05_21_101233_create_gitlab_users_table.php b/database/migrations/2026_05_21_101233_create_gitlab_users_table.php index 44bd612..930d263 100644 --- a/database/migrations/2026_05_21_101233_create_gitlab_users_table.php +++ b/database/migrations/2026_05_21_101233_create_gitlab_users_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_users', function (Blueprint $table) { + Schema::create('gitlab_users', function (Blueprint $table): void { $table->id()->comment('Id of the gitlab user.'); $table->unsignedBigInteger('gitlab_id')->unique()->comment('Gitlab id of the user.'); $table->foreignId('user_id')->unique()->comment('Id of the user.')->constrained()->cascadeOnDelete(); diff --git a/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php b/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php index 67aa2ab..e1b844d 100644 --- a/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php +++ b/database/migrations/2026_05_26_093500_create_gitlab_labels_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_labels', function (Blueprint $table) { + Schema::create('gitlab_labels', function (Blueprint $table): void { $table->id()->comment('Id of the gitlab label.'); $table->string('name')->unique()->comment('Name of the gitlab label.'); $table->unsignedBigInteger('gitlab_id')->unique()->comment('Gitlab id of the gitlab label.'); diff --git a/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php b/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php index 0397a28..935d46a 100644 --- a/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php +++ b/database/migrations/2026_05_26_100638_create_gitlab_issues_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_issues', function (Blueprint $table) { + Schema::create('gitlab_issues', function (Blueprint $table): void { $table->id()->comment('Id of the gitlab issue.'); $table->string('title')->comment('Title of the gitlab issue.'); $table->string('url')->unique()->comment('Url of the gitlab issue.'); diff --git a/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php b/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php index ca0d9c9..448de85 100644 --- a/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php +++ b/database/migrations/2026_05_26_104912_create_gitlab_milestones_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_milestones', function (Blueprint $table) { + Schema::create('gitlab_milestones', function (Blueprint $table): void { $table->id()->comment('Id of the gitlab milestone.'); $table->string('title')->comment('Title of the gitlab milestone.'); $table->string('url')->comment('Url of the gitlab milestone.'); diff --git a/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php b/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php index e28ba19..e283060 100644 --- a/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php +++ b/database/migrations/2026_05_26_110633_create_gitlab_issue_labels_table.php @@ -13,7 +13,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('gitlab_issues_labels', function (Blueprint $table) { + Schema::create('gitlab_issues_labels', function (Blueprint $table): void { $table->id()->comment('Id of the relation.'); $table->foreignId('issue_id')->comment('Gitlab issue id of the relation.') ->constrained('gitlab_issues')->onUpdate('no action')->onDelete('cascade'); diff --git a/phpcs.xml b/phpcs.xml index 10dfcd1..72590c0 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -6,12 +6,11 @@ app/ config/ - database/factories + database/factories/ routes/ */vendor/* - diff --git a/phpstan.neon b/phpstan.neon index 4859286..0707147 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,5 +4,8 @@ includes: parameters: paths: - app/ + - config/ + - database/factories/ + - routes/ level: 7 diff --git a/pint.json b/pint.json new file mode 100644 index 0000000..9856df8 --- /dev/null +++ b/pint.json @@ -0,0 +1,77 @@ +{ + "preset": "laravel", + "rules": { + "indentation_type": true, + "single_line_empty_body": false, + "types_spaces": { + "space": "single", + "space_multiple_catch": "single" + }, + "control_structure_braces": true, + "new_with_parentheses": { + "anonymous_class": true, + "named_class": true + }, + "class_definition": { + "single_item_single_line": false, + "single_line": false, + "space_before_parenthesis": true + }, + "curly_braces_position": { + "allow_single_line_empty_anonymous_classes": false, + "classes_opening_brace": "next_line_unless_newline_at_signature_end", + "anonymous_classes_opening_brace": "next_line_unless_newline_at_signature_end", + "control_structures_opening_brace": "same_line", + "functions_opening_brace": "next_line_unless_newline_at_signature_end", + "anonymous_functions_opening_brace": "same_line" + }, + "binary_operator_spaces": { + "default": "align_single_space_minimal", + "operators": { + "=": "align_single_space", + "|": "single_space", + "=>": "align_single_space", + ".=": "align_single_space" + } + }, + "concat_space": { + "spacing": "one" + }, + "align_multiline_comment": { + "comment_type": "all_multiline" + }, + "array_indentation": true, + "method_chaining_indentation": true, + "statement_indentation": { + "stick_comment_to_next_continuous_control_statement": true + }, + "no_unused_imports": true, + "fully_qualified_strict_types": { + "import_symbols": true, + "leading_backslash_in_global_namespace": true, + "phpdoc_tags": [] + }, + "visibility_required": { + "elements": [ + "const", + "method", + "property" + ] + }, + "no_useless_else": true, + "function_declaration": { + "closure_function_spacing": "one", + "closure_fn_spacing": "one", + "trailing_comma_single_line": false + }, + "single_line_after_imports": true, + "combine_consecutive_issets": true, + "array_syntax": { + "syntax": "short" + }, + "single_quote": true, + "blank_line_after_namespace": true, + "blank_line_after_opening_tag": true, + "declare_strict_types": true + } +} \ No newline at end of file diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..9bbc9ec --- /dev/null +++ b/rector.php @@ -0,0 +1,56 @@ +withSetProviders(LaravelSetProvider::class) + ->withPaths([ + __DIR__ . '/app', + __DIR__ . '/bootstrap', + __DIR__ . '/config', + __DIR__ . '/database', + __DIR__ . '/lang', + __DIR__ . '/routes', + ]) + ->withPhpSets() + ->withComposerBased(laravel: true) + ->withSets([ + LaravelLevelSetList::UP_TO_LARAVEL_130, + LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL, + LaravelSetList::LARAVEL_CODE_QUALITY, + LaravelSetList::LARAVEL_COLLECTION, + LaravelSetList::LARAVEL_IF_HELPERS, + LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES, + LaravelSetList::LARAVEL_TYPE_DECLARATIONS, + ]) + ->withTypeCoverageLevel(0) + ->withDeadCodeLevel(0) + ->withCodeQualityLevel(0) + ->withSkip([ + // Disable Laravel notations. + CommandHiddenPropertyToHiddenAttributeRector::class, + DescriptionPropertyToDescriptionAttributeRector::class, + FillablePropertyToFillableAttributeRector::class, + HiddenPropertyToHiddenAttributeRector::class, + ModelCastsPropertyToCastsMethodRector::class, + SignaturePropertyToSignatureAttributeRector::class, + TablePropertyToTableAttributeRector::class, + WithoutTimestampsPropertyToWithoutTimestampsAttributeRector::class, + + // Validation. + ValidationRuleArrayStringValueToArrayRector::class, + ]); diff --git a/resources/ts/back/Components/Filters/EnumFilter.tsx b/resources/ts/back/Components/Filters/EnumFilter.tsx index 59f0bdf..77f66b2 100644 --- a/resources/ts/back/Components/Filters/EnumFilter.tsx +++ b/resources/ts/back/Components/Filters/EnumFilter.tsx @@ -3,7 +3,7 @@ import { route } from "ziggy-js"; // * Other import EnumSelect from "@/back/Components/Inputs/EnumSelect"; import { LaravelEnum } from "@/types/global"; -import addFilterToUrl from "@/back/lib/filters"; +import AddFilterToUrl from "@/back/lib/filters"; type Props = { enums: LaravelEnum; @@ -35,7 +35,7 @@ function EnumFilter(props: Props) { ...route().params, [name]: selectedStatusName, }; - addFilterToUrl({ modelName, params }); + AddFilterToUrl({ modelName, params }); }} /> ); diff --git a/resources/ts/back/Components/Filters/MultiSelectRelationFilter.tsx b/resources/ts/back/Components/Filters/MultiSelectRelationFilter.tsx index 2da0781..0a77b22 100644 --- a/resources/ts/back/Components/Filters/MultiSelectRelationFilter.tsx +++ b/resources/ts/back/Components/Filters/MultiSelectRelationFilter.tsx @@ -2,7 +2,7 @@ import { route } from "ziggy-js"; // * Other import { ModelSelect } from "@/back/Components/Inputs/ModelSelect"; -import addFilterToUrl from "@/back/lib/filters"; +import AddFilterToUrl from "@/back/lib/filters"; type Props = { fieldName: string; @@ -37,7 +37,7 @@ function MultiSelectRelationFilter(props: Props) { ...route().params, [name]: valuesArray.length ? valuesArray.join(",") : undefined, }; - addFilterToUrl({ modelName, params }); + AddFilterToUrl({ modelName, params }); }} defaultValue={valuesFromUrl} responsive={{ diff --git a/resources/ts/back/Components/Filters/SwitchFilter.tsx b/resources/ts/back/Components/Filters/SwitchFilter.tsx index ab48a14..b1f179b 100644 --- a/resources/ts/back/Components/Filters/SwitchFilter.tsx +++ b/resources/ts/back/Components/Filters/SwitchFilter.tsx @@ -2,7 +2,7 @@ import { route } from "ziggy-js"; // * Other import SimpleSwitch from "@/back/Components/Inputs/SimpleSwitch"; -import addFilterToUrl from "@/back/lib/filters"; +import AddFilterToUrl from "@/back/lib/filters"; type Props = { fieldName: string; @@ -24,7 +24,7 @@ function SwitchFilter(props: Props) { ...route().params, [name]: value, }; - addFilterToUrl({ modelName, params }); + AddFilterToUrl({ modelName, params }); }} /> ); diff --git a/resources/ts/back/Components/Layout/Sidebar/Links/Brands.tsx b/resources/ts/back/Components/Layout/Sidebar/Links/Brands.tsx index 68351ac..5a6bc9d 100644 --- a/resources/ts/back/Components/Layout/Sidebar/Links/Brands.tsx +++ b/resources/ts/back/Components/Layout/Sidebar/Links/Brands.tsx @@ -52,7 +52,10 @@ export default function SidebarLinkBrands( auth.policies.brands.create && (