Laravel 5 在检索到的事件中访问$hidden属性
我需要修改Laravel 5 在检索到的事件中访问$hidden属性,laravel-5,eloquent,Laravel 5,Eloquent,我需要修改$hidden事件中雄辩模型的$hidden属性,这是一个静态函数,$hidden属性不是静态属性。有什么帮助吗?我想做的是在运行时隐藏一些属性 public function makeHidden($attributes) { $this->hidden = array_merge($this->hidden, (array) $attributes); return $this; } protected st
$hidden
事件中雄辩模型的$hidden
属性,这是一个静态函数,$hidden
属性不是静态属性。有什么帮助吗?我想做的是在运行时隐藏一些属性
public function makeHidden($attributes)
{
$this->hidden = array_merge($this->hidden, (array) $attributes);
return $this;
}
protected static function boot() {
parent::boot();
$user = JWTAuth::authenticate(JWTAuth::getToken());
if ($user === false) {
$user = Channel::authInfo();
$user->type = 'channel';
}
static::retrieved(function($model) use ($user) {
$this->makeHidden($this->toBeHidden[$user->type]);
});
}
请提供一些代码,例如yours@Learner我更新了帖子并添加了代码请提供一些代码,比如yours@Learner我更新了帖子并添加了代码