我正在尝试在模型的构造函数中检查当前已验证用户是否被允许访问给定的模型,但是我发现构造函数上下文中的$this为空。在Laravel中,属性赋值在哪里,以及在所有属性加载后如何调用方法?
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
var_dump($this); // empty model
$this->checkAccessible();
}
预先祝愿您成功。