style: Laravel Pint 코드 포맷팅 적용
- PSR-12 스타일 가이드 준수 - 302개 파일 스타일 이슈 자동 수정 - 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
@@ -11,16 +11,18 @@ class MenuObserver
|
||||
protected function actions(): array
|
||||
{
|
||||
// config/authz.php 에서 오버라이드 가능 (없으면 기본값)
|
||||
return config('authz.menu_actions', ['view','create','update','delete','approve']);
|
||||
return config('authz.menu_actions', ['view', 'create', 'update', 'delete', 'approve']);
|
||||
}
|
||||
|
||||
protected string $guard = 'api';
|
||||
|
||||
public function created(Menu $menu): void
|
||||
{
|
||||
if (!$this->shouldHandle($menu)) return;
|
||||
if (! $this->shouldHandle($menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setTeam((int)$menu->tenant_id);
|
||||
$this->setTeam((int) $menu->tenant_id);
|
||||
$this->ensurePermissions($menu);
|
||||
$this->forgetCache();
|
||||
}
|
||||
@@ -33,27 +35,33 @@ public function updated(Menu $menu): void
|
||||
|
||||
public function deleted(Menu $menu): void
|
||||
{
|
||||
if (!$this->shouldHandle($menu)) return;
|
||||
if (! $this->shouldHandle($menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setTeam((int)$menu->tenant_id);
|
||||
$this->setTeam((int) $menu->tenant_id);
|
||||
$this->removePermissions($menu);
|
||||
$this->forgetCache();
|
||||
}
|
||||
|
||||
public function restored(Menu $menu): void
|
||||
{
|
||||
if (!$this->shouldHandle($menu)) return;
|
||||
if (! $this->shouldHandle($menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setTeam((int)$menu->tenant_id);
|
||||
$this->setTeam((int) $menu->tenant_id);
|
||||
$this->ensurePermissions($menu);
|
||||
$this->forgetCache();
|
||||
}
|
||||
|
||||
public function forceDeleted(Menu $menu): void
|
||||
{
|
||||
if (!$this->shouldHandle($menu)) return;
|
||||
if (! $this->shouldHandle($menu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setTeam((int)$menu->tenant_id);
|
||||
$this->setTeam((int) $menu->tenant_id);
|
||||
$this->removePermissions($menu);
|
||||
$this->forgetCache();
|
||||
}
|
||||
@@ -61,7 +69,7 @@ public function forceDeleted(Menu $menu): void
|
||||
/** teams 사용 시 tenant_id 없는 공용 메뉴는 스킵하는 게 안전 */
|
||||
protected function shouldHandle(Menu $menu): bool
|
||||
{
|
||||
return !is_null($menu->tenant_id);
|
||||
return ! is_null($menu->tenant_id);
|
||||
}
|
||||
|
||||
protected function setTeam(int $tenantId): void
|
||||
@@ -73,16 +81,16 @@ protected function ensurePermissions(Menu $menu): void
|
||||
{
|
||||
foreach ($this->actions() as $act) {
|
||||
Permission::firstOrCreate([
|
||||
'tenant_id' => (int)$menu->tenant_id,
|
||||
'tenant_id' => (int) $menu->tenant_id,
|
||||
'guard_name' => $this->guard,
|
||||
'name' => "menu:{$menu->id}.{$act}",
|
||||
'name' => "menu:{$menu->id}.{$act}",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removePermissions(Menu $menu): void
|
||||
{
|
||||
Permission::where('tenant_id', (int)$menu->tenant_id)
|
||||
Permission::where('tenant_id', (int) $menu->tenant_id)
|
||||
->where('guard_name', $this->guard)
|
||||
->where(function ($q) use ($menu) {
|
||||
foreach ($this->actions() as $act) {
|
||||
|
||||
Reference in New Issue
Block a user