Level 51
You should be able to use conditional attributes
https://laravel.com/docs/5.7/eloquent-resources#conditional-attributes
Its difficult to give any more specifics with the code provided but should help get you on track.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guyz
I have a question please , I'am using api resource to build my api
I have a relation between contact and lead , in the lead resource I have
...
'contact_person' => ContactPerson::make($this->contacts),
...
in the contact , I return everything because I need all the attributes .
I wanted to know how I can hide some attributes only from lead resource ?
Thank you
Thank you @d9705996
I found a solution , maybe it will help someone :
public function contacts(){
return $this->belongsTo('App\ContactPerson' , 'contact_id')->select(array('id', 'title'));;
}
Please or to participate in this conversation.