Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Alexis Gousseau
2609c5e540 fix: 🎨 resolve phpcs and phpstan errors 2025-04-23 12:24:31 +02:00
141 changed files with 1235 additions and 1061 deletions

View file

@ -20,7 +20,7 @@ class CreateUser extends Command
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string|null
*/ */
protected $description = 'Create a user'; protected $description = 'Create a user';
@ -34,21 +34,21 @@ class CreateUser extends Command
/** /**
* The email of the new user. * The email of the new user.
* *
* @var string * @var string|null
*/ */
protected $email; protected $email;
/** /**
* The password of the new user. * The password of the new user.
* *
* @var string * @var string|null
*/ */
protected $password; protected $password;
/** /**
* The role of the new user. * The role of the new user.
* *
* @var integer * @var \App\Enums\Users\RoleEnum|null
*/ */
protected $role; protected $role;
@ -59,7 +59,7 @@ class CreateUser extends Command
*/ */
public function handle() public function handle()
{ {
$this->name = null; $this->name = "";
$this->addName(); $this->addName();
$this->email = null; $this->email = null;
@ -72,10 +72,10 @@ class CreateUser extends Command
$this->addRole(); $this->addRole();
$user = new User([ $user = new User([
'name' => $this->name, 'name' => $this->name,
'email' => $this->email, 'email' => $this->email,
'password' => $this->password, 'password' => $this->password,
'role' => $this->role 'role' => $this->role
]); ]);
$user->saveOrFail(); $user->saveOrFail();
@ -90,7 +90,7 @@ class CreateUser extends Command
*/ */
private function addName(): void private function addName(): void
{ {
while (is_null($this->name)) { while (empty($this->name)) {
try { try {
$tmp = $this->ask('Type the wanted user name', 'Admin'); $tmp = $this->ask('Type the wanted user name', 'Admin');
$validator = Validator::make(['name' => $tmp], [ $validator = Validator::make(['name' => $tmp], [

View file

@ -12,10 +12,12 @@ enum AccountTypeEnum: int
case seo = 1; case seo = 1;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::development->name => "Jours de développement", self::development->name => "Jours de développement",
self::seo->name => "Jours de seo", self::seo->name => "Jours de seo",
]; ];
} }

View file

@ -12,10 +12,12 @@ enum BalanceOperationEnum: int
case debit = 1; case debit = 1;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::credit->name => "Créditer un compte", self::credit->name => "Créditer un compte",
self::debit->name => "Débiter un compte", self::debit->name => "Débiter un compte",
]; ];
} }

View file

@ -13,11 +13,13 @@ enum EstimationStatusEnum: int
case refused = 2; case refused = 2;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::pending->name => "En attente", self::pending->name => "En attente",
self::accepted->name => "Acceptée", self::accepted->name => "Acceptée",
self::refused->name => "Refusée", self::refused->name => "Refusée",
]; ];
} }

View file

@ -1,49 +0,0 @@
<?php
namespace App\Enums\Credit;
use App\Traits\Enums\BaseEnum;
enum EstimationTimeEnum: int
{
use BaseEnum;
case halfHour = 0.0625;
case hour = 0.125;
case hourAndHalf = 0.1875;
case twoHours = 0.25;
case twoHoursAndHalf = 0.3125;
case threeHours = 0.375;
case threeHoursAndHalf = 0.4375;
case fourHours = 0.5;
case fourHoursAndHalf = 0.5625;
case fiveHours = 0.625;
case fiveHoursAndHalf = 0.6875;
case sixHours = 0.75;
case sixHoursAndHalf = 0.8125;
case sevenHours = 0.875;
case sevenHoursAndHalf = 0.9375;
case eightHours = 1;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::halfHour->name => "Une demi-heure",
self::hour->name => "Une heure",
self::hourAndHalf->name => "Une heure et demie",
self::twoHours->name => "Deux heures",
self::twoHoursAndHalf->name => "Deux heures et demie",
self::threeHours->name => "Trois heures",
self::twoHoursAndHalf->name => "Trois heures et demie",
self::fourHours->name => "Quatre heures",
self::fourHoursAndHalf->name => "Quatre heures et demie",
self::fiveHours->name => "Cinq heures",
self::fiveHoursAndHalf->name => "Cinq heures et demie",
self::sixHours->name => "Six heures",
self::sixHoursAndHalf->name => "Six heures et demie",
self::sevenHours->name => "Sept heures",
self::sevenHoursAndHalf->name => "Sept heures et demi",
self::eightHours->name => "Huit heures",
];
}

View file

@ -18,21 +18,21 @@ enum InfoColorsEnum: int
case dark = 7; case dark = 7;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*/ */
private const CLASSES = [ private const CLASSES = [
self::primary->name => "primary", self::primary->name => "primary",
self::secondary->name => "secondary", self::secondary->name => "secondary",
self::success->name => "success", self::success->name => "success",
self::danger->name => "danger", self::danger->name => "danger",
self::warning->name => "warning", self::warning->name => "warning",
self::info->name => "info", self::info->name => "info",
self::light->name => "light", self::light->name => "light",
self::dark->name => "dark", self::dark->name => "dark",
]; ];
/** /**
* Get Class * Get Class.
* *
* @return string * @return string
*/ */
@ -42,7 +42,7 @@ enum InfoColorsEnum: int
} }
/** /**
* Get enum classes * Get enum classes.
* *
* @return array<string> * @return array<string>
*/ */

View file

@ -15,10 +15,12 @@ enum InvoiceStatusEnum: int
/** /**
* Optionnal labels definition. * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::opened->name => "Ouvert (nouveaux ou en cours)", self::opened->name => "Ouvert (nouveaux ou en cours)",
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)", self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
self::canceled->name => "Annulé (supprimé)", self::canceled->name => "Annulé (supprimé)",
self::archived->name => "Archivé (validé et envoyé à la comptabilité)", self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
]; ];

View file

@ -14,41 +14,43 @@ enum TaskTypeEnum: int
case arbitrary = 4; case arbitrary = 4;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::web->name => "Web", self::web->name => "Web",
self::seo->name => "SEO", self::seo->name => "SEO",
self::package->name => "Forfait", self::package->name => "Forfait",
self::arbitrary->name => "Libre", self::arbitrary->name => "Libre",
]; ];
/** /**
* Custom added prices definition * Custom added prices definition.
*/ */
private const PRICES = [ private const PRICES = [
self::web->name => 600, self::web->name => 600,
self::seo->name => 690, self::seo->name => 690,
// * Linked to packages table // * Linked to packages table
self::package->name => 0, self::package->name => 0,
// * Arbitrary number // * Arbitrary number
self::arbitrary->name => 0, self::arbitrary->name => 0,
]; ];
/** /**
* Get Price * Get Price.
* *
* @return string * @return integer
*/ */
public function price(): string public function price(): int
{ {
return self::PRICES[$this->name]; return self::PRICES[$this->name];
} }
/** /**
* Get enum prices * Get enum prices.
* *
* @return array<string> * @return array<string, int>
*/ */
public static function toPrices(): array public static function toPrices(): array
{ {

View file

@ -12,10 +12,12 @@ enum MessageTypeEnum: int
case public = 2; case public = 2;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::private->name => "Privé", self::private->name => "Privé",
self::public->name => "Public", self::public->name => "Public",
]; ];
} }

View file

@ -4,7 +4,7 @@ namespace App\Enums\Tickets;
use App\Traits\Enums\BaseEnum; use App\Traits\Enums\BaseEnum;
enum TicketFileTypeEnum: int enum TicketFileTypeEnum: string
{ {
use BaseEnum; use BaseEnum;
@ -18,7 +18,9 @@ enum TicketFileTypeEnum: int
case csv = '.csv'; case csv = '.csv';
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::png->name => "Fichier png", self::png->name => "Fichier png",
@ -32,7 +34,7 @@ enum TicketFileTypeEnum: int
]; ];
/** /**
* Custom added mimes type definition * Custom added mimes type definition.
*/ */
private const MIMETYPE = [ private const MIMETYPE = [
self::png->name => 'image/png', self::png->name => 'image/png',
@ -46,7 +48,7 @@ enum TicketFileTypeEnum: int
]; ];
/** /**
* Get Class * Get Class.
* *
* @return string * @return string
*/ */
@ -56,7 +58,7 @@ enum TicketFileTypeEnum: int
} }
/** /**
* Get enum classes * Get enum classes.
* *
* @return array<string> * @return array<string>
*/ */

View file

@ -19,37 +19,39 @@ enum TicketStatusEnum: int
case archived = 9; case archived = 9;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::new->name => "Nouveau", self::new->name => "Nouveau",
self::estimateTodo->name => "Étude chef(s) de projet", self::estimateTodo->name => "Étude chef(s) de projet",
self::takenInAccount->name => "Pris en compte", self::takenInAccount->name => "Pris en compte",
self::waiting->name => "En attente de réponse", self::waiting->name => "En attente de réponse",
self::waitingValidation->name => "En attente de validation", self::waitingValidation->name => "En attente de validation",
self::recette->name => "En recettage", self::recette->name => "En recettage",
self::recetteValidated->name => "Recettage validé", self::recetteValidated->name => "Recettage validé",
self::production->name => "En production", self::production->name => "En production",
self::archived->name => "Archivé", self::archived->name => "Archivé",
]; ];
/** /**
* Custom added classes definition * Custom added classes definition.
*/ */
private const CLASSES = [ private const CLASSES = [
self::new->name => 'text-danger', self::new->name => 'text-danger',
self::estimateTodo->name => 'text-info', self::estimateTodo->name => 'text-info',
self::takenInAccount->name => 'text-info', self::takenInAccount->name => 'text-info',
self::waiting->name => 'text-white bg-danger', self::waiting->name => 'text-white bg-danger',
self::waitingValidation->name => 'text-warning bg-danger', self::waitingValidation->name => 'text-warning bg-danger',
self::recette->name => 'text-primary', self::recette->name => 'text-primary',
self::recetteValidated->name => 'text-success', self::recetteValidated->name => 'text-success',
self::production->name => 'text-success', self::production->name => 'text-success',
self::archived->name => 'text-secondary', self::archived->name => 'text-secondary',
]; ];
/** /**
* Get Class * Get Class.
* *
* @return string * @return string
*/ */
@ -59,7 +61,7 @@ enum TicketStatusEnum: int
} }
/** /**
* Get enum classes * Get enum classes.
* *
* @return array<string> * @return array<string>
*/ */

View file

@ -16,27 +16,29 @@ enum TicketTypeEnum: int
case advice = 6; case advice = 6;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::bug->name => "Bug", self::bug->name => "Bug",
self::evolution->name => "Évolution", self::evolution->name => "Évolution",
self::br->name => "Demande BR", self::br->name => "Demande BR",
self::newsletter->name => "Demande newsletter", self::newsletter->name => "Demande newsletter",
self::qrcode->name => "Demande de QR Code", self::qrcode->name => "Demande de QR Code",
self::advice->name => "Conseil - Accompagnement", self::advice->name => "Conseil - Accompagnement",
]; ];
/** /**
* Custom added classes definition * Custom added classes definition
*/ */
private const CLASSES = [ private const CLASSES = [
self::bug->name => "bg-danger", self::bug->name => "bg-danger",
self::evolution->name => "bg-success", self::evolution->name => "bg-success",
self::br->name => "bg-primary", self::br->name => "bg-primary",
self::newsletter->name => "bg-warning", self::newsletter->name => "bg-warning",
self::qrcode->name => "bg-secondary", self::qrcode->name => "bg-secondary",
self::advice->name => "bg-info", self::advice->name => "bg-info",
]; ];
/** /**

View file

@ -16,7 +16,9 @@ enum GitlabUsersEnum: int
case default = 24; case default = 24;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::default->name => "Default", self::default->name => "Default",

View file

@ -13,11 +13,13 @@ enum RoleEnum: int
case client = 2; case client = 2;
/** /**
* Optionnal labels definition * Optionnal labels definition.
*
* @phpstan-ignore-next-line
*/ */
private const LABELS = [ private const LABELS = [
self::developper->name => "Developpeur", self::developper->name => "Developpeur",
self::admin->name => "Administrateur", self::admin->name => "Administrateur",
self::client->name => "Client", self::client->name => "Client",
]; ];
} }

View file

@ -15,7 +15,7 @@ class TicketStatusChanged
use InteractsWithSockets; use InteractsWithSockets;
use SerializesModels; use SerializesModels;
/** @var \App\Models\Site */ /** @var \App\Models\Ticket */
public $ticket; public $ticket;
/** @var \App\Models\User */ /** @var \App\Models\User */

View file

