-
app/Observers/OrganizationObserver.php
Open in GitHubuse App\Jobs\LoadOrganizationRepositories; use App\Jobs\UpdateOrganizationDetails; use App\Models\Organization; use App\Models\Repository; class OrganizationObserver { public function created(Organization $organization): void { UpdateOrganizationDetails::dispatch($organization); LoadOrganizationRepositories::dispatch($organization); } public function deleting(Organization $organization): void { $organization->members()->detach(); $organization->repositories()->each(fn (Repository $repository) => $repository->delete()); } }
-
app/Providers/EventServiceProvider.php
Open in GitHubuse App\Models\Organization; use App\Models\Repository; use App\Models\User; use App\Observers\OrganizationObserver; use App\Observers\RepositoryObserver; use App\Observers\UserObserver; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { // public function boot(): void { User::observe(UserObserver::class); Organization::observe(OrganizationObserver::class); Repository::observe(RepositoryObserver::class); } }