Invoices can be uploaded
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user