@ -36,7 +36,7 @@ class Handler extends ExceptionHandler
* *
* @return void * @return void
*/ */
public function register() public function register(): void
{ {
$this->reportable(function (\Throwable $e) { $this->reportable(function (\Throwable $e) {
if (app()->bound('sentry')) { if (app()->bound('sentry')) {

View file

@ -10,7 +10,7 @@ class ForgotPasswordController extends Controller
use SendsPasswordResetEmails; use SendsPasswordResetEmails;
/** /**
* ForgotPasswordController * ForgotPasswordController.
* *
* @return void * @return void
*/ */

View file

@ -23,11 +23,11 @@ class ResetPasswordController extends Controller
* *
* @return array * @return array
*/ */
protected function rules() protected function rules(): array
{ {
return [ return [
'token' => 'required', 'token' => 'required',
'email' => 'required|email', 'email' => 'required|email',
'password' => [ 'password' => [
'required', 'confirmed', Password::min(8) 'required', 'confirmed', Password::min(8)
->mixedCase() ->mixedCase()

View file

@ -7,6 +7,7 @@ use App\Http\Requests\Bo\CreditAccounts\StoreCreditAccountRequest;
use App\Models\Brand; use App\Models\Brand;
use App\Models\Credit\Account; use App\Models\Credit\Account;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -21,13 +22,11 @@ class AccountController extends Controller
public function index(Request $request): \Illuminate\Contracts\View\View public function index(Request $request): \Illuminate\Contracts\View\View
{ {
/** @var \App\Models\User $user */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
if (!$user->isAdmin()) { $brandModels = (!$user->isAdmin())
$brandModels = $user->brands()->pluck('id'); ? $user->brands()->pluck('id')
} else { : $request->brand ?? Brand::query()->pluck('id');
$brandModels = $request->brand ?? Brand::all()->pluck('id');
}
/** @var \Illuminate\Database\Eloquent\Builder $credit_accountModels */ /** @var \Illuminate\Database\Eloquent\Builder $credit_accountModels */
$credit_accountModels = Account::query()->whereIn('brand_id', $brandModels); $credit_accountModels = Account::query()->whereIn('brand_id', $brandModels);
@ -62,14 +61,14 @@ class AccountController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @param \App\Models\Brand $brand * @param \App\Models\Brand $brand
* @param \App\Models\Account $account * @param \App\Models\Credit\Account $account
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
*/ */
public function create(Brand $brand, Account $account): \Illuminate\Contracts\View\View public function create(Brand $brand, Account $account): \Illuminate\Contracts\View\View
{ {
return view('bo.pages.credit_accounts.create', [ return view('bo.pages.credit_accounts.create', [
'brandModel' => $brand, 'brandModel' => $brand,
'credit_accountModel' => $account 'credit_accountModel' => $account
]); ]);
} }
@ -85,7 +84,7 @@ class AccountController extends Controller
{ {
return DB::transaction(function () use ($brand, $request) { return DB::transaction(function () use ($brand, $request) {
$credit_accountModel = new Account(); $credit_accountModel = new Account();
$credit_accountModel->brand_id = $brand->id; $credit_accountModel->brand_id = $brand->getKey();
$credit_accountModel->fill($request->validated()); $credit_accountModel->fill($request->validated());
if ($credit_accountModel->saveOrFail()) { if ($credit_accountModel->saveOrFail()) {

View file

@ -58,14 +58,14 @@ class CreditLogController extends Controller
/** /**
* Show the form for creating a new resource. * Show the form for creating a new resource.
* *
* @param \App\Models\Brand $brand * @param \App\Models\Brand $brand
* @param \App\Models\Account $account * @param \App\Models\Credit\Account $account
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
*/ */
public function create(Brand $brand, Account $account): \Illuminate\Contracts\View\View public function create(Brand $brand, Account $account): \Illuminate\Contracts\View\View
{ {
return view('bo.pages.credit_logs.create', [ return view('bo.pages.credit_logs.create', [
'brandModel' => $brand, 'brandModel' => $brand,
'credit_accountModel' => $account 'credit_accountModel' => $account
]); ]);
} }
@ -74,7 +74,7 @@ class CreditLogController extends Controller
* Store a newly created resource in storage. * Store a newly created resource in storage.
* *
* @param \App\Models\Brand $brand * @param \App\Models\Brand $brand
* @param \App\Models\Account $account * @param \App\Models\Credit\Account $account
* @param \App\Http\Requests\Bo\CreditLogs\StoreCreditLogRequest $request * @param \App\Http\Requests\Bo\CreditLogs\StoreCreditLogRequest $request
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */

View file

@ -176,8 +176,9 @@ class InvoiceController extends Controller
* @param \App\Models\Invoice $invoice * @param \App\Models\Invoice $invoice
* @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/ */
public function download(Invoice $invoice) public function download(
{ Invoice $invoice
): \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response {
if (Gate::allows('isAdmin')) { if (Gate::allows('isAdmin')) {
return $invoice->generateInvoice() return $invoice->generateInvoice()
->stream(Str::slug(trans('Devis :appname :date - ref :ref', [ ->stream(Str::slug(trans('Devis :appname :date - ref :ref', [
@ -199,7 +200,7 @@ class InvoiceController extends Controller
* Get a paginate resource. * Get a paginate resource.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
{ {

View file

@ -50,9 +50,9 @@ class ProjectController extends Controller
* Crud show view * Crud show view
* *
* @param \App\Models\Project $project * @param \App\Models\Project $project
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory * @return \Illuminate\Contracts\View\View
*/ */
public function show(Project $project) public function show(Project $project): \Illuminate\Contracts\View\View
{ {
return view('bo.pages.projects.show', [ return view('bo.pages.projects.show', [
'projectModel' => $project 'projectModel' => $project
@ -178,7 +178,7 @@ class ProjectController extends Controller
* Get a paginate resource. * Get a paginate resource.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
{ {

View file

@ -189,7 +189,7 @@ class SiteController extends Controller
* Get a paginate resource. * Get a paginate resource.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
{ {

View file

@ -28,6 +28,7 @@ use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
@ -62,7 +63,7 @@ class TicketController extends Controller
$q->where('name', 'LIKE', "%$request->s%"); $q->where('name', 'LIKE', "%$request->s%");
}); });
} }
/** @var \Illuminate/Pagination/LengthAwarePaginator $tickets */ /** @var \Illuminate\Pagination\LengthAwarePaginator $tickets */
$tickets = $tickets->paginate(); $tickets = $tickets->paginate();
return \response()->json($tickets->getCollection()->map(function (Ticket $ticket) { return \response()->json($tickets->getCollection()->map(function (Ticket $ticket) {
return [ return [
@ -128,10 +129,12 @@ class TicketController extends Controller
* *
* @param Request $request * @param Request $request
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory * @return \Illuminate\Http\JsonResponse|\Illuminate\Contracts\View\View
*/ */
public function show(Request $request, Ticket $ticket) public function show(
{ Request $request,
Ticket $ticket
): \Illuminate\Http\JsonResponse|\Illuminate\Contracts\View\View {
if ($request->ajax()) { if ($request->ajax()) {
return \response()->json([ return \response()->json([
'label' => $ticket->formatName($ticket), 'label' => $ticket->formatName($ticket),
@ -162,9 +165,9 @@ class TicketController extends Controller
/** /**
* Show create Form * Show create Form
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View
*/ */
public function create() public function create(): \Illuminate\Http\RedirectResponse|\Illuminate\Contracts\View\View
{ {
/** @var \App\Models\User */ /** @var \App\Models\User */
$user = auth()->user(); $user = auth()->user();
@ -187,7 +190,7 @@ class TicketController extends Controller
* @param StoreTicket $request * @param StoreTicket $request
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function store(StoreTicket $request) public function store(StoreTicket $request): \Illuminate\Http\RedirectResponse
{ {
try { try {
return DB::transaction(function () use ($request) { return DB::transaction(function () use ($request) {
@ -240,13 +243,13 @@ class TicketController extends Controller
} }
/** /**
* Show update form * Show update form.
* *
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory * @return \Illuminate\Contracts\View\View
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/ */
public function edit(Ticket $ticket) public function edit(Ticket $ticket): \Illuminate\Contracts\View\View
{ {
/** @var \App\Models\User */ /** @var \App\Models\User */
$user = auth()->user(); $user = auth()->user();
@ -259,13 +262,13 @@ class TicketController extends Controller
} }
/** /**
* Update Model * Update Model.
* *
* @param UpdateTicket $request * @param UpdateTicket $request
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function update(UpdateTicket $request, Ticket $ticket) public function update(UpdateTicket $request, Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
$ticket->fill($request->validated()); $ticket->fill($request->validated());
@ -304,13 +307,13 @@ class TicketController extends Controller
} }
/** /**
* Change ticket Status * Change ticket Status.
* *
* @param ChangeTicketStatus $request * @param ChangeTicketStatus $request
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function changeStatus(ChangeTicketStatus $request, Ticket $ticket) public function changeStatus(ChangeTicketStatus $request, Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
$ticket->fill($request->validated()); $ticket->fill($request->validated());
$ticket->saveOrFail(); $ticket->saveOrFail();
@ -320,25 +323,25 @@ class TicketController extends Controller
} }
/** /**
* Add a new Message to the Ticket * Add a new Message to the Ticket.
* *
* @param CreateMessage $request * @param CreateMessage $request
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function createMessage(CreateMessage $request, Ticket $ticket) public function createMessage(CreateMessage $request, Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
try { try {
return DB::transaction(function () use ($request, $ticket) { return DB::transaction(function () use ($request, $ticket) {
/** @var \App\Models\User $user */
$user = Auth::user();
/** @var \Illuminate\Http\UploadedFile|null */ /** @var \Illuminate\Http\UploadedFile|null */
$filesMessage = $request->file_messages; $filesMessage = $request->file_messages;
$message = new Message($request->validated()); $message = new Message($request->validated());
$message->user()->associate(auth()->user()); $message->user()->associate($user);
$message->ticket()->associate($ticket); $message->ticket()->associate($ticket);
/** @var \App\Models\User */
$user = auth()->user();
if ($request->subscribe) { if ($request->subscribe) {
if (!$user->subscriptions()->find($ticket->id)) { if (!$user->subscriptions()->find($ticket->id)) {
$user->subscriptions()->attach($ticket->id); $user->subscriptions()->attach($ticket->id);
@ -374,7 +377,7 @@ class TicketController extends Controller
} }
/** /**
* Update Message * Update Message.
* *
* @param UpdateMessage $request * @param UpdateMessage $request
* @param Ticket $ticket * @param Ticket $ticket
@ -382,8 +385,11 @@ class TicketController extends Controller
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/ */
public function updateMessage(UpdateMessage $request, Ticket $ticket, Message $message) public function updateMessage(
{ UpdateMessage $request,
Ticket $ticket,
Message $message
): \Illuminate\Http\RedirectResponse {
$message->message = $request->message; $message->message = $request->message;
$message->saveOrFail(); $message->saveOrFail();
@ -392,12 +398,12 @@ class TicketController extends Controller
} }
/** /**
* Change ticket status to archived * Change ticket status to archived.
* *
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function setToArchive(Ticket $ticket) public function setToArchive(Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
$ticket->status = TicketStatusEnum::archived; $ticket->status = TicketStatusEnum::archived;
$ticket->saveOrFail(); $ticket->saveOrFail();
@ -406,15 +412,15 @@ class TicketController extends Controller
} }
/** /**
* Subscribe to ticket * Subscribe to ticket.
* *
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function subscribe(Ticket $ticket) public function subscribe(Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
/** @var \App\Models\User */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
$user->subscriptions()->toggle($ticket->id); $user->subscriptions()->toggle($ticket->id);
if ($user->subscriptions()->where('ticket_id', $ticket->id)->exists()) { if ($user->subscriptions()->where('ticket_id', $ticket->id)->exists()) {
return back() return back()
@ -424,15 +430,15 @@ class TicketController extends Controller
} }
/** /**
* Reopen ticket * Reopen ticket.
* *
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function reopen(Ticket $ticket) public function reopen(Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
$message = trans(':ticketName à réouvert le ticket n°:ticketNumber', [ $message = trans(':ticketName à réouvert le ticket n°:ticketNumber', [
'ticketName' => $ticket->user->name, 'ticketName' => $ticket->user->name,
'ticketNumber' => $ticket->id, 'ticketNumber' => $ticket->id,
]); ]);
/** @var \App\Enums\Tickets\TicketStatusEnum */ /** @var \App\Enums\Tickets\TicketStatusEnum */
@ -442,27 +448,28 @@ class TicketController extends Controller
event(new TicketStatusChanged($ticket, $oldStatus, null, $message, false, false)); event(new TicketStatusChanged($ticket, $oldStatus, null, $message, false, false));
event(new NotifySubscriptions($ticket, $message, collect([$ticket->user]))); event(new NotifySubscriptions($ticket, $message, collect([$ticket->user])));
/** @var \App\Models\User */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
$user->subscriptions()->toggle($ticket->id); $user->subscriptions()->toggle($ticket->id);
return back()->with('warning', trans('Votre ticket à été réouvert.')); return back()->with('warning', trans('Votre ticket à été réouvert.'));
} }
/** /**
* Assign ticket to user ticket * Assign ticket to user ticket.
* *
* @param AssignTicketToUserRequest $request * @param AssignTicketToUserRequest $request
* @param Ticket $ticket * @param Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
public function assignTo(AssignTicketToUserRequest $request, Ticket $ticket) public function assignTo(AssignTicketToUserRequest $request, Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
/** @var \App\Models\User */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
/** @var \App\Models\User|null */ /** @var \App\Models\User|null $assignedUser */
if ($assignedUser = User::whereId($request->assign)->first()) { $assignedUser = User::whereId($request->assign)->first();
if ($assignedUser) {
$message = trans(':admin a assigné le ticket n°:ticketNumber à :assignedAdmin', [ $message = trans(':admin a assigné le ticket n°:ticketNumber à :assignedAdmin', [
'admin' => $user->name, 'admin' => $user->name,
'ticketNumber' => $ticket->id, 'ticketNumber' => $ticket->id,
@ -488,8 +495,6 @@ class TicketController extends Controller
event(new TicketStatusChanged($ticket, $oldStatus, null, $message, true, false)); event(new TicketStatusChanged($ticket, $oldStatus, null, $message, true, false));
event(new NotifySubscriptions($ticket, $message, collect([$ticket->user]))); event(new NotifySubscriptions($ticket, $message, collect([$ticket->user])));
/** @var \App\Models\User */
$user = auth()->user();
$user->subscriptions()->toggle($ticket->id); $user->subscriptions()->toggle($ticket->id);
if ($assignedUser) { if ($assignedUser) {
@ -517,9 +522,9 @@ class TicketController extends Controller
return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.')); return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.'));
} }
if (!$ticket->linkedTicket()->where('linked_ticket_id', $linkedTicket->id)->exists()) { if (!$ticket->linkedTickets()->where('linked_ticket_id', $linkedTicket->id)->exists()) {
$ticket->linkedTicket()->attach($linkedTicket->id); $ticket->linkedTickets()->attach($linkedTicket->id);
$linkedTicket->linkedTicket()->attach($ticket->id); $linkedTicket->linkedTickets()->attach($ticket->id);
return back()->with('success', trans('Les tickets ont été liés avec succès.')); return back()->with('success', trans('Les tickets ont été liés avec succès.'));
} }
@ -536,8 +541,8 @@ class TicketController extends Controller
*/ */
public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket) public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket)
{ {
$ticket->linkedTicket()->detach($linkedTicket->id); $ticket->linkedTickets()->detach($linkedTicket->id);
$linkedTicket->linkedTicket()->detach($ticket->id); $linkedTicket->linkedTickets()->detach($ticket->id);
return back()->with('warning', trans('Le lien entre les tickets à été supprimé.')); return back()->with('warning', trans('Le lien entre les tickets à été supprimé.'));
} }
@ -545,14 +550,14 @@ class TicketController extends Controller
// * PRIVATES // * PRIVATES
/** /**
* Filter Tickets request constructor * Filter Tickets request constructor.
* *
* @param Builder $tickets * @param \Illuminate\Database\Eloquent\Builder $tickets
* @param Request $request * @param \Illuminate\Http\Request $request
* @return Builder * @return \Illuminate\Database\Eloquent\Builder
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh * @phpcs:disable Generic.Metrics.CyclomaticComplexity.MaxExceeded
*/ */
private function filterTickets(Builder $tickets, Request $request): Builder private function filterTickets(Builder $tickets, Request $request): \Illuminate\Database\Eloquent\Builder
{ {
//phpcs:enable //phpcs:enable
if ($request->rst) { if ($request->rst) {
@ -659,13 +664,13 @@ class TicketController extends Controller
} }
/** /**
* Search ticket sql request constructor * Search ticket sql request constructor.
* *
* @param Builder $tickets * @param \Illuminate\Database\Eloquent\Builder $tickets
* @param Request $request * @param \Illuminate\Http\Request $request
* @return Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
private function searchTicket(Builder $tickets, Request $request): Builder private function searchTicket(Builder $tickets, Request $request): \Illuminate\Database\Eloquent\Builder
{ {
if ($request->exists('search')) { if ($request->exists('search')) {
if (empty($request->search)) { if (empty($request->search)) {
@ -681,29 +686,27 @@ class TicketController extends Controller
return $this->searchQuery($tickets, Session::get('tickets.search'), function ($q) { return $this->searchQuery($tickets, Session::get('tickets.search'), function ($q) {
$words = explode(' ', Session::get('tickets.search')); $words = explode(' ', Session::get('tickets.search'));
if (\is_array($words)) { foreach ($words as $word) {
foreach ($words as $word) { if (!strlen($word)) {
if (!strlen($word)) { continue;
continue; }
} $s = collect(TicketStatusEnum::cases())->filter(function (TicketStatusEnum $t) use ($word) {
$s = collect(TicketStatusEnum::cases())->filter(function (TicketStatusEnum $t) use ($word) { return Str::slug($t->label()) === Str::slug($word);
return Str::slug($t->label()) === Str::slug($word); })->map(function (TicketStatusEnum $ticket) {
})->map(function (TicketStatusEnum $ticket) { return $ticket->value;
return $ticket->value; });
$t = collect(TicketTypeEnum::cases())->filter(function (TicketTypeEnum $s) use ($word) {
return Str::slug($s->label()) === Str::slug($word);
})->map(function (TicketTypeEnum $ticket) {
return $ticket->value;
});
$q->orWhere('id', $word)
->orWhereIn('status', $s)
->orWhereIn('type', $t)
->orWhereHas('user', function ($q) use ($word) {
$q->where('name', 'LIKE', "%$word%");
}); });
$t = collect(TicketTypeEnum::cases())->filter(function (TicketTypeEnum $s) use ($word) { } //end foreach
return Str::slug($s->label()) === Str::slug($word);
})->map(function (TicketTypeEnum $ticket) {
return $ticket->value;
});
$q->orWhere('id', $word)
->orWhereIn('status', $s)
->orWhereIn('type', $t)
->orWhereHas('user', function ($q) use ($word) {
$q->where('name', 'LIKE', "%$word%");
});
} //end foreach
} //end if
}, 'text', 'title', 'file', 'file2', 'file3', 'file4', 'file5'); }, 'text', 'title', 'file', 'file2', 'file3', 'file4', 'file5');
} }
@ -711,7 +714,7 @@ class TicketController extends Controller
* Get a paginate resource. * Get a paginate resource.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return Illuminate\Http\JsonResponse * @return \Illuminate\Http\JsonResponse
*/ */
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
{ {
@ -742,9 +745,11 @@ class TicketController extends Controller
* *
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh
*/ */
public function createGitlabIssue(Ticket $ticket) public function createGitlabIssue(Ticket $ticket): \Illuminate\Http\RedirectResponse
{ {
//phpcs:enable
$gitlabRepoId = $ticket->site->gitlab_project_id; $gitlabRepoId = $ticket->site->gitlab_project_id;
$description = \sprintf("%s<br>", $ticket->text); $description = \sprintf("%s<br>", $ticket->text);
$cLabel = match ($ticket->type) { $cLabel = match ($ticket->type) {
@ -765,7 +770,6 @@ class TicketController extends Controller
$description .= $this->formatGitlabFiles($ticket, $uploadedFile, $key + 1); $description .= $this->formatGitlabFiles($ticket, $uploadedFile, $key + 1);
} }
} }
$issue = GitLab::issues()->create($gitlabRepoId, [ $issue = GitLab::issues()->create($gitlabRepoId, [
'title' => sprintf( 'title' => sprintf(
'ts-%s : %s', 'ts-%s : %s',
@ -797,14 +801,14 @@ class TicketController extends Controller
} }
/** /**
* Format files for Gitlab issues * Format files for Gitlab issues.
* *
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @param array $uploadedFile * @param array $uploadedFile
* @param integer $fileNb * @param integer $fileNb
* @return string * @return string
*/ */
private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb) private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb): string
{ {
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv'])) { if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv'])) {
$file = \sprintf( $file = \sprintf(
@ -835,7 +839,8 @@ class TicketController extends Controller
$paramNames = collect(request()->route()->parameterNames); $paramNames = collect(request()->route()->parameterNames);
$className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly(); $className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly();
$className = "\\App\\Models\\{$className}"; $className = "\\App\\Models\\{$className}";
$model = Arr::get($params, $paramNames->count() - 2); /** @var \App\Models\Ticket|null $model */
$model = Arr::get($params, $paramNames->count() - 2);
if (!class_exists($className)) { if (!class_exists($className)) {
throw new \RuntimeException("The {$className} class doesn't exist."); throw new \RuntimeException("The {$className} class doesn't exist.");
@ -849,7 +854,7 @@ class TicketController extends Controller
throw new \RuntimeException("The {$className} doesn't match second last binded param."); throw new \RuntimeException("The {$className} doesn't match second last binded param.");
} }
/** @var \Illuminate\Database\Eloquent\Model|null */ /** @var \App\Models\Ticket|null */
$model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first(); $model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first();
if (!$model) { if (!$model) {
@ -857,7 +862,7 @@ class TicketController extends Controller
} }
return DB::transaction(function () use ($request, $className, $model) { return DB::transaction(function () use ($request, $className, $model) {
/** @var \Illuminate\Support\Collection $models */ /** @var \Illuminate\Support\Collection<int, \App\Models\Ticket> $models */
$models = $className::query() $models = $className::query()
->orderBy('order', 'ASC') ->orderBy('order', 'ASC')
->where('site_id', $model->site_id) ->where('site_id', $model->site_id)

View file

@ -45,7 +45,7 @@ class TicketTypeController extends Controller
/** /**
* Show the form for editing the specified resource. * Show the form for editing the specified resource.
* *
* @param App\Models\Ticket\TicketType $ticketType * @param \App\Models\Ticket\TicketType $ticketType
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
* @ignore phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass * @ignore phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/ */

View file

@ -166,7 +166,7 @@ class UserController extends Controller
} }
/** /**
* Password reset form * Password reset form.
* *
* @return \Illuminate\Contracts\View\View * @return \Illuminate\Contracts\View\View
*/ */
@ -176,7 +176,7 @@ class UserController extends Controller
} }
/** /**
* Password reset submit * Password reset submit.
* *
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
*/ */
@ -187,18 +187,4 @@ class UserController extends Controller
$request = new Request(['email' => $user->email]); $request = new Request(['email' => $user->email]);
return app(ForgotPasswordController::class)->sendResetLinkEmail($request); return app(ForgotPasswordController::class)->sendResetLinkEmail($request);
} }
/**
* Get february last day date of the year
*
* @param integer $year
* @return integer 28 or 29
*/
private function getLastDayFebruary(int $year): int
{
if ((is_int($year / 4) && !is_int($year / 100)) || is_int($year / 400)) {
return 29;
}
return 28;
}
} }

View file

@ -4,7 +4,6 @@ namespace App\Http\Controllers;
use App\Enums\Tickets\TicketStatusEnum; use App\Enums\Tickets\TicketStatusEnum;
use App\Models\Ticket; use App\Models\Ticket;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
@ -89,7 +88,7 @@ class Controller extends BaseController
string $search, string $search,
callable $searchQuery = null, callable $searchQuery = null,
string ...$fields string ...$fields
): Builder { ): \Illuminate\Database\Eloquent\Builder {
if (count($fields)) { if (count($fields)) {
// Search using words. // Search using words.
$words = explode(' ', $search); $words = explode(' ', $search);
@ -199,7 +198,7 @@ class Controller extends BaseController
* @param array $ignore * @param array $ignore
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
protected function sortQuery(Builder $query, array $ignore = []): Builder protected function sortQuery(Builder $query, array $ignore = []): \Illuminate\Database\Eloquent\Builder
{ {
$rName = request()->route()->getName(); $rName = request()->route()->getName();
$table = $query->getModel()->getTable(); $table = $query->getModel()->getTable();
@ -218,8 +217,7 @@ class Controller extends BaseController
} }
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) { if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
if ( if (
!isset($ignore) or !in_array(request()->sort_col, $ignore)
(isset($ignore) and !in_array(request()->sort_col, $ignore))
) { ) {
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way); $query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
} }
@ -234,7 +232,7 @@ class Controller extends BaseController
* @param integer|null $pagination * @param integer|null $pagination
* @return \Illuminate\Pagination\LengthAwarePaginator * @return \Illuminate\Pagination\LengthAwarePaginator
*/ */
protected function customPaginate(Builder $query, $pagination): LengthAwarePaginator protected function customPaginate(Builder $query, $pagination): \Illuminate\Pagination\LengthAwarePaginator
{ {
if ($pagination) { if ($pagination) {
Cache::put('pagination', $pagination); Cache::put('pagination', $pagination);

View file

@ -54,17 +54,17 @@ class Kernel extends HttpKernel
* @var array<string, class-string|string> * @var array<string, class-string|string>
*/ */
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class, 'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'is-admin' => \App\Http\Middleware\IsAdmin::class, 'is-admin' => \App\Http\Middleware\IsAdmin::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \App\Http\Middleware\ValidateSignature::class, 'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class, 'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
]; ];
} }

View file

@ -34,7 +34,5 @@ class Authenticate extends Middleware
return route('login'); return route('login');
} }
abort(401); abort(401);
return null;
} }
} }

View file

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

View file

@ -4,7 +4,6 @@ namespace App\Http\Middleware;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
class RedirectIfAuthenticated class RedirectIfAuthenticated
{ {
@ -18,7 +17,7 @@ class RedirectIfAuthenticated
* @throws \RuntimeException If guard is unhandled. * @throws \RuntimeException If guard is unhandled.
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
*/ */
public function handle(Request $request, \Closure $next, ...$guards): Response public function handle(Request $request, \Closure $next, ...$guards): \Symfony\Component\HttpFoundation\Response
{ {
// phpcs:enable phpcs:disable // phpcs:enable phpcs:disable
$guards = empty($guards) ? [null] : $guards; $guards = empty($guards) ? [null] : $guards;

View file

@ -7,7 +7,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Vite; use Illuminate\Support\Facades\Vite;
use Symfony\Component\HttpFoundation\Response;
class SecureHeaders class SecureHeaders
{ {
@ -31,7 +30,7 @@ class SecureHeaders
* @return \Symfony\Component\HttpFoundation\Response * @return \Symfony\Component\HttpFoundation\Response
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint * @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
*/ */
public function handle(Request $request, Closure $next): Response public function handle(Request $request, Closure $next): \Symfony\Component\HttpFoundation\Response
{ {
// phpcs:enable // phpcs:enable
View::share('nonce', $nonce = Vite::useCspNonce()); View::share('nonce', $nonce = Vite::useCspNonce());
@ -89,12 +88,12 @@ class SecureHeaders
} }
/** /**
* Remove unwanted headers * Remove unwanted headers.
* *
* @param array $headerList * @param array $headerList
* @return void * @return void
*/ */
private function removeUnwantedHeaders(array $headerList) private function removeUnwantedHeaders(array $headerList): void
{ {
foreach ($headerList as $header) { foreach ($headerList as $header) {
header_remove($header); header_remove($header);

View file

@ -11,7 +11,7 @@ class TrustHosts extends Middleware
* *
* @return array<int, string|null> * @return array<int, string|null>
*/ */
public function hosts() public function hosts(): array
{ {
return [ return [
$this->allSubdomainsOfApplicationUrl(), $this->allSubdomainsOfApplicationUrl(),

View file

@ -4,6 +4,7 @@ namespace App\Http\Requests\Bo;
use App\Models\User; use App\Models\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class AssignTicketToUserRequest extends FormRequest class AssignTicketToUserRequest extends FormRequest
{ {
@ -12,11 +13,11 @@ class AssignTicketToUserRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
/** @var \App\Models\User */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
return auth()->check() and $user->isAdmin(); return Auth::check() and $user->isAdmin();
} }
/** /**
@ -24,15 +25,14 @@ class AssignTicketToUserRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'assign' => [ 'assign' => [
'nullable', 'exists:users,id', 'nullable', 'exists:users,id',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) { function ($attribute, $value, $fail) {
/** @var \App\Models\User $user */ if ($user = User::query()->whereId($value)->first() and !$user->isAdmin()) {
if ($user = User::whereId($value)->first() and !$user->isAdmin()) {
$fail(trans('Cet utilisateur ne peut se voir assigner un ticket')); $fail(trans('Cet utilisateur ne peut se voir assigner un ticket'));
} }
} }

View file

@ -12,7 +12,7 @@ class StoreBrandRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,11 +22,11 @@ class StoreBrandRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255', 'name' => 'required|string|min:3|max:255',
'sites' => 'nullable|array', 'sites' => 'nullable|array',
'sites.*.id' => 'required|exists:sites,id' 'sites.*.id' => 'required|exists:sites,id'
]; ];
} }
@ -39,8 +39,8 @@ class StoreBrandRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'name' => trans('Nom de la marque'), 'name' => trans('Nom de la marque'),
'sites' => trans('Sites associés à la marque'), 'sites' => trans('Sites associés à la marque'),
'sites.*.id' => trans('Élément parmis les sites associés à la marque'), 'sites.*.id' => trans('Élément parmis les sites associés à la marque'),
]; ];
} }

View file

@ -12,7 +12,7 @@ class ChangeTicketStatus extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
/** @var \App\Models\User */ /** @var \App\Models\User */
$user = auth()->user(); $user = auth()->user();
@ -24,7 +24,7 @@ class ChangeTicketStatus extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'status' => [ 'status' => [

View file

@ -12,7 +12,7 @@ class StoreCompanyRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,7 +22,7 @@ class StoreCompanyRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255', 'name' => 'required|string|min:3|max:255',

View file

@ -4,6 +4,7 @@ namespace App\Http\Requests\Bo;
use App\Enums\MessageTypeEnum; use App\Enums\MessageTypeEnum;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rules\Enum; use Illuminate\Validation\Rules\Enum;
class CreateMessage extends FormRequest class CreateMessage extends FormRequest
@ -13,10 +14,11 @@ class CreateMessage extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
/** @var \App\Models\User|null */ /** @var \App\Models\User|null $user */
if (!($user = auth()->user())) { $user = Auth::user();
if (!($user)) {
return false; return false;
} }
if ( if (
@ -25,7 +27,7 @@ class CreateMessage extends FormRequest
) { ) {
return false; return false;
} }
return auth()->check() and $user->sites and ($user->isAdmin() or $user->sites->contains( return Auth::check() and $user->sites and ($user->isAdmin() or $user->sites->contains(
$this->route()->ticket->site_id $this->route()->ticket->site_id
)); ));
} }
@ -35,7 +37,7 @@ class CreateMessage extends FormRequest
* *
* @return void * @return void
*/ */
protected function prepareForValidation() protected function prepareForValidation(): void
{ {
$this->merge([ $this->merge([
'subscribe' => $this->subscribe ? true : false, 'subscribe' => $this->subscribe ? true : false,
@ -48,10 +50,10 @@ class CreateMessage extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
/** @var \App\Models\User */ /** @var \App\Models\User $user */
$user = auth()->user(); $user = Auth::user();
return [ return [
'subscribe' => 'required|boolean', 'subscribe' => 'required|boolean',
'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'), 'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'),

View file

@ -11,7 +11,7 @@ class AnswerEstimateRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
if (!auth()->check()) { if (!auth()->check()) {
return false; return false;
@ -26,7 +26,7 @@ class AnswerEstimateRequest extends FormRequest
* *
* @return void * @return void
*/ */
protected function prepareForValidation() protected function prepareForValidation(): void
{ {
$this->merge([ $this->merge([
'answer' => $this->status === 'accept' 'answer' => $this->status === 'accept'
@ -38,7 +38,7 @@ class AnswerEstimateRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'status' => 'required|in:accept,refuse', 'status' => 'required|in:accept,refuse',

View file

@ -12,7 +12,7 @@ class CreateEstimateRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
if (!auth()->check()) { if (!auth()->check()) {
return false; return false;
@ -27,12 +27,12 @@ class CreateEstimateRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
/** @var \App\Models\Ticket */ /** @var \App\Models\Ticket */
$ticket = $this->ticket; $ticket = $this->ticket;
return [ return [
'amount' => [ 'amount' => [
'required', 'required',
'numeric', 'numeric',
'gt:0', 'gt:0',
@ -64,7 +64,7 @@ class CreateEstimateRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'amount' => 'Montant', 'amount' => 'Montant',
'credit_account_id' => 'Compte à débiter' 'credit_account_id' => 'Compte à débiter'
]; ];
} }

View file

@ -14,7 +14,7 @@ class StoreCreditAccountRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -24,11 +24,11 @@ class StoreCreditAccountRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'label' => 'required|string|min:3|max:255', 'label' => 'required|string|min:3|max:255',
'type' => [ 'type' => [
'required', 'required',
Rule::in(collect(AccountTypeEnum::cases())->pluck('value')->all()), Rule::in(collect(AccountTypeEnum::cases())->pluck('value')->all()),
], ],
@ -44,8 +44,8 @@ class StoreCreditAccountRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'label' => trans('Label du compte'), 'label' => trans('Label du compte'),
'type' => trans('Type du compte'), 'type' => trans('Type du compte'),
'balance' => trans('Solde du compte'), 'balance' => trans('Solde du compte'),
]; ];
} }

View file

@ -12,7 +12,7 @@ class StoreCreditLogRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,7 +22,7 @@ class StoreCreditLogRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'amount' => [ 'amount' => [

View file

@ -14,7 +14,7 @@ class StoreInformationRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -24,12 +24,12 @@ class StoreInformationRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'title' => 'required|string|min:3|max:255', 'title' => 'required|string|min:3|max:255',
'message' => 'required|string|min:3|max:255', 'message' => 'required|string|min:3|max:255',
'type' => [ 'type' => [
'required', 'required',
Rule::in(collect(InfoColorsEnum::cases())->pluck('value')->all()), Rule::in(collect(InfoColorsEnum::cases())->pluck('value')->all()),
], ],
@ -44,9 +44,9 @@ class StoreInformationRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'title' => trans('Titre de l\'information'), 'title' => trans('Titre de l\'information'),
'message' => trans('Message de l\'information'), 'message' => trans('Message de l\'information'),
'type' => trans('Type d\'information'), 'type' => trans('Type d\'information'),
]; ];
} }
} }

View file

@ -15,7 +15,7 @@ class StoreInvoiceRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -25,7 +25,7 @@ class StoreInvoiceRequest extends FormRequest
* *
* @return void * @return void
*/ */
protected function prepareForValidation() protected function prepareForValidation(): void
{ {
$this->merge([ $this->merge([
'tasks' => request()->tasks ? \collect(json_decode(request()->tasks)) 'tasks' => request()->tasks ? \collect(json_decode(request()->tasks))
@ -41,7 +41,7 @@ class StoreInvoiceRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'firstname' => 'required|string|min:3|max:255', 'firstname' => 'required|string|min:3|max:255',
@ -73,25 +73,25 @@ class StoreInvoiceRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'firstname' => trans('Prénom de la personne associée'), 'firstname' => trans('Prénom de la personne associée'),
'lastname' => trans('Nom de la personne associée'), 'lastname' => trans('Nom de la personne associée'),
'object' => trans('Objet du devis'), 'object' => trans('Objet du devis'),
'tasks' => trans('Tâches du devis'), 'tasks' => trans('Tâches du devis'),
'tasks.*' => trans('Tâches du devis'), 'tasks.*' => trans('Tâches du devis'),
'tasks.*.days' => trans('Nombre de jours dédiés à la tâche'), 'tasks.*.days' => trans('Nombre de jours dédiés à la tâche'),
'tasks.*.amount' => trans('Montant dédié à la tâche'), 'tasks.*.amount' => trans('Montant dédié à la tâche'),
'tasks.*.desc' => trans('Description dédié à la tâche'), 'tasks.*.desc' => trans('Description dédié à la tâche'),
'tasks.*.type' => trans('Type de tâche'), 'tasks.*.type' => trans('Type de tâche'),
'tasks.*.package' => trans('Forfait dédié à la tâche'), 'tasks.*.package' => trans('Forfait dédié à la tâche'),
'comment' => trans('Commentaire du devis'), 'comment' => trans('Commentaire du devis'),
'show_days' => trans('Visibilité des jours'), 'show_days' => trans('Visibilité des jours'),
'site_id' => trans('Site associé'), 'site_id' => trans('Site associé'),
'company_id' => trans('Companie associé'), 'company_id' => trans('Companie associé'),
'invoiced_to_id' => trans('Entité à facturer'), 'invoiced_to_id' => trans('Entité à facturer'),
'signed_date' => trans('Date de signature du Devis'), 'signed_date' => trans('Date de signature du Devis'),
'sent_client_date' => trans('Date d\'envoi du Devis au client'), 'sent_client_date' => trans('Date d\'envoi du Devis au client'),
'sent_accounting_date' => trans('Date d\'envoi du Devis à la comptabilité'), 'sent_accounting_date' => trans('Date d\'envoi du Devis à la comptabilité'),
'status' => trans('État du devis'), 'status' => trans('État du devis'),
]; ];
} }
} }

View file

@ -12,7 +12,7 @@ class UpdateInvoiceRequest extends StoreInvoiceRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
$rules = []; $rules = [];
$model = $this->route('invoice'); $model = $this->route('invoice');

View file

@ -13,7 +13,7 @@ class StoreLabelRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -23,10 +23,10 @@ class StoreLabelRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:2|max:255|unique:labels,name', 'name' => 'required|string|min:2|max:255|unique:labels,name',
'color' => [ 'color' => [
'required', 'required',
new Hex(), new Hex(),
@ -42,7 +42,7 @@ class StoreLabelRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'name' => trans('validation.attributes.name'), 'name' => trans('validation.attributes.name'),
'color' => trans('validation.attributes.color'), 'color' => trans('validation.attributes.color'),
]; ];
} }

View file

@ -9,7 +9,7 @@ class UpdateLabelRequest extends StoreLabelRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
'name' => 'required|string|min:2|max:255|unique:labels,name,' . $this->route('label')->id . ',id', 'name' => 'required|string|min:2|max:255|unique:labels,name,' . $this->route('label')->id . ',id',

View file

@ -12,7 +12,7 @@ class StorePackageRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,10 +22,10 @@ class StorePackageRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255', 'name' => 'required|string|min:3|max:255',
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/', 'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
]; ];
} }
@ -38,7 +38,7 @@ class StorePackageRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'name' => trans('Nom'), 'name' => trans('Nom'),
'amount' => trans('Montant (par jour)'), 'amount' => trans('Montant (par jour)'),
]; ];
} }

View file

@ -12,7 +12,7 @@ class StoreProjectRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,10 +22,10 @@ class StoreProjectRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255|unique:projects,name', 'name' => 'required|string|min:3|max:255|unique:projects,name',
'site_id' => 'required|exists:sites,id', 'site_id' => 'required|exists:sites,id',
]; ];
} }

View file

@ -9,7 +9,7 @@ class UpdateProjectRequest extends StoreProjectRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
'name' => 'required|string|min:3|max:255|unique:projects,name,' . $this->route('project')->id . ',id', 'name' => 'required|string|min:3|max:255|unique:projects,name,' . $this->route('project')->id . ',id',

View file

@ -12,7 +12,7 @@ class StoreSiteRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -22,16 +22,16 @@ class StoreSiteRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255', 'name' => 'required|string|min:3|max:255',
'users' => 'nullable|array', 'users' => 'nullable|array',
'users.*.id' => 'required|exists:users,id', 'users.*.id' => 'required|exists:users,id',
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id', 'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id',
'project_manager_id' => 'nullable|exists:users,id', 'project_manager_id' => 'nullable|exists:users,id',
'url_re7' => 'nullable|url', 'url_re7' => 'nullable|url',
'url_prod' => 'nullable|url' 'url_prod' => 'nullable|url'
]; ];
} }
@ -43,13 +43,13 @@ class StoreSiteRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'name' => trans('Nom du site'), 'name' => trans('Nom du site'),
'users' => trans('Utilisateurs associés au site'), 'users' => trans('Utilisateurs associés au site'),
'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'), 'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'),
'gitlab_project_id' => trans('ID du dépôt Gitlab'), 'gitlab_project_id' => trans('ID du dépôt Gitlab'),
'project_manager_id' => trans('Chef de projet'), 'project_manager_id' => trans('Chef de projet'),
'url_re7' => trans('Url de RECETTE'), 'url_re7' => trans('Url de RECETTE'),
'url_prod' => trans('Url de prod') 'url_prod' => trans('Url de prod')
]; ];
} }
} }

View file

@ -9,7 +9,7 @@ class UpdateSiteRequest extends StoreSiteRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id,' . $this->route('site')->id . ',id', 'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id,' . $this->route('site')->id . ',id',

View file

@ -12,7 +12,7 @@ class SortTickets extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -22,12 +22,12 @@ class SortTickets extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'search' => 'nullable|string', 'search' => 'nullable|string',
'sort_way' => 'sometimes|in:asc,desc', 'sort_way' => 'sometimes|in:asc,desc',
'status' => [ 'status' => [
'sometimes', 'sometimes',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) { function ($attribute, $value, $fail) {
@ -38,7 +38,7 @@ class SortTickets extends FormRequest
} }
} }
], ],
'pr' => 'sometimes|int|exists:sites,id' 'pr' => 'sometimes|int|exists:sites,id'
]; ];
} }
} }

View file

@ -14,7 +14,7 @@ class StoreTicket extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -24,7 +24,7 @@ class StoreTicket extends FormRequest
* *
* @return void * @return void
*/ */
protected function prepareForValidation() protected function prepareForValidation(): void
{ {
/** @var \App\Models\User|null */ /** @var \App\Models\User|null */
$user = auth()->user(); $user = auth()->user();

View file

@ -37,7 +37,7 @@ class UpdateTicketTypeRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'type' => trans('Type'), 'type' => trans('Type'),
'template' => trans('Template'), 'template' => trans('Template'),
]; ];
} }

View file

@ -39,5 +39,4 @@ class UpdateChangeOrderRequest extends FormRequest
'direction' => 'required|boolean', 'direction' => 'required|boolean',
]; ];
} }
} }

View file

@ -2,6 +2,8 @@
namespace App\Http\Requests\Bo; namespace App\Http\Requests\Bo;
use Illuminate\Support\Facades\Auth;
class UpdateTicket extends StoreTicket class UpdateTicket extends StoreTicket
{ {
/** /**
@ -11,11 +13,12 @@ class UpdateTicket extends StoreTicket
*/ */
public function authorize(): bool public function authorize(): bool
{ {
/** @var \App\Models\User|null */ /** @var \App\Models\User|null $user */
if (!($user = auth()->user())) { $user = Auth::user();
if (!($user)) {
return false; return false;
} }
return auth()->check() and ($user->isAdmin() or return Auth::check() and ($user->isAdmin() or
optional(request()->route()->ticket)->created_by === $user->id optional(request()->route()->ticket)->created_by === $user->id
); );
} }

View file

@ -14,7 +14,7 @@ class StoreUserRequest extends FormRequest
* *
* @return boolean * @return boolean
*/ */
public function authorize() public function authorize(): bool
{ {
return Gate::allows('isAdmin'); return Gate::allows('isAdmin');
} }
@ -24,18 +24,18 @@ class StoreUserRequest extends FormRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return [ return [
'name' => 'required|string|min:3|max:255', 'name' => 'required|string|min:3|max:255',
'email' => 'email|required|unique:users,email', 'email' => 'email|required|unique:users,email',
'role' => [ 'role' => [
'required', 'required',
Rule::in(collect(RoleEnum::cases())->pluck('value')->all()), Rule::in(collect(RoleEnum::cases())->pluck('value')->all()),
], ],
'sites' => 'nullable|array', 'sites' => 'nullable|array',
'sites.*.id' => 'required|exists:sites,id', 'sites.*.id' => 'required|exists:sites,id',
'gitlab_id' => 'nullable|integer|unique:users,gitlab_id' 'gitlab_id' => 'nullable|integer|unique:users,gitlab_id'
]; ];
} }
@ -47,12 +47,12 @@ class StoreUserRequest extends FormRequest
public function attributes(): array public function attributes(): array
{ {
return [ return [
'name' => trans('Nom de l\'utilisateur'), 'name' => trans('Nom de l\'utilisateur'),
'email' => trans('Email de l\'utilisateur'), 'email' => trans('Email de l\'utilisateur'),
'role' => trans('Rôle de l\'utilisateur'), 'role' => trans('Rôle de l\'utilisateur'),
'sites' => trans('Sites associés à l\'utilisateur'), 'sites' => trans('Sites associés à l\'utilisateur'),
'sites.*.id' => trans('Élément parmis les sites associés à l\'utilisateur'), 'sites.*.id' => trans('Élément parmis les sites associés à l\'utilisateur'),
'gitlab_id' => trans("ID de l'utilisateur Gitlab") 'gitlab_id' => trans("ID de l'utilisateur Gitlab")
]; ];
} }
} }

View file

@ -9,7 +9,7 @@ class UpdateUserRequest extends StoreUserRequest
* *
* @return array * @return array
*/ */
public function rules() public function rules(): array
{ {
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id', 'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id',

View file

@ -12,17 +12,17 @@ class UserLabeledResource extends ResourceCollection
* Transform the resource collection into an array. * Transform the resource collection into an array.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @return array * @return \Illuminate\Support\Collection
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/ */
public function toArray(Request $request) public function toArray(Request $request): \Illuminate\Support\Collection
{ {
// phpcs:enable // phpcs:enable
return $this->collection->mapWithKeys(function (User $user, $key) { return $this->collection->mapWithKeys(function (User $user, $key) {
return [ return [
$key => [ $key => [
'label' => sprintf('%d %s', $user->id, $user->name), 'label' => sprintf('%d %s', $user->id, $user->name),
'key' => $user->id 'key' => $user->id
] ]
]; ];
}); });

View file

@ -6,11 +6,12 @@ interface SpsConfigInterface
{ {
/** /**
* URL method * URL method
* Website (SP) url ex: https://le-gaulois-pro.s-web.test * Website (SP) url ex: https://le-gaulois-pro.s-web.test
* *
* @return string * @return string
*/ */
public function url(): string; public function url(): string;
/** /**
* acsBase64 method * acsBase64 method
* Return destination url base64 encoded * Return destination url base64 encoded
@ -18,6 +19,7 @@ interface SpsConfigInterface
* @return string * @return string
*/ */
public function acsBase64(): string; public function acsBase64(): string;
/** /**
* destination method * destination method
* Return acs url concatenated with url * Return acs url concatenated with url
@ -25,6 +27,7 @@ interface SpsConfigInterface
* @return string * @return string
*/ */
public function destination(): string; public function destination(): string;
/** /**
* logout method * logout method
* Return sls url concatenated with url * Return sls url concatenated with url
@ -32,6 +35,7 @@ interface SpsConfigInterface
* @return string * @return string
*/ */
public function logout(): string; public function logout(): string;
/** /**
* certificate method * certificate method
* Return certificate (.pem) file from kebab case of Enum name * Return certificate (.pem) file from kebab case of Enum name

View file

@ -15,7 +15,7 @@ class AutoCloseOldTickets
* *
* @return void * @return void
*/ */
public function handle() public function handle(): void
{ {
$limitDays = 15; $limitDays = 15;
$message = 'En l\'absence d\'activitée depuis 15 jours ce ticket est automatiquement clos et archivé.'; $message = 'En l\'absence d\'activitée depuis 15 jours ce ticket est automatiquement clos et archivé.';

View file

@ -39,7 +39,7 @@ class SendTicketMentionMail implements ShouldQueue
* *
* @return void * @return void
*/ */
public function handle() public function handle(): void
{ {
Mail::to($this->user->email)->send($this->mail); Mail::to($this->user->email)->send($this->mail);
Log::debug(sprintf('Mention mail sent to %s', $this->user->email)); Log::debug(sprintf('Mention mail sent to %s', $this->user->email));

View file

@ -36,7 +36,7 @@ class SendUserCreatedEmail implements ShouldQueue
* *
* @return void * @return void
*/ */
public function handle() public function handle(): void
{ {
Mail::to(['email' => $this->user->email]) Mail::to(['email' => $this->user->email])
->send(new UserCreatedMail($this->user)); ->send(new UserCreatedMail($this->user));

View file

@ -15,7 +15,7 @@ class WarnBeforeAutoCloseTicket
* *
* @return void * @return void
*/ */
public function handle() public function handle(): void
{ {
$warningDays = 7; $warningDays = 7;
// phpcs:ignore Generic.Files.LineLength.TooLong // phpcs:ignore Generic.Files.LineLength.TooLong

View file

@ -16,7 +16,7 @@ class CollectionHelper
* @param integer $pageSize * @param integer $pageSize
* @return \Illuminate\Pagination\LengthAwarePaginator * @return \Illuminate\Pagination\LengthAwarePaginator
*/ */
public static function paginate(Collection $results, int $pageSize): LengthAwarePaginator public static function paginate(Collection $results, int $pageSize): \Illuminate\Pagination\LengthAwarePaginator
{ {
$page = Paginator::resolveCurrentPage('page'); $page = Paginator::resolveCurrentPage('page');
@ -31,8 +31,11 @@ class CollectionHelper
* @param integer $page * @param integer $page
* @return \Illuminate\Pagination\LengthAwarePaginator * @return \Illuminate\Pagination\LengthAwarePaginator
*/ */
public static function paginateManually(Collection $results, int $pageSize, int $page = 1): LengthAwarePaginator public static function paginateManually(
{ Collection $results,
int $pageSize,
int $page = 1
): \Illuminate\Pagination\LengthAwarePaginator {
$total = $results->count(); $total = $results->count();
return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [ return self::paginator($results->forPage($page, $pageSize), $total, $pageSize, $page, [
@ -51,14 +54,19 @@ class CollectionHelper
* @param array $options * @param array $options
* @return \Illuminate\Pagination\LengthAwarePaginator * @return \Illuminate\Pagination\LengthAwarePaginator
*/ */
protected static function paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options) protected static function paginator(
{ Collection $items,
int $total,
int $perPage,
int $currentPage,
array $options
): \Illuminate\Pagination\LengthAwarePaginator {
return Container::getInstance()->makeWith(LengthAwarePaginator::class, [ return Container::getInstance()->makeWith(LengthAwarePaginator::class, [
'items' => $items, 'items' => $items,
'total' => $total, 'total' => $total,
'perPage' => $perPage, 'perPage' => $perPage,
'currentPage' => $currentPage, 'currentPage' => $currentPage,
'options' => $options 'options' => $options
]); ]);
} }
} }

View file

@ -5,7 +5,7 @@ namespace App\Lib\Helpers;
class ExceptionsHelper class ExceptionsHelper
{ {
/** /**
* Handle sentry event * Handle sentry event.
* *
* @param \Sentry\Event $event * @param \Sentry\Event $event
* @return null|\Sentry\Event * @return null|\Sentry\Event
@ -26,7 +26,7 @@ class ExceptionsHelper
} }
/** /**
* Anonimize Sentry Exception bag * Anonimize Sentry Exception bag.
* *
* @param \Sentry\ExceptionDataBag $exceptionDataBag * @param \Sentry\ExceptionDataBag $exceptionDataBag
* @return \Sentry\ExceptionDataBag * @return \Sentry\ExceptionDataBag
@ -42,7 +42,7 @@ class ExceptionsHelper
} }
/** /**
* Anonymise sentry stacktrace * Anonymise sentry stacktrace.
* *
* @param \Sentry\Stacktrace $stackTrace * @param \Sentry\Stacktrace $stackTrace
* @return \Sentry\Stacktrace * @return \Sentry\Stacktrace
@ -70,7 +70,7 @@ class ExceptionsHelper
} }
/** /**
* Get anonymized sentry params * Get anonymized sentry params.
* *
* @param mixed[] $params * @param mixed[] $params
* @return string[] * @return string[]
@ -105,7 +105,7 @@ class ExceptionsHelper
/** /**
* Anonymize at least Sql queries * Anonymize at least Sql queries.
* *
* @param string $message * @param string $message
* @return string * @return string
@ -120,7 +120,7 @@ class ExceptionsHelper
} }
/** /**
* Anonymize stack trace * Anonymize stack trace.
* *
* @param \Throwable $e * @param \Throwable $e
* @return string * @return string
@ -159,7 +159,7 @@ class ExceptionsHelper
} }
/** /**
* Handle Args * Handle Args.
* *
* @param array $stack * @param array $stack
* @return string * @return string

View file

@ -175,7 +175,7 @@ class FileStorageHelper
/** /**
* Remove all old files from string attribute html that are stored in public that * Remove all old files from string attribute html that are stored in public that
* are nove present anymore on new html string * are nove present anymore on new html string.
* *
* @param string $newHtmlString The html string with alreadyParsed files using storeModelFilesFromHtml. * @param string $newHtmlString The html string with alreadyParsed files using storeModelFilesFromHtml.
* @param string $oldHtmlString The old html string with alreadyParsed files using storeModelFilesFromHtml. * @param string $oldHtmlString The old html string with alreadyParsed files using storeModelFilesFromHtml.
@ -188,7 +188,7 @@ class FileStorageHelper
/** /**
* Remove all old files that are stored in public that * Remove all old files that are stored in public that
* are not present anymore on new array files * are not present anymore on new array files.
* *
* @param string[] $oldFiles The old array files. * @param string[] $oldFiles The old array files.
* @param string[] $newFiles The new array files. * @param string[] $newFiles The new array files.
@ -208,7 +208,7 @@ class FileStorageHelper
} }
/** /**
* Remove all files from string attribute html that are stored in public * Remove all files from string attribute html that are stored in public.
* *
* @param string $htmlString The html string with alreadyParsed files using storeModelFilesFromHtml. * @param string $htmlString The html string with alreadyParsed files using storeModelFilesFromHtml.
* @return void * @return void
@ -225,7 +225,7 @@ class FileStorageHelper
} }
/** /**
* Find all occurence of files in html * Find all occurence of files in html.
* *
* @param string $html * @param string $html
* @return array * @return array
@ -241,7 +241,7 @@ class FileStorageHelper
/** /**
* Filter array to get only uploaded files that exists * Filter array to get only uploaded files that exists
* on disk 'public' (using helper storage strategy) * on disk 'public' (using helper storage strategy).
* *
* @param array $urls * @param array $urls
* @return array * @return array
@ -261,8 +261,7 @@ class FileStorageHelper
} }
/** /**
* Filter array to get only uploaded files that exists * Filter array to get only uploaded files that exists on disk 'uploads'.
* on disk 'uploads'
* *
* @param array $urls * @param array $urls
* @return array * @return array
@ -284,8 +283,7 @@ class FileStorageHelper
} }
/** /**
* Prepare storage path and return * Prepare storage path and return the file full path.
* the file full path
* *
* @param string $tableName Model table name. * @param string $tableName Model table name.
* @param string $filename The basename for the file. * @param string $filename The basename for the file.
@ -316,7 +314,7 @@ class FileStorageHelper
/** /**
* Create sub folders to store files using pattern * Create sub folders to store files using pattern
* storage/modelfiles/posts/10/04/19/5f * storage/modelfiles/posts/10/04/19/5f
* year/month/day/md5 first 2 letters * year/month/day/md5 first 2 letters.
* *
* @param string $storage_dir * @param string $storage_dir
* @param string $table * @param string $table
@ -342,7 +340,7 @@ class FileStorageHelper
} }
/** /**
* Get unique filename if the path is already occupied * Get unique filename if the path is already occupied.
* *
* @param string $folderPath * @param string $folderPath
* @param string $filename * @param string $filename
@ -365,7 +363,7 @@ class FileStorageHelper
} }
/** /**
* Slugify the filename * Slugify the filename.
* *
* @param string $filename * @param string $filename
* @return string * @return string
@ -376,7 +374,7 @@ class FileStorageHelper
} }
/** /**
* Sanitize File name for uploaded files * Sanitize File name for uploaded files.
* *
* @param string $filename The original uploaded client file name. * @param string $filename The original uploaded client file name.
* @param boolean $beautify Beautify the filename. * @param boolean $beautify Beautify the filename.
@ -402,7 +400,7 @@ class FileStorageHelper
$filename = Str::of($filename)->ltrim('.-'); $filename = Str::of($filename)->ltrim('.-');
// * Optional beautification // * Optional beautification
if ($beautify) { if ($beautify) {
$filename = static::beautifyFilename($filename); $filename = self::beautifyFilename($filename);
} }
// * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086 // * Maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
/** @var string */ /** @var string */
@ -421,7 +419,7 @@ class FileStorageHelper
} }
/** /**
* Beautify a filename * Beautify a filename.
* *
* @param string $filename * @param string $filename
* @return string * @return string

View file

@ -2,8 +2,8 @@
namespace App\Lib\Helpers; namespace App\Lib\Helpers;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Contracts\Pagination\LengthAwarePaginator; use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
@ -57,7 +57,7 @@ class ToolboxHelper
} }
/** /**
* Check uri points to image file * Check uri points to image file.
* *
* @param string $url * @param string $url
* @return boolean * @return boolean
@ -69,7 +69,7 @@ class ToolboxHelper
} }
/** /**
* Check uri points to pdf file * Check uri points to pdf file.
* *
* @param string $url * @param string $url
* @return boolean * @return boolean
@ -85,7 +85,7 @@ class ToolboxHelper
* Only embed allowed are for MP4 self hosted videos right now * Only embed allowed are for MP4 self hosted videos right now
* *
* https is force by ckeditor MediaElements which natively supports * https is force by ckeditor MediaElements which natively supports
* only cloud hosted medias (youtube, spotify etc..) * only cloud hosted medias (youtube, spotify etc..).
* *
* @param string $input * @param string $input
* @return string * @return string
@ -97,7 +97,7 @@ class ToolboxHelper
} }
/** /**
* Assert That no Back Office url is present on txt * Assert That no Back Office url is present on txt.
* *
* @param string $field * @param string $field
* @param string $text * @param string $text
@ -140,7 +140,7 @@ class ToolboxHelper
} }
/** /**
* Assert That only external url is present on txt * Assert That only external url is present on txt.
* *
* @param string $field * @param string $field
* @param string $text * @param string $text
@ -184,7 +184,7 @@ class ToolboxHelper
} }
/** /**
* Assert Is Unique * Assert Is Unique.
* *
* @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $model
* @param array<string> $columns * @param array<string> $columns
@ -235,7 +235,7 @@ class ToolboxHelper
} }
/** /**
* Mutltibyte string replace * Mutltibyte string replace.
* *
* @param array|string $search * @param array|string $search
* @param array|string $replace * @param array|string $replace
@ -279,7 +279,7 @@ class ToolboxHelper
} }
/** /**
* Asserts that the field is unique * Asserts that the field is unique.
* *
* @param string $table * @param string $table
* @param string $field * @param string $field
@ -295,7 +295,7 @@ class ToolboxHelper
string|int|float|bool|null|array $value, string|int|float|bool|null|array $value,
?int $id = null, ?int $id = null,
?callable $query = null ?callable $query = null
) { ): void {
if (!$query) { if (!$query) {
Validator::make([$field => $value], [ Validator::make([$field => $value], [
self::mbReplace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id), self::mbReplace('.', '\.', $field) => Rule::unique($table, $field)->ignore($id),
@ -316,7 +316,7 @@ class ToolboxHelper
} }
/** /**
* Get original polyfill with autotranslate behavior * Get original polyfill with autotranslate behavior.
* *
* @param \Illuminate\Database\Eloquent\Model $model * @param \Illuminate\Database\Eloquent\Model $model
* @param string $attribute * @param string $attribute
@ -335,20 +335,20 @@ class ToolboxHelper
} }
/** /**
* Dynamic model query * Dynamic model query.
* *
* @param string $defaultLocale * @param string $defaultLocale
* @param \Illuminate\Contracts\Database\Eloquent\Builder $q * @param \Illuminate\Database\Eloquent\Builder $q
* @param string $column * @param string $column
* @param string $value * @param string $value
* @return \Illuminate\Contracts\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
public static function queryColumnWithLocales( public static function queryColumnWithLocales(
string $defaultLocale, string $defaultLocale,
Builder $q, Builder $q,
string $column, string $column,
string $value string $value
): Builder { ): \Illuminate\Contracts\Database\Eloquent\Builder {
$currentLocale = app()->currentLocale(); $currentLocale = app()->currentLocale();
$locales = collect(config('app.locales')) $locales = collect(config('app.locales'))
->mapWithKeys(fn(string $locale) => [$locale => $locale]); ->mapWithKeys(fn(string $locale) => [$locale => $locale]);
@ -376,7 +376,7 @@ class ToolboxHelper
} }
/** /**
* Generates an array from a dot separated string * Generates an array from a dot separated string.
* *
* @param string $path * @param string $path
* @param mixed $value * @param mixed $value
@ -395,7 +395,7 @@ class ToolboxHelper
} }
/** /**
* Convert deeply an object to array * Convert deeply an object to array.
* *
* @param array|object $input * @param array|object $input
* @return array * @return array
@ -418,7 +418,7 @@ class ToolboxHelper
} }
/** /**
* Convert deeply an array to object * Convert deeply an array to object.
* *
* @param array|object $input * @param array|object $input
* @return object * @return object
@ -441,15 +441,15 @@ class ToolboxHelper
} }
/** /**
* Validate picture * Validate picture.
* *
* @param string $attribute * @param string $attribute
* @param string|null $value * @param string|null $value
* @param callback $fail * @param callable $fail
* @param object $sizes * @param object $sizes
* @return void * @return void
*/ */
public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes) public static function validatePicture(string $attribute, string|null $value, callable $fail, object $sizes): void
{ {
if (!($useStorage = Storage::exists($value)) and !File::exists($value)) { if (!($useStorage = Storage::exists($value)) and !File::exists($value)) {
$fail(trans(':attribute n\'existe pas dans le système de fichier', [ $fail(trans(':attribute n\'existe pas dans le système de fichier', [
@ -502,7 +502,7 @@ class ToolboxHelper
} }
/** /**
* Get the file full path * Get the file full path.
* *
* @param string $value * @param string $value
* @param boolean $useStorage * @param boolean $useStorage
@ -516,13 +516,13 @@ class ToolboxHelper
} }
/** /**
* Get the file mimetype * Get the file mimetype.
* *
* @param string $value * @param string $value
* @param boolean $useStorage * @param boolean $useStorage
* @return string|false * @return string|false
*/ */
private static function getUploadedFileMimeType(string $value, bool $useStorage) private static function getUploadedFileMimeType(string $value, bool $useStorage): string|false
{ {
return !$useStorage ? File::mimeType($value) : Storage::mimeType($value); return !$useStorage ? File::mimeType($value) : Storage::mimeType($value);
} }
@ -559,6 +559,6 @@ class ToolboxHelper
] ]
); );
return \response()->json($models ?? 500); return \response()->json($models);
} }
} }

View file

@ -16,7 +16,7 @@ class AddStatusMessages
* @return void * @return void
* @phpcs:disable Generic.Metrics.CyclomaticComplexity * @phpcs:disable Generic.Metrics.CyclomaticComplexity
*/ */
public function handle(TicketStatusChanged $event) public function handle(TicketStatusChanged $event): void
{ {
// phpcs:enable // phpcs:enable
$message = new Message(); $message = new Message();

View file

@ -14,7 +14,7 @@ class SendNotificationMailToAdmin
* @param \App\Events\NotifyAdmin $event * @param \App\Events\NotifyAdmin $event
* @return void * @return void
*/ */
public function handle(NotifyAdmin $event) public function handle(NotifyAdmin $event): void
{ {
$ticket = $event->ticket; $ticket = $event->ticket;
Mail::to(config('mail.MAIL_ADMIN')) Mail::to(config('mail.MAIL_ADMIN'))

View file

@ -14,10 +14,12 @@ class SendNotificationMailToTicketCreator
* @param \App\Events\NotifyTicketCreator $event * @param \App\Events\NotifyTicketCreator $event
* @return void * @return void
*/ */
public function handle(NotifyTicketCreator $event) public function handle(NotifyTicketCreator $event): void
{ {
$ticket = $event->ticket; $ticket = $event->ticket;
Mail::to($ticket->user()->withTrashed()->first()->email) /** @var \App\Models\User */
$user = $ticket->user();
Mail::to($user->withTrashed()->first()->email)
->send(new TicketUpdate($ticket, $event->corpsMaj)); ->send(new TicketUpdate($ticket, $event->corpsMaj));
} }
} }

View file

@ -16,7 +16,7 @@ class SendSubscriptionsNotificationsMail
* @param \App\Events\NotifySubscriptions $event * @param \App\Events\NotifySubscriptions $event
* @return void * @return void
*/ */
public function handle(NotifySubscriptions $event) public function handle(NotifySubscriptions $event): void
{ {
$ignoreConnectedUserEmail = Auth::user()->email ?? ''; $ignoreConnectedUserEmail = Auth::user()->email ?? '';
$ignoreUsers = $event->ignoreUsers ?? collect(); $ignoreUsers = $event->ignoreUsers ?? collect();

View file

@ -31,10 +31,10 @@ class NewTicket extends Mailable
* *
* @return $this * @return $this
*/ */
public function build() public function build(): self
{ {
$ticket = $this->ticket; $ticket = $this->ticket;
return $this->subject("[Support] Nouveau ticket n°" . $ticket->id) return $this->subject("[Support] Nouveau ticket n°" . $ticket->id)
->view('emails.new-ticket', compact('ticket')); ->view('emails.new-ticket', compact('ticket'));
} }
} }

View file

@ -37,11 +37,11 @@ class TicketMention extends Mailable
* *
* @return $this * @return $this
*/ */
public function build() public function build(): self
{ {
$ticket = $this->ticket; $ticket = $this->ticket;
$corpsMaj = ToolboxHelper::plainToHtml($this->corpsMaj); $corpsMaj = ToolboxHelper::plainToHtml($this->corpsMaj);
return $this->subject("[Support] Vous avez été mentionné sur le ticket n° $ticket->id") return $this->subject("[Support] Vous avez été mentionné sur le ticket n° $ticket->id")
->view('emails.ticket-mention', compact('ticket', 'corpsMaj')); ->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
} }
} }

View file

@ -37,11 +37,13 @@ class TicketUpdate extends Mailable
* *
* @return $this * @return $this
*/ */
public function build() public function build(): self
{ {
$ticket = $this->ticket; $ticket = $this->ticket;
/** @var \App\Models\Site */
$site = $ticket->site;
$corpsMaj = \html_entity_decode(ToolboxHelper::plainToHtml($this->corpsMaj)); $corpsMaj = \html_entity_decode(ToolboxHelper::plainToHtml($this->corpsMaj));
return $this->subject("[Support][{$ticket->site->name}] Ticket n°$ticket->id") return $this->subject("[Support][{$site->name}] Ticket n°$ticket->id")
->view('emails.ticket-update', compact('ticket', 'corpsMaj')); ->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
} }
} }

View file

@ -26,7 +26,7 @@ class UserCreatedMail extends Mailable
* *
* @return $this * @return $this
*/ */
public function build() public function build(): self
{ {
return $this return $this
->subject(sprintf('%s : Votre compte a été crée', config('app.name'))) ->subject(sprintf('%s : Votre compte a été crée', config('app.name')))

View file

@ -16,7 +16,7 @@ class Brand extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name' 'name'
@ -50,6 +50,7 @@ class Brand extends Model
*/ */
public static function deleteSites(Brand $brand): void public static function deleteSites(Brand $brand): void
{ {
/** @var \App\Models\Site $site */
foreach ($brand->sites as $site) { foreach ($brand->sites as $site) {
$site->brand_id = null; $site->brand_id = null;
$site->saveOrFail(); $site->saveOrFail();
@ -63,7 +64,7 @@ class Brand extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function sites() public function sites(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Site::class); return $this->hasMany(Site::class);
} }
@ -73,7 +74,7 @@ class Brand extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function accounts() public function accounts(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Account::class); return $this->hasMany(Account::class);
} }

View file

@ -16,7 +16,7 @@ class Company extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name' 'name'
@ -25,28 +25,28 @@ class Company extends Model
/** /**
* The accessors to append to the model's array form. * The accessors to append to the model's array form.
* *
* @var array * @var list<string>
*/ */
protected $appends = [ protected $appends = [
'value' 'value'
]; ];
/** /**
* HasMany Invoices * HasMany Invoices.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function invoices() public function invoices(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Invoice::class); return $this->hasMany(Invoice::class);
} }
/** /**
* Return value attribute for belongsto search component * Return value attribute for belongsto search component.
* *
* @return \Illuminate\Database\Eloquent\Casts\Attribute * @return \Illuminate\Database\Eloquent\Casts\Attribute
*/ */
protected function value(): Attribute protected function value(): \Illuminate\Database\Eloquent\Casts\Attribute
{ {
return new Attribute( return new Attribute(
get: fn () => $this->id, get: fn () => $this->id,

View file

@ -7,10 +7,10 @@ use App\Models\Brand;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* @property string $label * @property string $label
* @property AccountTypeEnum $type * @property \App\Enums\Credit\AccountTypeEnum $type
* @property integer $balance * @property integer $balance
* @property Brand $brand_id * @property integer $brand_id
*/ */
class Account extends Model class Account extends Model
{ {
@ -24,7 +24,7 @@ class Account extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'label', 'label',
@ -36,7 +36,7 @@ class Account extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'type' => AccountTypeEnum::class 'type' => AccountTypeEnum::class
@ -47,7 +47,7 @@ class Account extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::deleting(function () { static::deleting(function () {
throw new \Error('Action impossible'); throw new \Error('Action impossible');
@ -61,7 +61,7 @@ class Account extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function brand() public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Brand::class); return $this->belongsTo(Brand::class);
} }
@ -71,7 +71,7 @@ class Account extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne
*/ */
public function creditlogs() public function creditlogs(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->HasOne(CreditLog::class, 'credit_account_id'); return $this->HasOne(CreditLog::class, 'credit_account_id');
} }

View file

@ -6,10 +6,10 @@ use App\Enums\Credit\BalanceOperationEnum;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* @property BalanceOperationEnum $type * @property \App\Enums\Credit\BalanceOperationEnum $type
* @property double $amount * @property double $amount
* @property Account $credit_account_id * @property Account $credit_account_id
* @property date $created_at * @property \Illuminate\Support\Carbon $created_at
*/ */
class CreditLog extends Model class CreditLog extends Model
{ {
@ -23,7 +23,7 @@ class CreditLog extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'type', 'type',
@ -35,7 +35,7 @@ class CreditLog extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'type' => BalanceOperationEnum::class 'type' => BalanceOperationEnum::class
@ -46,7 +46,7 @@ class CreditLog extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (self $model) { static::creating(function (self $model) {
$model->created_at = now(); $model->created_at = now();
@ -66,22 +66,22 @@ class CreditLog extends Model
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* BelongsToMany estimation relation (1 nullable) * BelongsToMany estimation relation (1 nullable).
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function estimation() public function estimation(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Estimation::class, EstimationLog::class, 'credit_log_id', 'credit_estimation_id') return $this->belongsToMany(Estimation::class, EstimationLog::class, 'credit_log_id', 'credit_estimation_id')
->withTimestamps(); ->withTimestamps();
} }
/** /**
* BelongsTo account relation * BelongsTo account relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function account() public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Account::class, 'credit_account_id'); return $this->belongsTo(Account::class, 'credit_account_id');
} }

View file

@ -14,7 +14,7 @@ class Estimation extends Model
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'status' => EstimationStatusEnum::class 'status' => EstimationStatusEnum::class
@ -30,7 +30,7 @@ class Estimation extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'amount', 'status', 'credit_account_id' 'amount', 'status', 'credit_account_id'
@ -41,7 +41,7 @@ class Estimation extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::updating(function (self $model) { static::updating(function (self $model) {
if (!$model->original['validator_id'] !== $model->validator_id) { if (!$model->original['validator_id'] !== $model->validator_id) {
@ -62,43 +62,43 @@ class Estimation extends Model
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* BelongsTo Ticket relation * BelongsTo Ticket relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function ticket() public function ticket(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Ticket::class); return $this->belongsTo(Ticket::class);
} }
/** /**
* BelongsTo Credit\Account relation * BelongsTo Credit\Account relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function account() public function account(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Account::class, 'credit_account_id'); return $this->belongsTo(Account::class, 'credit_account_id');
} }
/** /**
* BelongsTo User relation * BelongsTo User relation
* The use who created the estimate * The use who created the estimate.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function estimator() public function estimator(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'estimator_id'); return $this->belongsTo(User::class, 'estimator_id');
} }
/** /**
* BelongsTo User relation (nullable) * BelongsTo User relation (nullable)
* The use who validated the estimate * The use who validated the estimate.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function validator() public function validator(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'validator_id'); return $this->belongsTo(User::class, 'validator_id');
} }

View file

@ -32,7 +32,7 @@ class Information extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'title', 'title',
@ -43,7 +43,7 @@ class Information extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'type' => InfoColorsEnum::class, 'type' => InfoColorsEnum::class,
@ -56,7 +56,7 @@ class Information extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::created(function () { static::created(function () {
cache()->put('infos', Information::all(), 3600); cache()->put('infos', Information::all(), 3600);

View file

@ -9,7 +9,6 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Mccarlosen\LaravelMpdf\LaravelMpdf;
/** /**
* @property string $ref * @property string $ref
@ -36,7 +35,7 @@ class Invoice extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'ref', 'ref',
@ -60,14 +59,14 @@ class Invoice extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'tasks' => 'array', 'tasks' => 'array',
'signed_date' => 'date', 'signed_date' => 'date',
'sent_client_date' => 'date', 'sent_client_date' => 'date',
'sent_accounting_date' => 'date', 'sent_accounting_date' => 'date',
'status' => InvoiceStatusEnum::class, 'status' => InvoiceStatusEnum::class,
]; ];
/** /**
@ -75,7 +74,7 @@ class Invoice extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (self $model) { static::creating(function (self $model) {
$model->ref = \sprintf( $model->ref = \sprintf(
@ -118,30 +117,30 @@ class Invoice extends Model
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* BelongsTo Site * BelongsTo Site.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function site() public function site(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->BelongsTo(Site::class); return $this->BelongsTo(Site::class);
} }
/** /**
* BelongsTo Company * BelongsTo Company.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function company() public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->BelongsTo(Company::class); return $this->BelongsTo(Company::class);
} }
/** /**
* BelongsTo Company * BelongsTo Company.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function companyInvoiced() public function companyInvoiced(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->BelongsTo(Company::class, 'invoiced_to_id'); return $this->BelongsTo(Company::class, 'invoiced_to_id');
} }
@ -149,9 +148,9 @@ class Invoice extends Model
// * METHODS // * METHODS
/** /**
* Get the tasks line structure skel * Get the tasks line structure skel.
* *
* @return array<string,string|float> * @return array<string, \App\Enums\Invoices\TaskTypeEnum::web|int|string|null>
*/ */
public static function getTaskStructure(): array public static function getTaskStructure(): array
{ {
@ -170,11 +169,11 @@ class Invoice extends Model
} }
/** /**
* Generate Invoice * Generate Invoice.
* *
* @return LaravelMpdf * @return \Mccarlosen\LaravelMpdf\LaravelMpdf
*/ */
public function generateInvoice(): LaravelMpdf public function generateInvoice(): \Mccarlosen\LaravelMpdf\LaravelMpdf
{ {
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Package> */ /** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Package> */
$packages = Package::get()->keyBy('id')->all(); $packages = Package::get()->keyBy('id')->all();
@ -186,10 +185,10 @@ class Invoice extends Model
'bo.pages.documents.invoice', 'bo.pages.documents.invoice',
$this->toArray(), $this->toArray(),
[ [
'site' => $this->site, 'site' => $this->site,
'company' => $this->company, 'company' => $this->company,
'companyInvoiced' => $this->companyInvoiced, 'companyInvoiced' => $this->companyInvoiced,
'packages' => $packages, 'packages' => $packages,
], ],
[ [
'mode' => '', 'mode' => '',

View file

@ -21,7 +21,7 @@ class Label extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'color' => HtmlColor::class, 'color' => HtmlColor::class,
@ -30,7 +30,7 @@ class Label extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
@ -42,7 +42,7 @@ class Label extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (self $model) { static::creating(function (self $model) {
ToolboxHelper::assertIsUnique($model, ['name']); ToolboxHelper::assertIsUnique($model, ['name']);
@ -59,7 +59,7 @@ class Label extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function tickets() public function tickets(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Ticket::class); return $this->belongsToMany(Ticket::class);
} }
@ -69,7 +69,7 @@ class Label extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function site() public function site(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Site::class); return $this->belongsTo(Site::class);
} }

View file

@ -9,12 +9,9 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
/** /**
* * @property string $message The message content.
* @property string $message The message content.
* @property \App\Enums\MessageTypeEnum $type The message is not visible for clients. * @property \App\Enums\MessageTypeEnum $type The message is not visible for clients.
* @property string $file The message joined file path. * @property string $file The message joined file path.
*
* @package App\Models
*/ */
class Message extends Model class Message extends Model
{ {
@ -23,7 +20,7 @@ class Message extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'message', 'message',
@ -33,7 +30,7 @@ class Message extends Model
/** /**
* The attributes that should be cast to native types. * The attributes that should be cast to native types.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'type' => MessageTypeEnum::class 'type' => MessageTypeEnum::class
@ -44,7 +41,7 @@ class Message extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::created(function (Message $message) { static::created(function (Message $message) {
$message->load(['user' => function ($q) { $message->load(['user' => function ($q) {
@ -109,7 +106,7 @@ class Message extends Model
event(new NotifySubscriptions( event(new NotifySubscriptions(
$message->ticket, $message->ticket,
trans('Nouvelle réponse de :name :<br> :message', [ trans('Nouvelle réponse de :name :<br> :message', [
'name' => $message->user->name, 'name' => $message->user->name,
'message' => $message->message 'message' => $message->message
]), ]),
$dontNotifyUsers $dontNotifyUsers
@ -125,7 +122,7 @@ class Message extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function ticket() public function ticket(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Ticket::class, 'ticket_id'); return $this->belongsTo(Ticket::class, 'ticket_id');
} }
@ -135,7 +132,7 @@ class Message extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'user_id'); return $this->belongsTo(User::class, 'user_id');
} }

View file

@ -23,7 +23,7 @@ class Package extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',

View file

@ -16,7 +16,7 @@ class Project extends Model
/** /**
* The attributes that are mass assignable. * The attributes that are mass assignable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
@ -30,7 +30,7 @@ class Project extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function site() public function site(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Site::class); return $this->belongsTo(Site::class);
} }

View file

@ -10,11 +10,11 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
/** /**
* @property string $name * @property string $name
* @property string $url_re7 * @property string $url_re7
* @property string $url_prod * @property string $url_prod
* @property integer $gitlab_project_id * @property integer $gitlab_project_id
* @property Brand $brand_id * @property integer|null $brand_id
*/ */
class Site extends Model class Site extends Model
{ {
@ -24,7 +24,7 @@ class Site extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
@ -37,7 +37,7 @@ class Site extends Model
/** /**
* The accessors to append to the model's array form. * The accessors to append to the model's array form.
* *
* @var array * @var list<string>
*/ */
protected $appends = [ protected $appends = [
'value' 'value'
@ -49,7 +49,7 @@ class Site extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (self $model) { static::creating(function (self $model) {
self::manageFields($model); self::manageFields($model);
@ -64,10 +64,10 @@ class Site extends Model
/** /**
* Common methods function. * Common methods function.
* *
* @param Model $model * @param self $model
* @return void * @return void
*/ */
private static function manageFields(Model $model) private static function manageFields(self $model): void
{ {
if ($model->url_re7) { if ($model->url_re7) {
ToolboxHelper::assertNoInternalUrls('url_re7', $model->url_re7); ToolboxHelper::assertNoInternalUrls('url_re7', $model->url_re7);
@ -82,31 +82,31 @@ class Site extends Model
/** /**
* HasMany Message relation * HasMany Message relation
* The users of type client that would have access to this site tickets * The users of type client that would have access to this site tickets.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function users() public function users(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(User::class); return $this->belongsToMany(User::class);
} }
/** /**
* HasMany Ticket relation * HasMany Ticket relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function tickets() public function tickets(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Ticket::class, 'site_id'); return $this->hasMany(Ticket::class, 'site_id');
} }
/** /**
* BelongsTo Brand relation * BelongsTo Brand relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function brand() public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Brand::class); return $this->belongsTo(Brand::class);
} }
@ -127,20 +127,20 @@ class Site extends Model
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function project() public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Project::class); return $this->belongsTo(Project::class);
} }
/** /**
* Return value attribute for belongsto search component * Return value attribute for belongsto search component.
* *
* @return \Illuminate\Database\Eloquent\Casts\Attribute * @return \Illuminate\Database\Eloquent\Casts\Attribute
*/ */
protected function value(): Attribute protected function value(): \Illuminate\Database\Eloquent\Casts\Attribute
{ {
return new Attribute( return new Attribute(
get: fn () => $this->id, get: fn() => $this->id,
); );
} }
} }

View file

@ -16,9 +16,21 @@ use App\Models\Ticket\TicketType;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
/**
* @property string $title The message joined file path.
* @property string $text Ticket description.
* @property \App\Models\Site $site_id Site associated.
* @property \App\Enums\Tickets\TicketTypeEnum $type Ticket type.
* @property \App\Enums\Tickets\TicketStatusEnum $status Ticket status.
* @property integer $is_internal Internal ticket or not.
* @property integer $order Ticket order.
* @property \Carbon\Carbon $date_mep Production date wished.
* @property \Carbon\Carbon $last_activity Last activity in the ticket.
* @property-read \Carbon\Carbon $created_at Created date.
* @property-read \Carbon\Carbon $updated_at Updated date.
*/
class Ticket extends Model class Ticket extends Model
{ {
use HasFactory; use HasFactory;
@ -26,24 +38,24 @@ class Ticket extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'title',
'text',
'site_id', 'site_id',
'type', 'type',
'status', 'status',
'is_internal',
'order', 'order',
'date_mep', 'date_mep',
'text',
'title',
'is_internal',
'last_activity', 'last_activity',
]; ];
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'is_internal' => 'bool', 'is_internal' => 'bool',
@ -58,7 +70,7 @@ class Ticket extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (Ticket $ticket) { static::creating(function (Ticket $ticket) {
// If bug force the ticket status on new. All the others are estimateTodo. // If bug force the ticket status on new. All the others are estimateTodo.
@ -70,7 +82,10 @@ class Ticket extends Model
} }
}); });
static::updating(function (Ticket $ticket) { static::updating(function (Ticket $ticket) {
if (!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order) { if (
!$ticket->original['status'] !== $ticket->status->value &&
$ticket->original['order'] === $ticket->order
) {
event(new TicketStatusChanged( event(new TicketStatusChanged(
$ticket, $ticket,
TicketStatusEnum::make($ticket->original['status']), TicketStatusEnum::make($ticket->original['status']),
@ -104,91 +119,93 @@ class Ticket extends Model
*/ */
private static function setOrder(self $model, bool $isArchived = false): void private static function setOrder(self $model, bool $isArchived = false): void
{ {
$model->order = \intval(self::query()->where('status', $isArchived ? '=' : '!=', TicketStatusEnum::archived)->max('order')) + 1; $model->order = \intval(self::query()
->where('status', $isArchived ? '=' : '!=', TicketStatusEnum::archived)
->max('order')) + 1;
} }
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* HasOne Credit\Estimation relation * HasOne Credit\Estimation relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasOne * @return \Illuminate\Database\Eloquent\Relations\HasOne
*/ */
public function estimation() public function estimation(): \Illuminate\Database\Eloquent\Relations\HasOne
{ {
return $this->hasOne(Estimation::class); return $this->hasOne(Estimation::class);
} }
/** /**
* BelongsTo Site relation * BelongsTo Site relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function site() public function site(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(Site::class); return $this->belongsTo(Site::class);
} }
/** /**
* BelongsTo User relation * BelongsTo User relation
* The user that created the ticket * The user that created the ticket.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function user() public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'created_by'); return $this->belongsTo(User::class, 'created_by');
} }
/** /**
* BelongsTo User relation * BelongsTo User relation
* The user that is in charge of the ticket * The user that is in charge of the ticket.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function assignedUser() public function assignedUser(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(User::class, 'assigned_to'); return $this->belongsTo(User::class, 'assigned_to');
} }
/** /**
* HasMany Message relation * HasMany Message relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function messages() public function messages(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Message::class, 'ticket_id'); return $this->hasMany(Message::class, 'ticket_id');
} }
/** /**
* BelongsToMany User relation * BelongsToMany User relation
* The Users that are following this ticket * The Users that are following this ticket.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function subscriptions() public function subscriptions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(User::class, 'subscriptions'); return $this->belongsToMany(User::class, 'subscriptions');
} }
/** /**
* BelongsToMany Label relation * BelongsToMany Label relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function labels() public function labels(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Label::class, 'label_ticket'); return $this->belongsToMany(Label::class, 'label_ticket');
} }
/** /**
* BelongsTo ticket_type * BelongsTo ticket_type.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function ticketType() public function ticketType(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{ {
return $this->belongsTo(TicketType::class, 'type', 'type'); return $this->belongsTo(TicketType::class, 'type', 'type');
} }
@ -207,12 +224,12 @@ class Ticket extends Model
/** /**
* Parse message @user tags and send emails to concerned users * Parse message @user tags and send emails to concerned users
* returns and array with to users notified * returns and array with to users notified.
* *
* @param Message $message * @param Message $message
* @return Collection * @return \Illuminate\Support\Collection
*/ */
public function sendBeenMentionnedToUser(Message $message): Collection public function sendBeenMentionnedToUser(Message $message): \Illuminate\Support\Collection
{ {
$ticket = $this; $ticket = $this;
// Find @user + send mail si un seul user est trouvé. // Find @user + send mail si un seul user est trouvé.
@ -259,14 +276,14 @@ class Ticket extends Model
} }
/** /**
* full_name getter * full_name getter.
* *
* @return string * @return string
*/ */
public function getFullNameAttribute(): string public function getFullNameAttribute(): string
{ {
return trans('Ticket n° :ticketId : :ticketSiteName', [ return trans('Ticket n° :ticketId : :ticketSiteName', [
'ticketId' => $this->id, 'ticketId' => $this->id,
'ticketSiteName' => $this->site->name 'ticketSiteName' => $this->site->name
]); ]);
} }
@ -280,7 +297,8 @@ class Ticket extends Model
public function accountIsValidForThisTicket(Account $account): bool public function accountIsValidForThisTicket(Account $account): bool
{ {
/** @var \App\Models\Brand|null */ /** @var \App\Models\Brand|null */
if (!($siteBrand = optional($this->site)->brand)) { $siteBrand = optional($this->site)->brand;
if (!$siteBrand) {
return false; return false;
} }

View file

@ -19,7 +19,7 @@ class TicketType extends Model
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'type', 'type',
@ -29,7 +29,7 @@ class TicketType extends Model
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'type' => TicketTypeEnum::class, 'type' => TicketTypeEnum::class,
@ -40,7 +40,7 @@ class TicketType extends Model
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function () { static::creating(function () {
throw new \Error('Action impossible'); throw new \Error('Action impossible');
@ -56,11 +56,11 @@ class TicketType extends Model
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* BelongsToMany tickets * BelongsToMany tickets.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function tickets() public function tickets(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Ticket::class, 'type', 'type'); return $this->hasMany(Ticket::class, 'type', 'type');
} }

View file

@ -5,7 +5,6 @@ namespace App\Models;
use App\Enums\Users\RoleEnum; use App\Enums\Users\RoleEnum;
use App\Jobs\SendUserCreatedEmail; use App\Jobs\SendUserCreatedEmail;
use App\Notifications\ResetPassword; use App\Notifications\ResetPassword;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
@ -20,7 +19,7 @@ use Illuminate\Support\Str;
* @property string $password * @property string $password
* @property string $remember_token * @property string $remember_token
* @property RoleEnum $role * @property RoleEnum $role
* @property Collection $sites * @property \Illuminate\Database\Eloquent\Collection $sites
*/ */
class User extends Authenticatable class User extends Authenticatable
{ {
@ -38,7 +37,7 @@ class User extends Authenticatable
/** /**
* The attributes that are fillable. * The attributes that are fillable.
* *
* @var array * @var list<string>
*/ */
protected $fillable = [ protected $fillable = [
'name', 'name',
@ -52,7 +51,7 @@ class User extends Authenticatable
/** /**
* The attributes that should be hidden for arrays. * The attributes that should be hidden for arrays.
* *
* @var array * @var list<string>
*/ */
protected $hidden = [ protected $hidden = [
'password', 'password',
@ -62,11 +61,11 @@ class User extends Authenticatable
/** /**
* The attributes that should be cast. * The attributes that should be cast.
* *
* @var array * @var array<string, string>
*/ */
protected $casts = [ protected $casts = [
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
'role' => RoleEnum::class 'role' => RoleEnum::class
]; ];
/** /**
@ -74,7 +73,7 @@ class User extends Authenticatable
* *
* @return void * @return void
*/ */
protected static function booted() protected static function booted(): void
{ {
static::creating(function (User $user) { static::creating(function (User $user) {
if (\is_null($user->password)) { if (\is_null($user->password)) {
@ -100,32 +99,32 @@ class User extends Authenticatable
// * METHODS // * METHODS
/** /**
* get User brands * Get User brands.
* *
* @return \Illuminate\Database\Eloquent\Collection<\App\Models\Brand> * @return \Illuminate\Database\Eloquent\Collection<(int|string), \App\Models\Brand>
*/ */
public function brands() public function brands(): \Illuminate\Database\Eloquent\Collection
{ {
return $this->sites->pluck('brand')->filter(); return $this->sites->pluck('brand')->filter();
} }
/** /**
* Send User creation confirm mail * Send User creation confirm mail.
* *
* @return void * @return void
*/ */
public function sendMailConfirm() public function sendMailConfirm(): void
{ {
dispatch(new SendUserCreatedEmail($this)); dispatch(new SendUserCreatedEmail($this));
} }
/** /**
* Send User reset password mail * Send User reset password mail.
* *
* @param mixed $token * @param mixed $token
* @return void * @return void
*/ */
public function sendPasswordResetNotification(mixed $token) public function sendPasswordResetNotification(mixed $token): void
{ {
/** @var string $token */ /** @var string $token */
$this->notify(new ResetPassword($token)); $this->notify(new ResetPassword($token));
@ -143,11 +142,11 @@ class User extends Authenticatable
} }
/** /**
* Get All Admin users * Get All Admin users.
* *
* @return Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
public static function adminUsers(): Collection public static function adminUsers(): \Illuminate\Database\Eloquent\Collection
{ {
return Cache::remember('AdminUsers', 86400, function () { return Cache::remember('AdminUsers', 86400, function () {
return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->orderBy('name')->get(); return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->orderBy('name')->get();
@ -157,41 +156,41 @@ class User extends Authenticatable
// * RELATIONSHIPS // * RELATIONSHIPS
/** /**
* HasMany Ticket relation * HasMany Ticket relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function tickets() public function tickets(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Ticket::class, 'created_by'); return $this->hasMany(Ticket::class, 'created_by');
} }
/** /**
* HasMany Message relation * HasMany Message relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return \Illuminate\Database\Eloquent\Relations\HasMany
*/ */
public function messages() public function messages(): \Illuminate\Database\Eloquent\Relations\HasMany
{ {
return $this->hasMany(Message::class, 'user_id'); return $this->hasMany(Message::class, 'user_id');
} }
/** /**
* BelongsToMany Ticket relation * BelongsToMany Ticket relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function subscriptions() public function subscriptions(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Ticket::class, 'subscriptions'); return $this->belongsToMany(Ticket::class, 'subscriptions');
} }
/** /**
* BelongsToMany Site relation * BelongsToMany Site relation.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/ */
public function sites() public function sites(): \Illuminate\Database\Eloquent\Relations\BelongsToMany
{ {
return $this->belongsToMany(Site::class); return $this->belongsToMany(Site::class);
} }

View file

@ -16,7 +16,7 @@ class ResetPassword extends ResetPasswordNotification
* @param mixed $url * @param mixed $url
* @return \Illuminate\Notifications\Messages\MailMessage * @return \Illuminate\Notifications\Messages\MailMessage
*/ */
protected function buildMailMessage(mixed $url) protected function buildMailMessage(mixed $url): \Illuminate\Notifications\Messages\MailMessage
{ {
$message = (new MailMessage()) $message = (new MailMessage())
->subject(trans('Reinitialisation de mot de passe')) ->subject(trans('Reinitialisation de mot de passe'))

View file

@ -14,7 +14,7 @@ class AccountPolicy
* *
* @return boolean * @return boolean
*/ */
public function viewAny() public function viewAny(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -24,7 +24,7 @@ class AccountPolicy
* *
* @return boolean * @return boolean
*/ */
public function view() public function view(): bool
{ {
return false; return false;
} }
@ -35,7 +35,7 @@ class AccountPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function create(User $user) public function create(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -45,7 +45,7 @@ class AccountPolicy
* *
* @return boolean * @return boolean
*/ */
public function update() public function update(): bool
{ {
return false; return false;
} }
@ -56,7 +56,7 @@ class AccountPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function delete(User $user) public function delete(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -66,7 +66,7 @@ class AccountPolicy
* *
* @return boolean * @return boolean
*/ */
public function credit() public function credit(): bool
{ {
return true; return true;
} }

View file

@ -15,7 +15,7 @@ class CreditLogPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function update(User $user) public function update(User $user): bool
{ {
return $user->isAdmin() or $user->brands()->count() > 0; return $user->isAdmin() or $user->brands()->count() > 0;
} }

View file

@ -19,7 +19,7 @@ class EstimationPolicy
* @return boolean * @return boolean
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter
*/ */
public function answer(User $user, Estimation $estimation) public function answer(User $user, Estimation $estimation): bool
{ {
// phpcs:enable // phpcs:enable
return $estimation->status->equals(EstimationStatusEnum::pending); return $estimation->status->equals(EstimationStatusEnum::pending);

View file

@ -13,7 +13,7 @@ class SitePolicy
* *
* @return boolean * @return boolean
*/ */
public function viewAny() public function viewAny(): bool
{ {
return auth()->check(); return auth()->check();
} }

View file

@ -7,7 +7,6 @@ use App\Enums\Tickets\TicketTypeEnum;
use App\Enums\Users\RoleEnum; use App\Enums\Users\RoleEnum;
use App\Models\Ticket; use App\Models\Ticket;
use App\Models\User; use App\Models\User;
use Error;
use Illuminate\Auth\Access\HandlesAuthorization; use Illuminate\Auth\Access\HandlesAuthorization;
class TicketPolicy class TicketPolicy
@ -19,7 +18,7 @@ class TicketPolicy
* *
* @return boolean * @return boolean
*/ */
public function viewAny() public function viewAny(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -29,7 +28,7 @@ class TicketPolicy
* *
* @return boolean * @return boolean
*/ */
public function view() public function view(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -39,7 +38,7 @@ class TicketPolicy
* *
* @return boolean * @return boolean
*/ */
public function create() public function create(): bool
{ {
return auth()->check(); return auth()->check();
} }
@ -51,7 +50,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function update(User $user, Ticket $ticket) public function update(User $user, Ticket $ticket): bool
{ {
return $user->sites->contains($ticket->site_id) return $user->sites->contains($ticket->site_id)
|| $user->isAdmin(); || $user->isAdmin();
@ -63,7 +62,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function changeStatus(User $user) public function changeStatus(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -74,7 +73,18 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function linkTicket(User $user) public function linkTicket(User $user): bool
{
return $user->isAdmin();
}
/**
* Determine if the user can change ticket order.
*
* @param \App\Models\User $user
* @return boolean
*/
public function changeOrder(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -85,7 +95,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function changeInternalStatus(User $user) public function changeInternalStatus(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -95,7 +105,7 @@ class TicketPolicy
* *
* @return boolean * @return boolean
*/ */
public function delete() public function delete(): bool
{ {
return false; return false;
} }
@ -105,7 +115,7 @@ class TicketPolicy
* *
* @return boolean * @return boolean
*/ */
public function forceDelete() public function forceDelete(): bool
{ {
return false; return false;
} }
@ -117,7 +127,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function restore(User $user, Ticket $ticket) public function restore(User $user, Ticket $ticket): bool
{ {
return $user->sites->contains($ticket->site_id) return $user->sites->contains($ticket->site_id)
|| $user->isAdmin(); || $user->isAdmin();
@ -131,7 +141,7 @@ class TicketPolicy
* @return boolean * @return boolean
* phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/ */
public function suscribeToTicket(User $user, Ticket $ticket) public function suscribeToTicket(User $user, Ticket $ticket): bool
{ {
// phpcs:enable // phpcs:enable
return !$ticket->status->equals(TicketStatusEnum::archived); return !$ticket->status->equals(TicketStatusEnum::archived);
@ -145,7 +155,7 @@ class TicketPolicy
* @return boolean * @return boolean
* phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed * phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/ */
public function createMessage(User $user, Ticket $ticket) public function createMessage(User $user, Ticket $ticket): bool
{ {
// phpcs:enable // phpcs:enable
return !$ticket->status->equals(TicketStatusEnum::archived); return !$ticket->status->equals(TicketStatusEnum::archived);
@ -157,7 +167,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function createPrivateMessage(User $user) public function createPrivateMessage(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -169,7 +179,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function updateMessage(User $user, Ticket $ticket) public function updateMessage(User $user, Ticket $ticket): bool
{ {
return !$ticket->status->equals(TicketStatusEnum::archived) return !$ticket->status->equals(TicketStatusEnum::archived)
&& $user->isAdmin(); && $user->isAdmin();
@ -181,7 +191,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function reopen(User $user) public function reopen(User $user): bool
{ {
return $user->role->equals(RoleEnum::client); return $user->role->equals(RoleEnum::client);
} }
@ -193,7 +203,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function assignTo(User $user, Ticket $ticket) public function assignTo(User $user, Ticket $ticket): bool
{ {
return $user->isAdmin() return $user->isAdmin()
&& !$ticket->status->equals(TicketStatusEnum::archived) && !$ticket->status->equals(TicketStatusEnum::archived)
@ -206,7 +216,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function assignTickets(User $user) public function assignTickets(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -217,7 +227,7 @@ class TicketPolicy
* @param \App\Models\User $user * @param \App\Models\User $user
* @return boolean * @return boolean
*/ */
public function assignLabels(User $user) public function assignLabels(User $user): bool
{ {
return $user->isAdmin(); return $user->isAdmin();
} }
@ -229,7 +239,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function estimate(User $user, Ticket $ticket) public function estimate(User $user, Ticket $ticket): bool
{ {
if (!($brand = $ticket->site->brand)) { if (!($brand = $ticket->site->brand)) {
return false; return false;
@ -248,7 +258,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function validateEstimate(User $user, Ticket $ticket) public function validateEstimate(User $user, Ticket $ticket): bool
{ {
if (!($brand = $ticket->site->brand)) { if (!($brand = $ticket->site->brand)) {
return false; return false;
@ -268,7 +278,7 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function cancelEstimate(User $user, Ticket $ticket) public function cancelEstimate(User $user, Ticket $ticket): bool
{ {
return $user->role->equals(RoleEnum::developper) return $user->role->equals(RoleEnum::developper)
&& $ticket->estimation()->exists(); && $ticket->estimation()->exists();
@ -281,24 +291,13 @@ class TicketPolicy
* @param \App\Models\Ticket $ticket * @param \App\Models\Ticket $ticket
* @return boolean * @return boolean
*/ */
public function createGitlabIssue(User $user, Ticket $ticket) public function createGitlabIssue(User $user, Ticket $ticket): bool
{ {
return $user->role->equals(RoleEnum::developper) return $user->role->equals(RoleEnum::developper)
&& ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution) || $ticket->type->equals(TicketTypeEnum::newsletter)) && ($ticket->type->equals(TicketTypeEnum::bug)
|| $ticket->type->equals(TicketTypeEnum::evolution)
|| $ticket->type->equals(TicketTypeEnum::newsletter))
&& !\is_null($ticket->site->gitlab_project_id) && !\is_null($ticket->site->gitlab_project_id)
&& \is_null($ticket->gitlab_issue); && \is_null($ticket->gitlab_issue);
} }
/**
* Determine if the user can changeOrder
*
* @param User $user
* @return bool
* @throws Error
*/
public function changeOrder(User $user)
{
return $user->role->equals(RoleEnum::developper);
}
} }

View file

@ -13,7 +13,7 @@ class AppServiceProvider extends ServiceProvider
* *
* @return void * @return void
*/ */
public function boot() public function boot(): void
{ {
// * HTTPS FIX // * HTTPS FIX
URL::forceScheme('https'); URL::forceScheme('https');

View file

@ -12,7 +12,7 @@ class BroadcastServiceProvider extends ServiceProvider
* *
* @return void * @return void
*/ */
public function boot() public function boot(): void
{ {
Broadcast::routes(); Broadcast::routes();

Some files were not shown because too many files have changed in this diff Show more