@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user