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
Details
at
line 43
__construct(string $modelClass)
at
line 59
ModelPrivate
checker(callable|string $callback)
Add a model privacy checker.