Behavier for reading only own record like BlameableBehavior for writing

Hallo,

i am searching for a possiblity something like BlameableBehavior

also for reading only his own records from database. Is there a ready solution from Yii2?

when not Maybe someone can give me a Tip how to do it :D

Thank you !

You cannot use behaviours to check for permissions that use a rule that requires the model to be loaded because the model won’t be loaded at that point.

Important point 1) The user should not be able to click on anything they can’t do in the first place. If they cannot read other records, they should never be shown anyone else’s links.

Important point 2) Because of point 1, you can check with Yii::$app->user->can(‘readPost’) in the action function itself (not behavior() ) and throw a 403 exception if the rule fails. Normally this would be not user-friendly but they should not have been able to click on any links anyway.