0
用戶信息作爲它在文檔中說,我想修改信息由find()方法使用beforeFind()方法回調返回。CakePHP的3.X檢索內beforeFind
您可以使用此回調來限制基於 用戶角色的查找操作,或基於當前負載進行緩存決策。
但我實際上不知道如何檢索模型內的用戶信息。例如:
public function beforeFind(\Cake\Event\Event $event, Query $query, $options, $primary) {
$query->where(['society_id' => $user->society_id]);
}
感謝您的時間。
而「_user_」是指當前認證的用戶? – ndm
你看過這個[link](http://book.cakephp.org/3.0/en/controllers/components/authentication.html#accessing-the-logged-in-user)嗎? – Ray
@ndm,是的,我的意思是當前用戶。 – Zat42