js(__DIR__ . '/js/dist/forum.js'), (new Extend\Frontend('admin')) ->js(__DIR__ . '/js/dist/admin.js'), (new Extend\User()) ->displayNameDriver('nickname', NicknameDriver::class), (new Extend\Event()) ->listen(Saving::class, SaveNicknameToDatabase::class) ->listen(ConfigureUserGambits::class, SetUserNicknameGambit::class), (new Extend\ApiSerializer(UserSerializer::class)) ->attribute('canEditOwnNickname', function ($serializer, $user) { $actor = $serializer->getActor(); return $actor->id === $user->id && $serializer->getActor()->can('editOwnNickname', $user); }), (new Extend\ApiSerializer(ForumSerializer::class)) ->attribute('displayNameDriver', function ($serializer, $user) { return app(SettingsRepositoryInterface::class)->get('display_name_driver', 'username'); }), (new Extend\Validator(UserValidator::class)) ->configure(AddNicknameValidation::class), ];