- FileObserver: 파일 생성/삭제 시 tenant.storage_used 자동 업데이트 - RecalculateTenantStorageCommand: 기존 데이터 재계산 명령어 - php artisan tenant:recalculate-storage [--tenant=ID] [--dry-run] - 음수 storage_used 방지 로직 포함 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.5 KiB
PHP
54 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Boards\File;
|
|
use App\Models\Boards\Post;
|
|
use App\Models\Tenants\Department;
|
|
use App\Models\User;
|
|
use App\Observers\FileObserver;
|
|
use App\Services\SidebarMenuService;
|
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
// SidebarMenuService 싱글턴 등록
|
|
$this->app->singleton(SidebarMenuService::class);
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
// File Observer: 파일 생성/삭제 시 테넌트 저장소 사용량 자동 업데이트
|
|
File::observe(FileObserver::class);
|
|
|
|
// Morph Map: Polymorphic 관계 모델 등록
|
|
Relation::enforceMorphMap([
|
|
'user' => User::class,
|
|
'post' => Post::class,
|
|
'department' => Department::class,
|
|
]);
|
|
|
|
// 사이드바에 메뉴 데이터 전달
|
|
View::composer('partials.sidebar', function ($view) {
|
|
$menuService = app(SidebarMenuService::class);
|
|
$menusBySection = $menuService->getMenusBySection();
|
|
|
|
$view->with([
|
|
'mainMenus' => $menusBySection['main'],
|
|
'toolsMenus' => $menusBySection['tools'],
|
|
'labsMenus' => $menusBySection['labs'],
|
|
]);
|
|
});
|
|
}
|
|
}
|