class ModelPrivate implements ExtenderInterface

Some models, in particular Discussion and CommentPost, are intended to support a "private" mode, wherein they aren't visible unless some criteria is met. This can be used to implement anything from private discussions to post approvals.

When a model is saved, any "privacy checkers" registered for it will be run. If any privacy checkers return `true`, the `is_private` field of that model instance will be set to `true`. Otherwise, it will be set to `false`. Accordingly, this is only available for models with an `is_private` field. In Flarum core, the Discussion and CommentPost models come with private support. Core also contains visibility scopers that hide instances of these models with `is_private = true` from queries. Extensions can register custom scopers for these classes with the `viewPrivate` ability to grant access to view some private instances under some conditions.

Methods

__construct(string $modelClass)

No description

checker(callable|string $callback)

Add a model privacy checker.

void
extend(Container $container, Extension|null $extension = null)

No description

Details

__construct(string $modelClass)

Parameters

string $modelClass

ModelPrivate checker(callable|string $callback)

Add a model privacy checker.

Parameters

callable|string $callback

Return Value

ModelPrivate

void extend(Container $container, Extension|null $extension = null)

Parameters

Container $container
Extension|null $extension

Return Value

void