Preserva base local aceite de identidade e acessos
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Identity\Models;
|
||||
|
||||
use App\Shared\Context\BelongsToCompany;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
final class Unit extends Model
|
||||
{
|
||||
use BelongsToCompany;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope('unit-access', function (\Illuminate\Database\Eloquent\Builder $query): void {
|
||||
$query->whereIn('units.id', app(\App\Shared\Context\CompanyContext::class)->permittedUnitIds());
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user