Code improvements

This commit is contained in:
2026-09-04 09:27:48 +02:00
parent d23e6c3914
commit 4bb64b0053
51 changed files with 30702 additions and 87 deletions
+3 -3
View File
@@ -2,6 +2,7 @@
namespace App\Repositories;
use \currentUser;
use App\Enumerations\CostUnitType;
use App\Enumerations\InvoiceStatus;
use App\Enumerations\InvoiceType;
@@ -67,8 +68,7 @@ class CostUnitRepository {
}
public function getCostUnitsByCriteria(array $criteria, bool $forDisplay = true, $disableAccessCheck = false) : array {
$user = Auth()->user();
$user = currentUser();
if ($disableAccessCheck) {
$canSeeAll = true;
} else {
@@ -97,7 +97,7 @@ class CostUnitRepository {
public function listForSummary(int $maxCountCostUnits) : array {
$costUnits = $this->getCostUnitsByCriteria([
'archived' => false,
'tenant' => app('tenant')->slug,
'tenant' => currentTenant()->slug,
],false);
foreach ($costUnits as &$cu) {
@@ -297,7 +297,7 @@ class EventParticipantRepository {
public function getMyParticipations(?int $maxEvents = null) : array {
$participations = [];
$user = auth()->user();
$user = currentUser();
if ($user === null) {
return $participations;
}
@@ -326,13 +326,13 @@ class EventParticipantRepository {
}
public function getMyParticipationByIdentifier(string $identifier) : ?EventParticipant {
$user = auth()->user();
$user = currentUser();
if ($user === null) {
return null;
}
return EventParticipant::where('identifier', $identifier)
->where('tenant', app('tenant')->slug)
->where('tenant', currentTenant()->slug)
->where('user_id', $user->id)
->whereNull('unregistered_at')
->first();
+5 -5
View File
@@ -20,7 +20,7 @@ class InvoiceRepository {
];
$user = auth()->user();
$user = currentUser();
if (null === $user) {
return $invoices;
}
@@ -41,7 +41,7 @@ class InvoiceRepository {
}
public function getUnexportedInvoices() : Collection {
return Invoice::where(['tenant' => app('tenant')->slug, 'status' => InvoiceStatus::INVOICE_STATUS_EXPORTED, 'upload_required' => true])->get();
return Invoice::where(['tenant' => currentTenant()->slug, 'status' => InvoiceStatus::INVOICE_STATUS_EXPORTED, 'upload_required' => true])->get();
}
public function getByStatus(CostUnit $costUnit, string $status, bool $forDisplay = true) : array {
@@ -63,8 +63,8 @@ class InvoiceRepository {
foreach (Invoice::where(
[
'status' => $status,
'user_id' => auth()->user()->id,
'tenant' => app('tenant')->slug,
'user_id' => currentUserOrFail()->id,
'tenant' => currentTenant()->slug,
]
)->get() as $invoice) {
@@ -79,7 +79,7 @@ class InvoiceRepository {
return null;
}
$isTreasurer = $invoice->costUnit()->first()->treasurers()->where('user_id', auth()->user()->id)->exists();
$isTreasurer = $invoice->costUnit()->first()->treasurers()->where('user_id', currentUserOrFail()->id)->exists();
if ($isTreasurer) {
return $invoice;
}
+2 -2
View File
@@ -20,7 +20,7 @@ class UserRepository {
}
public function getCurrentUserDetails() : array {
$user = auth()->user();
$user = currentUser();
$return = [
'userId' => null,
@@ -31,7 +31,7 @@ class UserRepository {
'userAccountIban' => '',
];
if (null !== auth()->user()) {
if ($user !== null) {
$return = [
'userId' => $user->id,
'userName' => trim($user->getOfficialName()),