use cakephp component inside a model

后端 未结 3 2094
长发绾君心
长发绾君心 2021-02-13 05:03

How do I use a component that I created in cakePHP inside one of my model classes? Is this possible?

If so, please let me know how I can do so

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 05:37

    @AD7six

    // Use anywhere
    AuthComponent::user('id')
    
    // From inside a controller
    $this->Auth->user('id');
    

    From the cake PHP documentation they provide AuthComponent::user('id') so that it can be used in places other than a controller.

    Maybe I need a bigger hint, but why shouldn't my model be able to access ACL information ?

提交回复
热议问题