commit compras4 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 19:13:31 +02:00
parent 9cf9764710
commit 7486007fcf
41 changed files with 1270 additions and 66 deletions
+4 -1
View File
@@ -2,6 +2,8 @@
namespace App\Models\Concerns;
use App\Services\ReplenishmentRun;
use App\Services\RequisitionExpiryRun;
use Illuminate\Database\Eloquent\Builder;
trait BelongsToTenant
@@ -9,7 +11,8 @@ trait BelongsToTenant
protected static function bootBelongsToTenant(): void
{
static::addGlobalScope('tenant', function (Builder $query) {
$tenantId = auth()->check() ? auth()->user()->tenant_id : app(\App\Services\ReplenishmentRun::class)->tenantId();
$tenantId = auth()->check() ? auth()->user()->tenant_id : (app(ReplenishmentRun::class)->tenantId()
?? app(RequisitionExpiryRun::class)->tenantId());
$query->where($query->getModel()->qualifyColumn('tenant_id'), $tenantId ?? 0);
});
}