why loadWhere callback is never called there

 (new Extend\ApiController(ShowForumController::class))
	->loadWhere('groups', function ($query, $request) {
		echo 'something';
	})

    bradraj instead of using echo, include symfony/var-dumper as a dev dependency and then hard end the output (as laravel does) with dd('something')

    It is possible that the output is buffered or reset or that the echo is not shown outside of its own closure.

    PS, this is for Flarum 1.x I assume?

      luceos yes, it's for Flarum 1.8.9. I'm tried dd, throw and echo. The callback is simply never called.

        bradraj then we need more information:

        • where does this code live?
        • is the file in which the code lives executed?

        Please provide more information so we can get to the resolution asap.

          luceos yes. It's just empty extension.

          <?php
          
          namespace My\FlarumExt;
          
          use Flarum\Extend;
          use Flarum\Api\Controller\ShowForumController;
          
          return [
              (new Extend\ApiController(ShowForumController::class))
                  ->loadWhere('groups', function ($query, $request) {
                      echo 'something';
                      dd('something');
          	    throw 1;
                  })
          ];

          Yes, other things are executed well, the problem occured only with this

          luceos found the issue. AbstractSerializeController::loadRelations is not calling in ShowForumController. And it's in this function that callbacks are called.

          Are there way to force eager loads the required relationships even if controller is not calling loadRelations? ( It's protected function so I can't even manually call it )

          I'm on mobile so cannot check further right now, but I believe the extender you are using is specifically for serializers based on Eloquent models. But the forum serializer is not based on a model, and therefore doesn't have Eloquent relationships.

          The relations on the forum serializer are all hard-coded data. There's another extender hook for before data serialization that can be used for this.

          What are you trying to do though? The groups relation is not a real relation. If you want to make some groups invisible, you should use a visibility scoper. If you want to pre-load specific groups to render in a dropdown list in your extension UI, you should create a new virtual relationship with a unique name, or load the data asynchronously from an API endpoint when needed.

            clarkwinkelmann I'm need to serialize another relationship for actor -> actor.my_relation ( this part is working ) and actor itself is loading to frontend in ShowForumController, also I'm need to eager loads the required relationship.

              As there's always a single actor, eager loading would not bring any performance improvement

                clarkwinkelmann I'm using eager loader for apply visible scoper to model relationship that includes in show controller