Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

laravelstarter's avatar

How to hide appends attribute in laravel query?

hi I want laravel query that hide appends attribute? my model like below

protected $appends = ['name'];

public function getNameAttribute(){ 

    return $this->first_name . ' ' . $this->last_name;

}

$user = user::get();

this above query gets appends name attribute. is that any query to exclude name appends attribute?

and Thanks for answering...

0 likes
4 replies
webrobert's avatar

in the forum, three backticks to open code and three again to close

1 like
bestmomo's avatar
bestmomo
Best Answer
Level 52

You can do that :

$users = User::get()->makeHidden('name');
1 like
laravelstarter's avatar

@bestmomo i know makehidden. First I use it before get(). So it is not working. Now it works after using get().

Thanks BESTMOMO...

Please or to participate in this conversation.