Invoices can be uploaded

This commit is contained in:
2026-02-11 15:40:06 +01:00
parent bccfc11687
commit ee7fc637f1
47 changed files with 1751 additions and 67 deletions

View File

@@ -8,6 +8,17 @@ use App\Models\CostUnit;
use App\Resources\CostUnitResource;
class CostUnitRepository {
public function getCostUnitsForNewInvoice(string $type) : array {
return $this->getCostUnitsByCriteria([
'allow_new' => true,
'type' => $type,
'archived' => false
], true, true);
}
public function getCurrentEvents() : array {
return $this->getCostUnitsByCriteria([
'allow_new' => true,
@@ -38,8 +49,8 @@ class CostUnitRepository {
]);
}
public function getById(int $id) : ?CostUnit {
$costUnits = self::getCostUnitsByCriteria(['id' => $id], false);
public function getById(int $id, bool $disableAccessCheck = false) : ?CostUnit {
$costUnits = self::getCostUnitsByCriteria(['id' => $id], false, $disableAccessCheck);
if (count($costUnits) === 0) {
return null;
}
@@ -47,7 +58,7 @@ class CostUnitRepository {
}
public function getCostUnitsByCriteria(array $criteria, bool $forDisplay = true) : array {
public function getCostUnitsByCriteria(array $criteria, bool $forDisplay = true, $disableAccessCheck = false) : array {
$tenant = app('tenant');
$canSeeAll = false;
@@ -71,7 +82,7 @@ class CostUnitRepository {
$visibleCostUnits = [];
/** @var CostUnit $costUnit */
foreach (Costunit::where($criteria)->get() as $costUnit) {
if ($costUnit->tresurers()->where('user_id', $user->id)->exists() || $canSeeAll) {
if ($costUnit->tresurers()->where('user_id', $user->id)->exists() || $canSeeAll || $disableAccessCheck) {
if ($forDisplay) {
$visibleCostUnits[] = new CostUnitResource($costUnit)->toArray(request());
} else {

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Repositories;
use App\Models\PageText;
class PageTextRepository {
public function getPageText(string $name) : string {
$name = strtoupper($name);
$pageText = PageText::where(['name' => $name])->first();
if (null === $pageText) {
PageText::create(['name' => $name, 'content' => '']);
return strtoupper($name);
}
return $pageText->content;
}
}

View File

@@ -17,4 +17,34 @@ class UserRepository {
return $token === $user->activation_token;
}
public function getCurrentUserDetails() : array {
$user = auth()->user();
$return = [
'userId' => null,
'userName' => '',
'userEmail' => '',
'userTelephone' => '',
'userAccountOwner' => '',
'userAccountIban' => '',
];
if (null !== auth()->user()) {
$return = [
'userId' => $user->id,
'userName' => trim($user->getOfficialName()),
'userEmail' => trim($user->email),
'userTelephone' => trim($user->phone),
'userAccountOwner' => trim($user->bank_account_owner),
'userAccountIban' => trim($user->bank_account_iban),
];
if ($return['userAccountOwner'] === '') {
$return['userAccountOwner'] = $return['userName'];
}
}
return $return;
}
}