This commit is contained in:
mrKamoo
2026-09-30 16:27:32 +02:00
commit 310724708f
147 changed files with 21327 additions and 0 deletions
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers\Admin\Concerns;
use Illuminate\Database\Eloquent\Model;
/** Cloisonnement par tenant : un admin ne voit et ne modifie que les données de sa collectivité. */
trait ScopedToTenant
{
protected function tenantId(): int
{
return (int) auth()->user()->tenant_id;
}
protected function ensureTenant(Model $model): void
{
abort_unless((int) $model->tenant_id === $this->tenantId(), 404);
}
protected function actor(): string
{
return (string) auth()->user()->email;
}
}